Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: maximumrock on April 05, 2011, 06:09:29 PM

Title: Customize 'Who's Online'
Post by: maximumrock on April 05, 2011, 06:09:29 PM
Is there any way i could customize what regular users see on "Who's Online" screen......i have  SMF 2.0 RC5

on the screen, there is a drop down box that i can do for myself to view only Everyone, Members Only, and Guests.

I want everyone to be able to only have option to see "members only"......Any way to do that?

thx,
Max
Title: Re: Customize 'Who's Online'
Post by: IchBin™ on April 06, 2011, 12:07:02 PM
You can comment out the other array items if you only want to show members.

Code (find in Sources/Who.php) Select
$context['show_methods'] = array(
'all' => $txt['who_show_all'],
'members' => $txt['who_show_members_only'],
'guests' => $txt['who_show_guests_only'],
);



Code (change to this) Select
$context['show_methods'] = array(
//'all' => $txt['who_show_all'],
'members' => $txt['who_show_members_only'],
//'guests' => $txt['who_show_guests_only'],
);
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 07, 2011, 05:41:25 PM
Thanks!! those 2 thing u posted look the same? i cant see a difference in code,

what part would i change on on the 2nd one?
Title: Re: Customize 'Who's Online'
Post by: MoreBloodWine on April 07, 2011, 05:46:25 PM
Quote from: maximumrock on April 07, 2011, 05:41:25 PM
Thanks!! will admins still be able to view all guests and such??
No because his suggestion cuts them out all together.

You might have to use something like this... provided I formatted it right.

Find:
     $context['show_methods'] = array(
         'all' => $txt['who_show_all'],
         'members' => $txt['who_show_members_only'],
         'guests' => $txt['who_show_guests_only'],
     );


Replace With:
if($context['user']['is_admin']){
     $context['show_methods'] = array(
         'all' => $txt['who_show_all'],
         'members' => $txt['who_show_members_only'],
         'guests' => $txt['who_show_guests_only'],
     );
}else{
     $context['show_methods'] = array(
//       'all' => $txt['who_show_all'],
         'members' => $txt['who_show_members_only'],
//       'guests' => $txt['who_show_guests_only'],
     );
}
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 07, 2011, 06:21:16 PM
thanks again. i will mess with it tonight..
Title: Re: Customize 'Who's Online'
Post by: MoreBloodWine on April 07, 2011, 06:23:22 PM
Quote from: maximumrock on April 07, 2011, 06:21:16 PM
thanks again. i will mess with it tonight..
Welcome and like I said, provided I wrote it right that should allow everyone to see only members with the exception to site admin being allowed to see everyone.
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 07, 2011, 09:13:39 PM
Moreblood.... No luck on that one. BUT the drop down box is locked to show show  "members only".......not sure why it still shows guests when i log on as a regular member...So you are definitely on the right track..

Only thing i notice thats odd is these 2 lines (on the code you gave me to replace with) in dreamweaver code view, show up as "yellow/orange" instead of mostly RED like the others.. Could that be something you think?


//       'all' => $txt['who_show_all'],
//       'guests' => $txt['who_show_guests_only'],


Title: Re: Customize 'Who's Online'
Post by: MoreBloodWine on April 07, 2011, 11:00:01 PM
Maybe the code originally posted that I modified was just for the drop box and not the actual display. One way to tell would be to implement my code and then check the drop box on admin, then logged out a guest / regular member. Again, provided I wrote it right.

The // just comments them out from PHP reading it, in reality you can just remove the two lines with the preceding //'s.
Quote from: maximumrock on April 07, 2011, 09:13:39 PM
Moreblood.... No luck on that one. BUT the drop down box is locked to show show  "members only".......not sure why it still shows guests when i log on as a regular member...So you are definitely on the right track..

Only thing i notice thats odd is these 2 lines (on the code you gave me to replace with) in dreamweaver code view, show up as "yellow/orange" instead of mostly RED like the others.. Could that be something you think?


//       'all' => $txt['who_show_all'],
//       'guests' => $txt['who_show_guests_only'],

Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 07, 2011, 11:55:36 PM
I logged in as admin and everything normal is it was originally to me.. but when i go back onto a guest/regular acct, Only change is just the drop box only shows "members only" but guests are still viewable
Title: Re: Customize 'Who's Online'
Post by: MoreBloodWine on April 08, 2011, 02:07:34 AM
Quote from: maximumrock on April 07, 2011, 11:55:36 PM
I logged in as admin and everything normal is it was originally to me.. but when i go back onto a guest/regular acct, Only change is just the drop box only shows "members only" but guests are still viewable
Again, that's because it's for just the dropbox... attach your Who.template.php file and I'll fix it up for ya so the lists display based on values in the drop box.

ie. As admin everything shows as is does now fine, but if logged out as guest / regular user only members show in the drop box as well as the actual list of users.
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 08, 2011, 10:23:25 AM
ohh ok.. thx alot..

here is my original one without any edits..
Title: Re: Customize 'Who's Online'
Post by: MoreBloodWine on April 08, 2011, 06:03:18 PM
Quote from: maximumrock on April 08, 2011, 10:23:25 AM
ohh ok.. thx alot..

here is my original one without any edits..
DL now get this back to you in about an hr or so if thats alright. Got some other stuff I need to finish ;-)
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 08, 2011, 06:56:34 PM
sounds good! thx!
Title: Re: Customize 'Who's Online'
Post by: MoreBloodWine on April 08, 2011, 07:14:36 PM
Quote from: maximumrock on April 08, 2011, 06:56:34 PM
sounds good! thx!

Something came up and I need to run out of the house for a few hrs so I'll get to this when I'm back, in the meantime if someone else wanted to jump on it that's fine because the basic codes already there with the if statement I posted before for the drop box. It's just a matter of placement.
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 08, 2011, 07:22:13 PM
dude, no worries at all.. in no rush.... thx for the heads up..
Title: Re: Customize 'Who's Online'
Post by: HunterP on April 10, 2011, 12:55:20 PM
Quote from: IchBin™ on April 06, 2011, 12:07:02 PM
Code (find in Sources/Who.php) Select
$context['show_methods'] = array(
'all' => $txt['who_show_all'],
'members' => $txt['who_show_members_only'],
'guests' => $txt['who_show_guests_only'],
);


By default, "guests" is selected. How can i make "Members" the default selection?
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 12, 2011, 11:47:50 AM
Good question Hunter.  On the code that moreblood first provided to me.. that did give me the only option for "members" but didnt take effect on the who's online list....... Maybe his solution to me will help you too..
Title: Re: Customize 'Who's Online'
Post by: maximumrock on April 19, 2011, 02:15:59 PM
Hey MoreBlood. just wondering if you got a chance to look that over yet?

thx
Title: Re: Customize 'Who's Online'
Post by: jrstark on April 29, 2011, 01:57:47 PM
Is there any way to remove mentions of who is reporting a post?  I'd like to protect whistleblowers.  I'm using 1.1.13.
Title: Re: Customize 'Who's Online'
Post by: Owdy on April 29, 2011, 02:10:33 PM
Quote from: jrstark on April 29, 2011, 01:57:47 PM
Is there any way to remove mentions of who is reporting a post?  I'd like to protect whistleblowers.  I'm using 1.1.13.

Sure, just edit the lang file.


Who.english.php

$txt['whoall_reporttm'] = 'Reporting a topic to a moderator.';

to

$txt['whoall_reporttm'] = 'Drinking Pepsi';
Title: Re: Customize 'Who's Online'
Post by: jrstark on April 29, 2011, 03:23:58 PM
Very cool, thanks!
Title: Re: Customize 'Who's Online'
Post by: Owdy on April 29, 2011, 04:03:29 PM
If you are using SMF 2, remember empty SMF cache after lang file edit (if you dont edit it via admin panel) :)
Title: Re: Customize 'Who's Online'
Post by: HunterP on October 16, 2011, 01:23:15 PM
Quote from: HunterP on April 10, 2011, 12:55:20 PM
Quote from: IchBin™ on April 06, 2011, 12:07:02 PM
Code (find in Sources/Who.php) Select
$context['show_methods'] = array(
'all' => $txt['who_show_all'],
'members' => $txt['who_show_members_only'],
'guests' => $txt['who_show_guests_only'],
);


By default, "guests" is selected. How can i make "Members" the default selection?

Took a while (ofcourse I haven't bee looking for this all the time), but I found it :

File : Who.php
Function: Who()

// Fallback to top filter?
if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
$_REQUEST['show'] = $_REQUEST['show_top'];
// Does the user wish to apply a filter?
if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
{
$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
$conditions[] = $show_methods[$_REQUEST['show']];
}
// Perhaps we saved a filter earlier in the session?
elseif (isset($_SESSION['who_online_filter']))
{
$context['show_by'] = $_SESSION['who_online_filter'];
$conditions[] = $show_methods[$_SESSION['who_online_filter']];
}
else
$context['show_by'] = $_SESSION['who_online_filter'] = 'all';


Change the last line into :

$context['show_by'] = $_SESSION['who_online_filter'] = 'members';

And "members" will be the default selection.
Title: Re: Customize 'Who's Online'
Post by: Shambles on October 16, 2011, 01:36:48 PM
Quote from: HunterP on October 16, 2011, 01:23:15 PM

Change the last line into :

$context['show_by'] = $_SESSION['who_online_filter'] = 'members';

And "members" will be the default selection.

Thank you. I've been hunting that down for a week now  ;D
Title: Re: Customize 'Who's Online'
Post by: HunterP on November 19, 2011, 04:14:23 PM

A little update. Sometimes when the dropdownbox shows "members", all visitors (members and guests) are being displayed. When selecting all (or guests) and reselecting "Members" again, it's OK. I figured out that one line needs to be added :

// Does the user wish to apply a filter?
if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
{
$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
$conditions[] = $show_methods[$_REQUEST['show']];
}
// Perhaps we saved a filter earlier in the session?
elseif (isset($_SESSION['who_online_filter']))
{
$context['show_by'] = $_SESSION['who_online_filter'];
$conditions[] = $show_methods[$_SESSION['who_online_filter']];
}
else
{
$context['show_by'] = $_SESSION['who_online_filter'] = 'members'; // was 'all'
$conditions[] = $show_methods[$_REQUEST['show']];
}


When I added the last line :

      $conditions[] = $show_methods[$_REQUEST['show']];

It finally seems to work OK.