Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Rain Forest - elokuu 11, 2014, 12:57:33 IP

Otsikko: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Rain Forest - elokuu 11, 2014, 12:57:33 IP
Hello!

I have search through other support topics (for example completely remove forum stats & users online (http://www.simplemachines.org/community/index.php?topic=315684.0)) but I haven't see a perfect solution yet.

I want to know how I can hide the 'Who's online/Users online' list from all but admins.

Do I need to add this somewhere?

if (!$context['user']['is_guest'])

in Boardindex.template.php
// "Users online" - in order of activity.
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '
</span>
</h4>
</div>
<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];



Using default theme.
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Ninja ZX-10RR - elokuu 11, 2014, 02:35:52 IP
Actually there is a permission for this... {your forum url}/index.php?action=helpadmin;help=permissionhelp_who_view just uncheck it for all membergroups :)
The permission is "View Who's Online" under "Use basic forum functionality" ;)
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Rain Forest - elokuu 11, 2014, 05:07:34 IP
Error occurred: 404 - not found

I know that if I unlock 'view who's online' regular members can't see the memberlist. Although they can see the 'who's online list' without enable to click on 'members online'.



As regular member they see this right now:

Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Arantor - elokuu 11, 2014, 05:09:58 IP
There's no way to configure SMF to hide that users online list on the front page. Only way it can be done is to modify the code you've already mentioned.
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Steve - elokuu 11, 2014, 05:40:31 IP
Then what does that permission do?
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Illori - elokuu 11, 2014, 05:41:36 IP
the who's online list
http://www.simplemachines.org/community/index.php?action=who
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Ninja ZX-10RR - elokuu 11, 2014, 05:47:16 IP
Lainaus käyttäjältä: Steve - elokuu 11, 2014, 05:40:31 IP
Then what does that permission do?
It deactivates the possibility to click on the who's online list and see the details about who is doing what (the link provided by Illori) ;) while the other one deactivates the memberslist at all.
There are no mods for it as well so...
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Steve - elokuu 11, 2014, 05:49:34 IP
@ Illori: If you're trying to confuse me you're doing a good job. :P

Thanks for explanation ... I think ...  ???

Wait! Let me see if I have this straight. One can't hide the who's online information on the index page but the permission prevents one from seeing WHERE online they are, right?
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Arantor - elokuu 11, 2014, 06:02:14 IP
There are two 'who's online' lists.

There is the short form of who is online, a list of names, which is on the board index. No permission. Shown to everyone.

There is long form, which shows what everyone is doing. Controlled by permission.
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Rain Forest - elokuu 11, 2014, 06:21:07 IP
So, in order to remove the who's online list from board index I have to remove this code and replace it by 'echo?

// "Users online" - in order of activity.
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '
</span>
</h4>
</div>
<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Steve - elokuu 11, 2014, 08:53:02 IP
Lainaus käyttäjältä: ‽ - elokuu 11, 2014, 06:02:14 IP
There are two 'who's online' lists.

There is the short form of who is online, a list of names, which is on the board index. No permission. Shown to everyone.

There is long form, which shows what everyone is doing. Controlled by permission.

So the short answer to my question is yes. :P
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 11, 2014, 11:43:39 IP
OP, use

if ($context['user']['is_admin']) {

The said who's online code  (short form) in here <==

}


Edited: Note that you may also use if (allowedTo('who_view')) to extend the functionality of the permission in the who is online page to the board index. In that case, just replace the above code if ($context['user']['is_admin']) with  if (allowedTo('who_view')) and disable / untick permission to view who is online in the admin permission page.

Edited again: Note also that the whole who is online code in Board Index page is as follows:
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '
</span>
</h4>
</div>
<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
if (!empty($context['num_users_hidden']))
$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . $txt['hidden'];

if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';

echo $context['show_who'] ? '</a>' : '', '
</p>
<p class="inline smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

// Showing membergroups?
if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
echo '
<br />[' . implode(']&nbsp;&nbsp;[', $context['membergroups']) . ']';
}

echo '
</p>
<p class="last smalltext">
', $txt['most_online_today'], ': <strong>', comma_format($modSettings['mostOnlineToday']), '</strong>.
', $txt['most_online_ever'], ': ', comma_format($modSettings['mostOnline']), ' (', timeformat($modSettings['mostDate']), ')
</p>';
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Chalky - elokuu 12, 2014, 01:39:39 AP
Of course, there's always an easier way  ;)

http://custom.simplemachines.org/mods/index.php?mod=2473
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 12, 2014, 01:59:45 AP
Err... I thought OP wants to hide only who is online in Board Index page not the whole info center?
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Chalky - elokuu 12, 2014, 02:20:21 AP
Ah, maybe  :P
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 12, 2014, 02:52:24 AP
So this mod already extended permission to who is online in board index page, is that what you mean?

Edited: Tested the mod. It only creates permission to access Info Center as a whole, and not any part of it (including who is online).

With regards to who is online, which this mod moves, to be under a new Info Center permission title. This IMO creates a confusion since who is online is originally meant for its own page not board index page (though it can be extended to it as suggested above).

This mod also causes some breaks which can be remedied by adding <br /> if it denies access to it (as suggested to me by SMF Customization Team for my withdrawn mod).
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Rain Forest - elokuu 12, 2014, 07:59:56 AP
Ehm, ok..

This topic confuses me now :P One say yes, other says no.

Can I hide the who's online list on the bottom of the forums for anyone but admins?
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Ninja ZX-10RR - elokuu 12, 2014, 08:41:06 AP
Lainaus käyttäjältä: ‽ - elokuu 11, 2014, 05:09:58 IP
There's no way to configure SMF to hide that users online list on the front page. Only way it can be done is to modify the code you've already mentioned.
If someone manages to do it then it would be editing the code...
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 12, 2014, 10:56:35 AP
Yes. The answer is definitely by editing the code as suggested in post #11 OP. If the OP still cannot resolve this on his own, I will try to take a look at this again when I am in front of my PC.
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Rain Forest - elokuu 12, 2014, 11:09:36 AP
Ok :)

Finally!

Adding:
if ($context['user']['is_admin']) {


Before
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '
</span>
</h4>
</div>
<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
if (!empty($context['num_users_hidden']))
$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . $txt['hidden'];

if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';

echo $context['show_who'] ? '</a>' : '', '
</p>
<p class="inline smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

// Showing membergroups?
if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
echo '
<br />[' . implode(']&nbsp;&nbsp;[', $context['membergroups']) . ']';
}

echo '
</p>
<p class="last smalltext">
', $txt['most_online_today'], ': <strong>', comma_format($modSettings['mostOnlineToday']), '</strong>.
', $txt['most_online_ever'], ': ', comma_format($modSettings['mostOnline']), ' (', timeformat($modSettings['mostDate']), ')
</p>';


and adding this after that code

}
worked for me! Only admins can see it now.
Thanks! :)
Otsikko: Re: [SMF 2.0.8] Hide who's online lists for anyone but admins
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 12, 2014, 12:53:30 IP
Nice to hear that.