Guest User

Untitled

a guest
May 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. function slf_GetUserGroupInfo()
  2. {
  3.     global $db;
  4.     $Result = array();
  5.     $Fetch = $db->query_read
  6.     (
  7.         'SELECT '.
  8.             'usergroupid, '.
  9.             'usertitle, '.
  10.             'opentag, '.
  11.             'closetag '.
  12.         'FROM usergroup'
  13.     );
  14.     while($Row = $db->fetch_array($Fetch))
  15.     {
  16.         $Result[$Row['usergroupid']]['usertitle'] = $Row['usertitle'];
  17.         $Result[$Row['usergroupid']]['opentag'] = $Row['opentag'];
  18.         $Result[$Row['usergroupid']]['closetag'] = $Row['closetag'];
  19.     }
  20.     return($Result);
  21. }
  22.  
  23. function slf_FormatForumName($ForumId, $UserGroupInfo)
  24. {
  25.     global $db;
  26.     $Fetch = $db->query_read
  27.     (
  28.         'SELECT '.
  29.             'username, '.
  30.             'IF(displaygroupid=0, usergroupid, displaygroupid) AS usergroup '.
  31.         'FROM user '.
  32.         'WHERE userid = '.($ForumId * 1).' '.
  33.         'LIMIT 1'
  34.     );
  35.     $Row = $db->fetch_array($Fetch);
  36.  
  37.     // Format name.
  38.     $Group = $Row['usergroup'];
  39.     $OpenTag = $UserGroupInfo[$Group]['opentag'];
  40.     $CloseTag = $UserGroupInfo[$Group]['closetag'];
  41.     return($OpenTag.$Row['username'].$CloseTag);
  42. }
  43.  
  44. ////////////////////////// USAGE ////////////////////////////
  45.  
  46. function mysub()
  47. {
  48.     // First call this at top of the sub
  49.     $UserGroupInfo = slf_GetUserGroupInfo();
  50.  
  51.     // This is the vBulletin User ID we want to get the name for.
  52.     $TheUserId = 6;
  53.  
  54.     // Not only get the name, but format it so it looks like a real vBulletin username.
  55.     $ClickableFormattedName = '<a href="/member.php?u='.$TheUserId.'">'.slf_FormatForumName($TheUserId, $UserGroupInfo).'</a>';
  56.  
  57.     // Do something with it.
  58.     echo $ClickableFormattedName;
  59. }
Add Comment
Please, Sign In to add comment