MyBB Community Forums

Full Version: [1.8] Keeping track made easy - Egosearch Extreme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The demand for an egosearch functionality for MyBB seems high.
Many plugin requests prove this. (Just see the few most recent ones here and here.)
My last tutorial showed how to unlock the built-in but undocumented egosearch trackkeeping functions in MyBB.
However, phpBB offers a further nifty egosearch mode which MyBB does not have.

I wanted to have that also, and found out that it can be added relatively easily.

In this tutorial I show how you can do this yourself, too.

See first how it looks:
[Image: attachment.php?aid=37367]


If you want this on your board, too, you only need to edit a template and two files.
Insert the red-colored lines into the template header_welcomeblock_member.

Quote:<ul class="menu user_links">
<li><a href="#" onclick="MyBB.popupWindow('{$mybb->settings['bburl']}/misc.php?action=buddypopup&modal=1', null, true); return false;">{$lang->welcome_open_buddy_list}</a></li>
<li><a href="{$mybb->settings['bburl']}/search.php?action=finduserthreads&uid={$mybb->user['uid']}">{$lang->welcome_mythreads}</a></li>
<li><a href="{$mybb->settings['bburl']}/search.php?action=finduserthreads2&uid={$mybb->user['uid']}">{$lang->welcome_mydiscussions}</a></li>
<li><a href="{$mybb->settings['bburl']}/search.php?action=finduser&uid={$mybb->user['uid']}. ">{$lang->welcome_myposts}</a></li>

<li><a href="{$mybb->settings['bburl']}/search.php?action=getnew">{$lang->welcome_newposts}</a></li>
<li><a href="{$mybb->settings['bburl']}/search.php?action=getdaily">{$lang->welcome_todaysposts}</a></li>

In the file inc/languages/english/global.lang.php insert these lines:
Quote:$l['welcome_register'] = "Register";
$l['welcome_open_buddy_list'] = "Open Buddy List";
$l['welcome_mythreads'] = "My Threads";
$l['welcome_mydiscussions'] = "My Discussions";
$l['welcome_myposts'] = "My Posts";

$l['welcome_newposts'] = "New Posts";
$l['welcome_todaysposts'] = "Today's Posts";
If you have other language packs than English installed, you'll probably want to edit their global.lang.php also.

In file search.php modify/insert the lines marked red. The orange lines are already present, but need to be modified the way shown.
Quote:$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif(($mybb->input['action'] == "do_search" && $mybb->request_method == "post") || ($mybb->input['action'] == "finduserthreads2"))
{
$plugins->run_hooks("search_do_search_start");

// Check if search flood checking is enabled and user is not admin

<snip>

error($lang->error_searchflooding);
}
}
if(($mybb->get_input('showresults') == "threads") || ($mybb->input['action'] == "finduserthreads2"))
{
$resulttype = "threads";
}
else
{
$resulttype = "posts";
}
       if($mybb->input['action'] == "finduserthreads2")
       {
               $search_data = array(
                       "keywords" => '',
                       "author" => $mybb->user['username'],
                       "postthread" => '1',
                       "matchusername" => $mybb->user['username'],
                       "postdate" => '',
                       "pddir" => '',
                       "forums" => '',
                       "findthreadst" => '',
                       "numreplies" => '',
                       "threadprefix" => ''
               );
       } else {

               $search_data = array(
                       "keywords" => $mybb->input['keywords'],
                       "author" => $mybb->get_input('author'),
                       "postthread" => $mybb->get_input('postthread', MyBB::INPUT_INT),
                       "matchusername" => $mybb->get_input('matchusername', MyBB::INPUT_INT),
                       "postdate" => $mybb->get_input('postdate', MyBB::INPUT_INT),
                       "pddir" => $mybb->get_input('pddir', MyBB::INPUT_INT),
                       "forums" => $mybb->input['forums'],
                       "findthreadst" => $mybb->get_input('findthreadst', MyBB::INPUT_INT),
                       "numreplies" => $mybb->get_input('numreplies', MyBB::INPUT_INT),
                       "threadprefix" => $mybb->get_input('threadprefix', MyBB::INPUT_ARRAY)[/color]
              );
        }
if(is_moderator() && !empty($mybb->input['visible']))
{
$search_data['visible'] = $mybb->get_input('visible', MyBB::INPUT_INT);
}

If you like my tutorial, please consider clicking the "Rate" button. Cool

Enjoy! Smile


Edit/Update:
To make things easier I have uploaded the search.php file as it runs on my server.
Please first make a backup of your old search.php first. You can then download the modified search.php from github instead of hand-editing it.
This might be the preferable way, because it is very, very easy to make the slightest mistake when editing this file. If your forum server throws error messages after editing, fails otherwise or if the egosearch just does not work correctly, this might be an indicator of such an editing mistake that you can avoid by just downloading and replacing the file.
Is it possible to find or even list user threads only from specifc forums?