NamelessMC

Internet Explorer

Internet Explorer is not supported. Please upgrade to a more modern browser.

[Tutorial] Online Staff Members Module V1
Started by Tsuki

Tsuki

Tsuki

Member
Joined
25 Mar 2017
Last Seen
17 Jan 2022
Topics
5
Posts
27
Hello Nameless Community,

Nameless V1 doesn't have a module where you can see online staff members. I thought I would make this because it can be very useful to the users. Please note this will NOT work with Nameless 2 Pre versions. I am working on a Module for this, which will be released shortly.

Version 2 Version:
https://namelessmc.com/forum/topic/491-nameless-version-20-pre-3-online-staff-members/#post-1750



First I'll post some screenshots.



First, navigate to the following file

pages -> forum -> index.php
open that file and find following piece of code:
 
 
Code
    // List online users
    $online_users = $queries->getWhere('users', array('last_online', '>', strtotime("-10 minutes")));
    if(count($online_users)){
        $online_users_string = '';
        foreach($online_users as $online_user){
            $online_users_string .= '' . htmlspecialchars($online_user->username) . ', ';
        }
        $smarty->assign('ONLINE_USERS_LIST', rtrim($online_users_string, ', '));
    } else {
        // Nobody online
        $smarty->assign('ONLINE_USERS_LIST', $forum_language['no_users_online']);
    }
    $smarty->assign('ONLINE_USERS', $forum_language['online_users']);

Replace it with the following
 
 
New Code
    // List online users
    $online_users = $queries->getWhere('users', array('last_online', '>', strtotime("-10 minutes")));

        foreach ($online_users as $id => $online_user) {
            $groups = $queries->getWhere('groups', array('id', '=', $online_user->group_id));

            if($groups[0]->staff != 1){
                unset($online_users[$id]);
                continue;
            }

            $online_users[$id]->group = $groups[0]->name;
        }

    if(count($online_users)){
        $online_users_string = '';
        foreach($online_users as $online_user){
                $online_users_string .= '' . htmlspecialchars($online_user->mcnam ';
            $online_users_string .= '' . htmlspecialchars($online_user->username) . ' ';
                $online_users_string .= ' - ' . htmlspecialchars($online_user->group) . '';
                $online_users_string .= '
';
                $online_users_string .= '
';


        }
        $smarty->assign('ONLINE_USERS_LIST', rtrim($online_users_string, ', '));
    } else {
        // Nobody online
        $smarty->assign('ONLINE_USERS_LIST', $forum_language['no_users_online']);
    }
    $smarty->assign('ONLINE_USERS', $forum_language['online_users']);

Once you have done this save and reload your site.
In Order to change the title of the module go into your language file and search for
 'online_users' => 'Online Users',
You can then change this too:
 'online_users' => 'Online Staff', 

After that search for 
    'no_users_online' => 'There are no users online.',
It should be one line underneath the other part. Change this to:
    'no_users_online' => 'There are no Staff members online.',

Reload your Site and your new Module will be working. Have Fun!

If you have any problems or questions feel free to ask them in this post!
~Gemerican
x4
Tsuki · over 5 years ago · Last edited: over 4 years ago
Hyfalls

Hyfalls

Management Developer
Joined
11 Oct 2016
Last Seen
18 Aug 2022
Topics
3
Posts
35

Very nice!

<p>Interesting...</p>
Hyfalls · over 5 years ago
MeganPiie

MeganPiie

Member
Joined
30 Oct 2017
Last Seen
30 Oct 2017
Topics
0
Posts
1

Might look into making this into a proper module, instead of a customization to the online members module. Very cool though!

MeganPiie · over 5 years ago · Last edited: over 5 years ago
Tsuki

Tsuki

Member
Joined
25 Mar 2017
Last Seen
17 Jan 2022
Topics
5
Posts
27
MeganPiie:
Might look into making this into a proper module, instead of a customization to the online members module. Very cool though!

I was thinking the same thing. Sadly I looked into it and found that it was easier to do it this way than making a module for V1. I might be starting one for V2. If you want to cooperatrate I think we could make something pretty cool and useful.
Tsuki · over 5 years ago
Hyfalls

Hyfalls

Management Developer
Joined
11 Oct 2016
Last Seen
18 Aug 2022
Topics
3
Posts
35
Gemerican:

I was thinking the same thing. Sadly I looked into it and found that it was easier to do it this way than making a module for V1. I might be starting one for V2. If you want to cooperatrate I think we could make something pretty cool and useful.

V2 is much easier to do it with because v2 has a widgets system :)
<p>Interesting...</p>
Hyfalls · over 5 years ago
Joooonathan

Joooonathan

Member
Joined
30 Jul 2017
Last Seen
29 Dec 2017
Topics
0
Posts
1

Hey,

du kannst glaube ich auch Deutsch. :)
Ich habe das jetzt geändert, aber dann heißt es bei mir, dass die Seite nicht geladen verarbeitet werden kann.
Hinweis: Ich benutze Nameless 2

LG JOnathan

Joooonathan · over 5 years ago
Tsuki

Tsuki

Member
Joined
25 Mar 2017
Last Seen
17 Jan 2022
Topics
5
Posts
27
Joooonathan:
Hey,

du kannst glaube ich auch Deutsch. :)
Ich habe das jetzt geändert, aber dann heißt es bei mir, dass die Seite nicht geladen verarbeitet werden kann.
Hinweis: Ich benutze Nameless 2

LG JOnathan

Leider hab ich diese Lösung nur für Nameless V1 programmiert. Ich arbeite jedoch an einem Module für V2 was in Zukunft raus kommen wird. Bis dann musst du entweder warten oder dich selber ans coden machen.

~ Gemerican
Tsuki · over 5 years ago
Tsuki

Tsuki

Member
Joined
25 Mar 2017
Last Seen
17 Jan 2022
Topics
5
Posts
27
ONLY WORKS WITH V1!

https://gist.github.com/CHYTsuki/7c60c15076789a3af86ce49a1018a78d


You can check this code to be able to do this:

Tsuki · over 5 years ago
Sapphire

Sapphire

Contributor
Joined
28 Jan 2018
Last Seen
24 Jan 2021
Topics
0
Posts
12

I always love the tutorials :D. Easy, simple copy and paste, but sometimes newbie coders might want to know what the code exactly does, therefore learning more about Nameless and PHP as well. Good work on this, the module is always needed and it's a core feature in most of the forum softwares, hopefully, somebody will implement this into Nameless v2 as well ^^.

Sapphire · over 4 years ago · Last edited: over 4 years ago
Tsuki

Tsuki

Member
Joined
25 Mar 2017
Last Seen
17 Jan 2022
Topics
5
Posts
27
-kakara-:
I always love the tutorials :D. Easy, simple copy and paste, but sometimes newbie coders might want to know what the code exactly does, therefore learning more about Nameless and PHP as well. Good work on this, the module is always needed and it's a core feature in most of the forum softwares, hopefully, somebody will implement this into Nameless v2 as well ^^.

Working on it ATM :D
Tsuki · over 4 years ago