forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: stardust on July 10, 2008, 04:34:10 am

Title: [Solved]: Colorcode usernames by group? (unbridged)
Post by: stardust on July 10, 2008, 04:34:10 am
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?
Title: Re: Colorcode usernames by group? (unbridged)
Post by: Joachim Müller on July 10, 2008, 06:30:28 am
Related to the onlinestats plugin, moving accordingly.
Title: Re: Colorcode usernames by group? (unbridged)
Post by: Αndré on July 10, 2008, 09:52:27 am
Open plugin/onlinestats/codebase.php

Find:
Code: [Select]
        $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:
Code: [Select]
        $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.
Title: Re: Colorcode usernames by group? (unbridged)
Post by: stardust on July 10, 2008, 05:32:43 pm
That works perfect, thanks!