Advanced search  

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

Pages: [1]   Go Down

Author Topic: [Solved]: Colorcode usernames by group? (unbridged)  (Read 4296 times)

0 Members and 1 Guest are viewing this topic.

stardust

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 44
[Solved]: Colorcode usernames by group? (unbridged)
« 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?
« Last Edit: July 10, 2008, 05:42:32 pm by Nibbler »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Colorcode usernames by group? (unbridged)
« Reply #1 on: July 10, 2008, 06:30:28 am »

Related to the onlinestats plugin, moving accordingly.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Colorcode usernames by group? (unbridged)
« Reply #2 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.
Logged

stardust

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 44
Re: Colorcode usernames by group? (unbridged)
« Reply #3 on: July 10, 2008, 05:32:43 pm »

That works perfect, thanks!
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 19 queries.