SimplePortal

Customization => Custom Coding => Topic started by: gossebezak on June 26, 2010, 12:43:13 PM

Title: Who's Online Block
Post by: gossebezak on June 26, 2010, 12:43:13 PM
Hello !
Can you help me to change my "who's online block??"

I would like to have the list of users online, and their avatar next to them (instead of this (http://simpleportal.net/Themes/default/images/sp/user.png))
And if possible, when clicking avatar, being redirect to "send a private message" to this member.

Is it possible please??
Thank you very much!!

smf 2.0 RC3
SP : 2.3.2
Title: Re: Re: Who's Online Block adjustment
Post by: Nathaniel on June 26, 2010, 11:28:21 PM
Split from the other topic, this is a completely different issue.
Title: Re: Who's Online Block adjustment
Post by: gossebezak on June 27, 2010, 04:35:21 AM
ok sorry  ;)

Somebody can help me please??  :thumbsup:
thanks!
Title: Re: Who's Online Block
Post by: gossebezak on June 29, 2010, 01:08:19 PM
Hello,
I would like to have something like that.

(http://img291.imageshack.us/img291/5333/whosy.jpg)

with a direct link on avatar to PM.

Can somebody help me??
I'm a newie with the php code  :D
Thanks
Title: Re: Who's Online Block
Post by: York on July 01, 2010, 12:19:13 PM
I am also very interested by this modification.
Someone can help us ?
Please  :thumbsup:
Title: Re: Who's Online Block
Post by: Nathaniel on July 02, 2010, 10:31:35 PM
Find the 'sp_WhosOnline' function in your 'Sources/PortalBlocks.php' file and replace it with the function below:

Code: [Select]
function sp_whosOnline($parameters, $id, $return_parameters = false)
{
global $scripturl, $sourcedir, $modSettings, $txt, $smcFunc;

$block_parameters = array(
'online_today' => 'check'
);

if ($return_parameters)
return $block_parameters;

$online_today = !empty($parameters['online_today']);

$stats = ssi_whosOnline('array');

$members = array();
foreach ($stats['users_online'] as $user)
$members[] = $user['id'];

if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

$request = $smcFunc['db_query']('','
SELECT
m.id_member, m.avatar,
a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
WHERE m.id_member in ({array_int:members})',
array(
'members' => $members,
)
);

$avatars = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$avatars[$row['id_member']] = array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
);
}
$smcFunc['db_free_result']($request);

echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ', $txt['guests'], ': ', $stats['num_guests'], '</li>';

if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')))
echo '
<li>', sp_embed_image('dot'), ' ', $txt['spiders'], ': ', $stats['num_spiders'], '</li>';

echo '
<li>', sp_embed_image('dot'), ' ', $txt['hidden'], ': ', $stats['num_users_hidden'], '</li>
<li>', sp_embed_image('dot'), ' ', $txt['users'], ': ', $stats['num_users_online'], '</li>';

if (!empty($stats['users_online']))
{
echo '
<li>', sp_embed_image('dot'), ' ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '<a href="' . $scripturl . '?action=who">' : '', $txt['online_users'], allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '</a>' : '', ':</li>
</ul>
<div class="sp_online_flow">
<ul class="sp_list">';

foreach ($stats['users_online'] as $user)
echo '
<li class="sp_list_indent">', $avatars[$user['id']]['image'], ' <span style="vertical-align: top;">', $user['hidden'] ? '<em>' . $user['link'] . '</em>' : $user['link'], '</span></li>';

echo '
</ul>
</div>';
}
else
{
echo '
</ul>
<br />
<div class="sp_fullwidth sp_center">', $txt['error_sp_no_online'], '</div>';
}

if ($online_today && file_exists($sourcedir . '/Subs-MembersOnlineToday.php'))
{
require_once($sourcedir . '/Subs-MembersOnlineToday.php');

$membersOnlineTodayOptions = array(
'sort' => 'login_time',
'reverse_sort' => true,
'period' => 'current_day',
'canview' => 'registered',
);

$stats += getMembersOnlineTodayStats($membersOnlineTodayOptions);

if (empty($stats['num_users_online_today']))
return;

echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ', $txt['sp-online_today'], ': ', $stats['num_users_online_today'], '</li>
</ul>
<div class="sp_online_flow">
<ul class="sp_list">';

foreach ($stats['users_online_today'] as $user)
echo '
<li class="sp_list_indent">', sp_embed_image($user['name'] == 'H' ? 'tux' : 'user'), ' ', $user['hidden'] ? '<em>' . $user['link'] . '</em>' : $user['link'], '</li>';

echo '
</ul>
</div>';
}
}
Title: Re: Who's Online Block
Post by: gossebezak on July 03, 2010, 01:25:11 PM
Thank you very much!! It's a great change for my website
how can i change the size of the avatar?? I would like to have avatar : 40 x 40 .

Thank you again!  :D
Title: Re: Who's Online Block
Post by: Nathaniel on July 03, 2010, 10:31:50 PM
Code: ("Find (in that function)") [Select]
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

Code: ("Replace") [Select]
$avatar_width = '40';
$avatar_height = '40';
Title: Re: Who's Online Block
Post by: gossebezak on July 04, 2010, 07:28:09 AM
 :nervous-happy: Thanks for your help but it doesn't change the avatar size.
I still have this... :(

(http://img804.imageshack.us/img804/1381/marchepas.jpg)

Title: Re: Who's Online Block
Post by: Nathaniel on July 04, 2010, 09:49:45 PM
Whoops, try this:
Code: [Select]
$avatar_width = ' width="40"';
$avatar_height = ' height="40"';
Title: Re: Who's Online Block
Post by: gossebezak on July 05, 2010, 06:57:48 AM
hum... still doesn't work  :0
Thank you very much for your help  :thumbsup:
Title: Re: Who's Online Block
Post by: gossebezak on July 07, 2010, 06:47:01 AM
In other blocks, where the avatar are resized, there is this code : (in topmember bloc here)

Code: [Select]
foreach ($members as $member)
echo '
<tr>
<td class="sp_top_poster sp_center">', !empty($member['avatar']['href']) ? '
<img src="' . $member['avatar']['href'] . '" alt="' . $member['name'] . '" width="40" />' : '', '
</td>
<td>
', $member['link'], '<br />
', $member['posts'], ' ', $txt['posts'], '
</td>
</tr>';

echo '
</table>';

Is it possible to ingrate this kind of code in my bloc? Maybe it can work...
Thank you
Title: Re: Who's Online Block
Post by: gossebezak on July 12, 2010, 05:23:23 PM
Any idea??  ;)
Title: Re: Who's Online Block
Post by: gossebezak on September 19, 2010, 12:01:34 PM
Humm I Up the topic  :D
Can somebody help me to find what's wrong in this code.
The avatars are big, and not 40x40...

I try but I don't find the solution.  :|
SimplePortal 2.3.8 © 2008-2024, SimplePortal