PDA

View Full Version : Buddy list in sidebar?


qpurser
11-14-2011, 12:11 PM
I tried to use the code from the misc.php ->buddylist popup into a sidebar block without any success.
I am not that familiar with coding and some help would be greatly appreciated.

What part of the coding is wrong?

code:
($hook = vBulletinHook::fetch_hook('misc_buddylist_start')) ? eval($hook) : false;

$buddies =& $vbulletin->input->clean_gpc('r', 'buddies', TYPE_STR);

$datecut = TIMENOW - $vbulletin->options['cookietimeout'];

$buddys = $db->query_read_slave("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.userid, session.lastactivity
FROM " . TABLE_PREFIX . "userlist AS userlist
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid)
LEFT JOIN " . TABLE_PREFIX . "session AS session ON(session.userid = user.userid)
WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy'
ORDER BY username ASC, session.lastactivity DESC
");

$onlineusers = '';
$offlineusers = '';
$newusersound = '';
$lastonline = array();

if (isset($buddies))
{
$buddies = urldecode($buddies);
$lastonline = explode(' ', $buddies);
}
$buddies = '0 ';
$show['playsound'] = false;

require_once(DIR . '/includes/functions_bigthree.php');
while ($buddy = $db->fetch_array($buddys))
{
if ($doneuser["$buddy[userid]"])
{
continue;
}

$doneuser["$buddy[userid]"] = true;

if ($onlineresult = fetch_online_status($buddy))
{
if ($onlineresult == 1)
{
$buddy['statusicon'] = 'online';
}
else
{
$buddy['statusicon'] = 'invisible';
}
$buddies .= $buddy['userid'] . ' ';
}
else
{
$buddy['statusicon'] = 'offline';
}

$show['highlightuser'] = false;

($hook = vBulletinHook::fetch_hook('misc_buddylist_bit')) ? eval($hook) : false;

if ($buddy['statusicon'] != 'offline')
{
if (!in_array($buddy['userid'], $lastonline) AND !empty($lastonline))
{
$show['playsound'] = true;
$show['highlightuser'] = true;
// add name to top of list
$templater = vB_Template::create('buddylistbit');
$templater->register('buddy', $buddy);
$onlineusers = $templater->render() . $onlineusers;
}
else
{
$templater = vB_Template::create('buddylistbit');
$templater->register('buddy', $buddy);
$onlineusers .= $templater->render();
}
}
else
{
$templater = vB_Template::create('buddylistbit');
$templater->register('buddy', $buddy);
$offlineusers .= $templater->render();
}
}

$buddies = urlencode(trim($buddies));

($hook = vBulletinHook::fetch_hook('misc_buddylist_complete ')) ? eval($hook) : false;

$templater = vB_Template::create('BUDDYLIST');
$templater->register_page_templates();
$templater->register('buddies', $buddies);
$templater->register('offlineusers', $offlineusers);
$templater->register('onlineusers', $onlineusers);
print_output($templater->render());
}

kh99
11-14-2011, 02:04 PM
In this line:

$buddys = $db->query_read_slave("


you've used $buddys instead of $buddies, but I'm not sure that's the only problem - I think you've copied more code than you need.

BTW, could you edit the above post and put ... around your code? It makes it much easier to read.