[Solved]: Colorcode usernames by group? (unbridged) [Solved]: Colorcode usernames by group? (unbridged)
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: Colorcode usernames by group? (unbridged)

Started by stardust, July 10, 2008, 04:34:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

stardust

Hi, I want to set a color for certain groups so that visitors can see in the "Online Stats" feature what group a user belongs to. Like regular Registered Members are black but users under Administrators are red. I've seen this done in forums and I was wondering if there is a way to do this on a coppermine gallery that is not bridged to a forum?

Joachim Müller

Related to the onlinestats plugin, moving accordingly.

Αndré

Open plugin/onlinestats/codebase.php

Find:
        $result = cpg_db_query("SELECT user_id, user_name FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id <> 0");

        $logged_in_array = array();

        while ($row = mysql_fetch_row($result)) {
                $logged_in_array[] = vsprintf('<a href="profile.php?uid=%d">%s</a>', $row);
        }


Replace with:
        $result = cpg_db_query("SELECT o.user_id, o.user_name, u.user_group FROM {$CONFIG['TABLE_ONLINE']} o INNER JOIN {$CONFIG['TABLE_USERS']} u ON o.user_id = u.user_id WHERE o.user_id <> 0");

        $logged_in_array = array();

        while ($row = mysql_fetch_row($result))
        {
        switch($row[2])
        {
        case 1: $color = "#FF0000"; break;
        case 2: $color = "#00FF00"; break;
        case 3: $color = "#0000FF"; break;
        }
                $logged_in_array[] = vsprintf('<a href="profile.php?uid=%d"><font color="'.$color.'">%s</font></a>', $row);
        }


In the switch-statement you can set the different colors for the group id's.

stardust