Hi!
How can I add name of the group that user belongs to, below username in user galleries?
Thanks!
Edit index.php (function list_users)
Replace
$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
$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
$user_pic_count = $user['pic_count'];
$user_thumb_pid = $user['thumb_pid'];
$user_album_count = $user['alb_count'];
with
$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
'{ALBUMS}' => $albums_txt,
with
'{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.
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!
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.
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)
for($i = 0; $i < count($rowset); $i++) {
$rowset[$i]['user_name'] = empty($name[$rowset[$i]['user_id']]) ? '???' : $name[$rowset[$i]['user_id']];
}
with
$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 :)
WOW, it works great! Thanks!!!
:D :D :D
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".
I don't know how phpBB's group system works. So i can't help much on this. :(
OK! Thanks anyway! You have been much helpfull! :)