Group list in viewtopic

Shows a list of all a users groups under their post details in viewtopic

Carrying on from here, this snippet was requested by nasadows in the same topic. Instead of just showing a posters default group, it lists every group that they are a member of. Only those with permissions to see a group will see it's name in the list, as this snippet make use of the same auth check that is used in the memberlist view profile section.

*CAUTION* This snippet runs quite an expensive query in viewtopic. I haven't looked into trimming it down, so you may want to try and find a way reduce the load caused by this before installing.

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php  
#
#-----[ FIND ]------------------------------------------
#
        //
        $postrow = array( 
#
#-----[ BEFORE, ADD ]------------------------------------------
#
        // Stolen from memberlist.php - get a dropdown list of all users groups (checking for auths as well)
        $gsql = 'SELECT g.group_id, g.group_name, g.group_type
            FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
            WHERE ug.user_id = $poster_id
                AND g.group_id = ug.group_id" . ((!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
                AND ug.user_pending = 0
            ORDER BY g.group_type, g.group_name';
        $res = $db->sql_query($gsql);

        $group_list = array();
        while ($grow = $db->sql_fetchrow($res))
        {
            $group_list[]    = ($grow['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $grow['group_name']] : $grow['group_name'];
        }
        $db->sql_freeresult($res);    
        $group_list = implode(', ', $group_list); 
#
#-----[ FIND ]------------------------------------------
#

Not a duplicate here, there's an array for guests and an array for registered users

            'S_IGNORE_POST'            => ($row['hide_post']) ? true : false, 
#
#-----[ BEFORE, ADD ]------------------------------------------
#
            'S_GROUP_LIST'        => $group_list, 
#
#-----[ OPEN ]------------------------------------------
#
styles/prosilver/template/viewtopic_body.html
#
#-----[ FIND ]------------------------------------------
#
	 <!-- IF postrow.POSTER_FROM --><dd><strong>{L_LOCATION}:</strong> {postrow.POSTER_FROM}</dd><!-- ENDIF -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
	<!-- IF postrow.S_GROUP_LIST --><dd><strong>{L_GROUPS}:</strong> {postrow.S_GROUP_LIST}</dd><!-- ENDIF -->

Please see here if you would like to split each group on to a new line, link the group name to the groups page and add the groups color to the text