Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
DevTracker : Search by usergroup Details »»
DevTracker : Search by usergroup
Version: 0.01, by Nxs Nxs is offline
Developer Last Online: Feb 2011 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.6.0 Rating:
Released: 08-06-2006 Last Update: Never Installs: 15
Code Changes Is in Beta Stage  
No support by the author.

DevTracker : Search by usergroup


Description:
Allows you to search for threads containing posts by multiple user ids a.k.a DevTracker

This hack requires you to EDIT a base vbulletin php source file
This hack is in BETA and I could use some feedback please

A good friend (wish i could plug your site Jon but I'd get a slap) mentioned this requirement in passing, and checking vb.com and vb.org yielded no existing hack but plenty of requirements for people to have this on their forum.


Installation
1) Create a new user on your forum, (eg devtracker)
2) Make a note of all the userid's you want to be linked to the tracker, yes I know the title of the hack says usergroups this was just to help search terms (and may come later) (eg 1,5,10,43)
3) Edit the file search.php, find the code below and add the section highlighted, remember to use your own values from the first two steps
4) Publish a new link on your navbar or where required with a ahref of search.php?do=process&searchuser=devtracker&showpo sts=1

Code:
$users = $db->query_read_slave($q);
if ($db->num_rows($users))
{
     $userids = array();
     while ($user = $db->fetch_array($users))
     {
          $postsum += $user['posts'];
          $display['users']["$user[userid]"] = $user['username'];
          $userids[] = in_array($user['userid'], $coventry) ? -1 : $user['userid'];
     }

     $userids = implode(', ', $userids);

     if ($vbulletin->GPC['searchuser'] == 'devtracker') { $userids = '1,5,10,43'; }
                        
     if ($vbulletin->GPC['starteronly'])
     {
          if ($vbulletin->GPC['showposts'])
          {
               $post_query_logic[] = "post.userid IN($userids)";
          }
          $thread_query_logic[] = "thread.postuserid IN($userids)";
     }
Change Log:
7-Aug-06 : (0.01) BETA version

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-07-2006, 07:26 PM
Nxs's Avatar
Nxs Nxs is offline
 
Join Date: May 2004
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If anyone has some constructive ideas of how to improve this, or can think of a way to make it a plugin please feel free to comment or drop me a PM.

If there is no other way than to edit vbulletin source then I would rather keep this to one or two lines of code over enhanced functionality
Reply With Quote
  #3  
Old 08-07-2006, 07:27 PM
Caiman Caiman is offline
 
Join Date: Apr 2004
Location: Manchester UK
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for attempting this, Alan. I'll give it a whirl now, ++kudos

Edit: So far, so good.
Reply With Quote
  #4  
Old 08-08-2006, 12:50 AM
KubisForce KubisForce is offline
 
Join Date: May 2006
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow - Great that you take this project .
But I think the current design sucks. Sorry to say but I would make it like that. So that there is a seperate PHP file for handling those searches.
Reply With Quote
  #5  
Old 08-08-2006, 06:19 AM
Nxs's Avatar
Nxs Nxs is offline
 
Join Date: May 2004
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KubisForce
Wow - Great that you take this project .
But I think the current design sucks. Sorry to say but I would make it like that. So that there is a seperate PHP file for handling those searches.
I heard that link cost a little under $200 - this is free and one line of code to change so forum upgrades will be a breeze. If three is enough interest (or enough spare time) i'll look into doing a wrapper later.
Reply With Quote
  #6  
Old 08-08-2006, 03:07 PM
KubisForce KubisForce is offline
 
Join Date: May 2006
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I hate modifications that cost money. That really sucks.
So I count on you .
Reply With Quote
  #7  
Old 09-30-2006, 11:08 AM
KubisForce KubisForce is offline
 
Join Date: May 2006
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone who wants to improve this hack? That would be really cool...
Reply With Quote
  #8  
Old 02-15-2007, 01:45 AM
Niber Niber is offline
 
Join Date: Sep 2006
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent work. Thank you.
Reply With Quote
  #9  
Old 02-18-2007, 09:15 PM
jksgvb jksgvb is offline
 
Join Date: Jan 2007
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nxs,

Just what I was looking for. Thanks for taking the time to post this.
Reply With Quote
  #10  
Old 04-23-2007, 05:55 PM
Blizzke Blizzke is offline
 
Join Date: Apr 2007
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, if you like to search by groups you can do it like this:
Code:
if ($vbulletin->GPC['searchuser'])
{
   // username too short
   if (!$vbulletin->GPC['exactname'] AND strlen($vbulletin->GPC['searchuser']) < 3)
   {
      $errors[] = 'searchnametooshort';
   }
   else
   {
      if ( $vbulletin->GPC['searchuser'] == 'devtracker' )
      {
         $aDevGroups = Array ( 1, 2, 3 );
         $q = 'SELECT posts, userid, username FROM `' . TABLE_PREFIX . 'user` where usergroupid IN ( ' . implode ( ',', $aDevGroups ) . ') ';
         foreach ( $aDevGroups as $nDevGroup )
            $q .= ' OR concat( membergroupids,"," ) LIKE "%' . $nDevGroup . ',%"';
      }
      else
      {
         $username = htmlspecialchars_uni($vbulletin->GPC['searchuser']);
         $q = "
            SELECT posts, userid, username
            FROM " . TABLE_PREFIX . "user AS user
            WHERE username " .
               ($vbulletin->GPC['exactname'] ?
                  "= '" . $db->escape_string($username) . "'" :
                  "LIKE('%" . sanitize_word_for_sql($username) . "%')"
               )
         ;
      }

      require_once(DIR . '/includes/functions_bigthree.php');
      $coventry = fetch_coventry();
The green section is what you should add in the search.php file, note that you need to replace the $aDevGroups = Array ( 1, 2, 3 ); with an array containing the id's of the groups you wish to track.

How does it work?
Pretty easy. The query returns all users that either have one of the specified groups as the primary group (usergroupid field) or user with one (or more) of the requested groups as secondary.

Why the concat in the query ?
The secondary grouplist consists of a comma separate list of group id's.
We have to add a comma to the search term because otherwise we could pick up partial groups (ie a user in group 10 will be returned if we are looking for group 1). Solution to that is to always include a comma, so look for "1," instead of simple "1".
This poses a second problem: Should a group be the the last, it will not be detected. (eg "1,2" and we are searching for group "2"). So, the logical thing is to add an extra comma to the end of the membergroupids and then search for the groupid with a comma, which will always return the correct user.

Please note the following:
Obviously this is a "decent query" when used on a large board with a lot of users, so you might want to consider taking the initial query out and caching it's results into a small separate table, that way you would only have to select the rows from that table. You could have a script update that table so that you only have to run that once when you add or remove "devs".
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06134 seconds
  • Memory Usage 2,298KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete