Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Group name in user albums  (Read 5489 times)

0 Members and 1 Guest are viewing this topic.

NevilleX

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
    • SeGoodies
Group name in user albums
« on: October 08, 2005, 01:49:56 pm »

Hi!

How can I add name of the group that user belongs to, below username in user galleries?


Thanks!
« Last Edit: October 09, 2005, 11:05:42 am by Abbas Ali »
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Group name in user albums
« Reply #1 on: October 08, 2005, 02:37:25 pm »

Edit index.php (function list_users)

Replace

Code: [Select]
        $sql = "SELECT user_id, " .
               "user_name, " .
               "COUNT(DISTINCT a.aid) as alb_count, " .
               "COUNT(DISTINCT pid) as pic_count, " .
               "MAX(pid) as thumb_pid " .
               "FROM {$CONFIG['TABLE_USERS']} AS u " .
               "INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON category = " . FIRST_USER_CAT . " + user_id " .
               "LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON (p.aid = a.aid AND approved = 'YES') ";
        if ($FORBIDDEN_SET != "" && !$cpg_show_private_album) $sql .= "WHERE $FORBIDDEN_SET ";
        $sql .= "GROUP BY user_id " .
                "ORDER BY user_name";

with

Code: [Select]
        $sql = "SELECT user_id, " .
               "user_name, " .
               "COUNT(DISTINCT a.aid) as alb_count, " .
               "COUNT(DISTINCT pid) as pic_count, " .
               "MAX(pid) as thumb_pid, " .
               "group_name " .
               "FROM {$CONFIG['TABLE_USERS']} AS u, {$CONFIG['TABLE_USERGROUPS']} AS g " .
               "INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON category = " . FIRST_USER_CAT . " + user_id " .
               "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON (p.aid = a.aid AND approved = 'YES') WHERE u.user_group = g.group_id ";
        if ($FORBIDDEN_SET != "" && !$cpg_show_private_album) $sql .= "AND $FORBIDDEN_SET ";
        $sql .= "GROUP BY user_id " .
                "ORDER BY user_name";

then Replace

Code: [Select]
        $user_pic_count = $user['pic_count'];
        $user_thumb_pid = $user['thumb_pid'];
        $user_album_count = $user['alb_count'];

with

Code: [Select]
        $user_pic_count = $user['pic_count'];
        $user_thumb_pid = $user['thumb_pid'];
        $user_album_count = $user['alb_count'];
        $user_group_name = $user['group_name'];

and finally Replace

Code: [Select]
            '{ALBUMS}' => $albums_txt,

with

Code: [Select]
            '{ALBUMS}' => $user_group_name."<br>".$albums_txt,

That's it.

NOTE: This is only for unbridged installation. If you have bridged coppermine with some bbs then you need to modify respective bridge file.
Logged
Chief Geek at Ranium Systems

NevilleX

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
    • SeGoodies
Re: Group name in user albums
« Reply #2 on: October 08, 2005, 07:15:56 pm »

Thanks for your help Abbas, I really appreciate this, however I'm running cpg bridged with phpbb.
Could you please tell how can I modify my phpbb.inc.php file to get this working.
Thanks again!

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Group name in user albums
« Reply #3 on: October 08, 2005, 09:02:57 pm »

I don't have a phpbb bridged installation on my machine as of now. So will tell u how to do it tomorrow after going through it. In the meantime anyone else knows how to do it then he can post the details.
Logged
Chief Geek at Ranium Systems

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Group name in user albums
« Reply #4 on: October 09, 2005, 10:42:31 am »

Here is solution for phpbb bridged installation. But i have not tested it since i don't have a phpbb bridged installation on my machine. But it should work.

Keep the changes mentioned above.

Edit bridge/phpbb.inc.php

Replace ( in function udb_list_users_retrieve_data)

Code: [Select]
    for($i = 0; $i < count($rowset); $i++) {
        $rowset[$i]['user_name'] = empty($name[$rowset[$i]['user_id']]) ? '???' : $name[$rowset[$i]['user_id']];
    }

with

Code: [Select]
    $query = "SELECT group_name, user_id FROM ".$UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_UGROUP_TABLE." AS ug, ".$UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_GROUP_TABLE ." AS g WHERE ug.user_id IN $user_id_set AND ug.group_id = g.group_id";
   
    $result1 = db_query($query, $UDB_DB_LINK_ID);
   
    while ($g_row = mysql_fetch_array($result1)) {
      $group_arr[$g_row['user_id']] = $g_row['group_name'];
    }
   
    for($i = 0; $i < count($rowset); $i++) {
        $rowset[$i]['user_name'] = empty($name[$rowset[$i]['user_id']]) ? '???' : $name[$rowset[$i]['user_id']];
        $rowset[$i]['group_name'] = $group_arr[$rowset[$i]['user_id']];
    }

Hope it works :)
Logged
Chief Geek at Ranium Systems

NevilleX

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
    • SeGoodies
Re: Group name in user albums
« Reply #5 on: October 09, 2005, 10:57:19 am »

WOW, it works great! Thanks!!!
 :D :D :D

NevilleX

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
    • SeGoodies
Re: Group name in user albums
« Reply #6 on: October 09, 2005, 11:41:37 am »

Just one more small thing: If an user have more than one group membership is it possible to search an array for specific group name, and then extract desired group name from an array? For example; I have an user that is "moderator" and "designer", and I would like to show only "designer" group name. I think that this script now shows last assigned group.
I have modified code a little to show user rank images instead of group name; you can see this at www.segoodies.com under "Designer galleries".

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Group name in user albums
« Reply #7 on: October 10, 2005, 07:58:57 am »

I don't know how phpBB's group system works. So i can't help much on this. :(
Logged
Chief Geek at Ranium Systems

NevilleX

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
    • SeGoodies
Re: Group name in user albums
« Reply #8 on: October 10, 2005, 08:07:32 am »

OK! Thanks anyway! You have been much helpfull!  :)
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.