Any chance someone can create a buddy list block. A block that only shows your buddies that are online. Just a list of buddy names...
I tried and didn't have much luck.
Well where is Max when you need him the most :P
I can't be sure this will work because I'm the only person who goes to my test site, so there can't be any buddies online. But at least I know there are no syntax errors and it tells me that there are no buddies online. :)
global $scripturl, $db_prefix, $user_info, $txt;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = mysql_fetch_assoc($result))
{
if (in_array($row['ID_MEMBER'], $user_info['buddies']) && (!empty($row['showOnline']) || allowedTo('moderate_forum')))
{
$return['buddies']++;
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<b><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a></b>';
else
$link = '<b><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b>';
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
}
else
echo 'No buddies online at this time';
This is really just taking some lines out of function ssi_whosOnline in SSI.php.
Works perfect! Thanks!
I changed the title and added the topic link to the snippet index.
Quote from: G6 on December 24, 2006, 01:25:49 PM
Well where is Max when you need him the most :P
Haha.. Id probs with a previous code to do with buddys, JPDeni had to help me with it. :up:
Show a "Add Buddy" link under karma in members posts...
Opendefault/Display.template.php
Find:
// Show online and offline buttons?
Add Before:// Can they add this member as a buddy?
if (!empty($modSettings['enable_buddylist']) && ($message['member']['id'] != $context['user']['id'])){
echo '<a href="' . $scripturl . '?action=buddy;u=' . $message['member']['id'] . ';sesc=' . $context['session_id'] . '">' . (empty($message['member']['is_buddy']) ? '[Add To Buddy List]' : '[Remove Buddy From List]') . '</a><br />';
}
Did a bit of work on this to make it linear with an online symbol (wanted to do avatars, but here it is)
Preview:Buddies Online | | No Buddies Online |
| | |
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fnextsite.org%2Fforum%2Fimagehost%2Fuploads%2F991996f517.jpg&hash=99c4da3d21e62aa882e6a5d4d15b2047b21d5a46) | | (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fnextsite.org%2Fforum%2Fimagehost%2Fuploads%2F53c0fea5c7.jpg&hash=ba9b0ea42017870f6d1d931cdfb2a70cac0d8a17) |
Disclaimer:THIS CODE WILL LOOK FUNNY ON YOUR SITE IF YOU HAVE IT ALLOWED FOR GUEST ACCESS, SO I WOULD UNCHECK THAT...HAHA
global $scripturl, $db_prefix, $user_info, $txt, $modSettings;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
$friend_bullet = '<img src ="/Themes/default/images/useron.gif"> ';
while ($row = mysql_fetch_assoc($result))
{
if (in_array($row['ID_MEMBER'], $user_info['buddies']) && (!empty($row['showOnline']) || allowedTo('moderate_forum')))
{
$return['buddies']++;
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<b><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a></b>';
else
$link = '<b><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b>';
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $friend_bullet.$user['link'] . '</i>' : $friend_bullet.$user['link'], $user['is_last'] ? '' : '<br> ';
}
else
echo '<img src ="/Themes/default/images/useroff.gif"> No Friends Online';
Very nice M'lord
I just customize to suit users :D