TinyPortal

Development => Support => Topic started by: cepsi on February 08, 2009, 08:45:59 PM

Title: Buddy list php block
Post by: cepsi on February 08, 2009, 08:45:59 PM
Hi,

ive got a php block which lists all my online buddies (i think i got it from here but had a look in the snippets and couldnt find it)
my question is, is there somewhere in that can be altered that instead of showing the buddies all grouped up (pic 1) can i show them in a line as the stats block does with the bullets (pic 2)

Pic 1
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi534.photobucket.com%2Falbums%2Fee350%2Fsurrealkiller_photos%2Fpic1-1.jpg&hash=ae08fd74e411a9f98a6f9f98396ac09c05399215)

Pic 2
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi534.photobucket.com%2Falbums%2Fee350%2Fsurrealkiller_photos%2Fpic2-1.jpg&hash=639eca7c48d5f8ca5b8b18a8648a0f218e8f4151)



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';



(i will keep looking for teh snippet so i can credit the source and original post if its here)

EDIT: found it, its one of JPDeni's ORIGINAL POST (http://www.tinyportal.net/index.php/topic,11713.0.html)

as usual thx for any help or guidance ;)

Link to my site: http://www.thepokerpod.com
SMF version: SMF ver. 1.1.7
TP version: TP ver.1.0.5
Theme name and version: Dark_4
Title: Re: Buddy list php block
Post by: JPDeni on February 08, 2009, 10:42:18 PM

if (!empty($return['users']))
{
krsort($return['users']);
        echo '<ul>';
        foreach ($return['users'] as $user) {
                echo '<li>';
        echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
                echo '</li>';
        }
        echo '</ul>';
}
else
        echo 'No Buddies Online';
Title: Re: Buddy list php block
Post by: cepsi on February 08, 2009, 10:55:49 PM
Thx JPDeni u r the best! :D
Title: Re: Buddy list php block
Post by: JPDeni on February 08, 2009, 11:29:06 PM
:D