1

Topic: Styling the onlinenames...

It would be nice if the names in the onlinelist was styled on a way or another depending on the user status (Administrator, Moderator, User). Something to add to the 1.2?

Religion is the result of a mans imagination.

2 (edited by Frank H 2004-10-07 20:05)

Re: Styling the onlinenames...

have you noticed the setting where you can choose "Show users of status" and be able to select Admins, Moderators, Members or all?

or do you mean they should have different colors and stuff?

Re: Styling the onlinenames...

yeah i think thats his point
would like it too

4

Re: Styling the onlinenames...

Frank H wrote:

have you noticed the setting where you can choose "Show users of status" and be able to select Admins, Moderators, Members or all?

or do you mean they should have different colors and stuff?


Yeah, bold and italic would work fine for me.

Religion is the result of a mans imagination.

5 (edited by Smartys 2004-10-08 00:10)

Re: Styling the onlinenames...

OK, one sec and I'll see what you would have to modify.

Edit:

index.php

FIND:

$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);


REPLACE WITH:

$result = $db->query('SELECT id, username,status FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);


FIND:
    while ($cur_user_online = $db->fetch_assoc($result))
    {
        if ($cur_user_online['user_id'] > 0)
            $users[] = '<a href="profile.php?id='.$cur_user_online['user_id'].'">'.pun_htmlspecialchars($cur_user_online['ident']).'</a>';
        else
            ++$num_guests;
    }


REPLACE WITH

    while ($cur_user_online = $db->fetch_assoc($result))
    {
        if ($cur_user_online['user_id'] > 0)
        {
            if ($stats['last_user'] > PUN_USER)
            $users[] = '<i><a href="profile.php?id='.$cur_user_online['user_id'].'">'.pun_htmlspecialchars($cur_user_online['ident']).'</a></i>';
            else
            $users[] = '<a href="profile.php?id='.$cur_user_online['user_id'].'">'.pun_htmlspecialchars($cur_user_online['ident']).'</a>';
        }
        else
            ++$num_guests;
    }

That will make any mods/admins who are online show up in italics (substitute other HTML for the <i> and </i>s if you wish)

Edit: Fixed, ty Rickard, and silly me tongue

6

Re: Styling the onlinenames...

If you are going to do that why not put a class on the <a> instead then you can style them how you wish via the stylesheet.

<a class="vipuser" href etc

Re: Styling the onlinenames...

Smartys: That won't work. $cur_user is you, not the user on the list :) You have to join in the users table.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8

Re: Styling the onlinenames...

Am I safe in assuming this is not going to be a standard feature smile

Re: Styling the onlinenames...

LMAO, silly me tongue
/me makes the change

Re: Styling the onlinenames...

Paul wrote:

Am I safe in assuming this is not going to be a standard feature :)

Yes :)

"Programming is like sex: one mistake and you have to support it for the rest of your life."

11

Re: Styling the onlinenames...

Smartys: thanks! The code worked fine smile

Religion is the result of a mans imagination.

Re: Styling the onlinenames...

No problem.
But thank Rickard, without him you would have had a non working chunk of code tongue

13

Re: Styling the onlinenames...

This does not work on punBB 1.2.7, I get an error saying 'Registered user cannot be fetched.'

14 (edited by Smartys 2005-09-07 20:02)

Re: Styling the onlinenames...

I'm going to write this up for 1.2.7 smile
I'm not even sure how this code would have worked in 1.1.5, it fetched from the wrong query (I think) :-/

index.php

FIND:
$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

REPLACE WITH:
$result = $db->query('SELECT o.user_id, o.ident, u.group_id AS status FROM '.$db->prefix.'online AS o INNER JOIN '.$db->prefix.'users AS u ON u.id = o.user_id WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

FIND:
    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1)
            $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
        else
            ++$num_guests;
    }


REPLACE WITH
    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1)
        {
            if ($pun_user_online['status'] > PUN_MOD)
                $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
            else
                $users[] = "\n\t\t\t\t".'<dd><i><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a></i>';
        }        
        else
            ++$num_guests;
    }

That will make any mods/admins who are online show up in italics (substitute other HTML for the <i> and </i>s if you wish)

Edit: This is untested, tell me if it works or not smile

15

Re: Styling the onlinenames...

Works great now!  Thanks!  smile