#62 Groups listed multiple times

open
nobody
None
5
2007-04-11
2007-04-11
Joshua Megerman
No

There's a small bug in MonarchStorProc.pm in get_auth_groups - it pulls up the list of groups for each auth group you're in, but doesn't eliminate dups. So (for example) since my user is in 3 groups with access to all of the groups, it showed the list of groups in the tree 3 times. The solution is to change the 'select' statement to 'select distinct', which has the SQL server handle the deduping for you. Here's the patch:

--- MonarchStorProc.pm.orig.2.0.2 2007-04-05 13:56:58.000000000 -0400
+++ MonarchStorProc.pm 2007-04-11 12:36:48.000000000 -0400
@@ -3425,7 +3425,7 @@

sub get_auth_groups(@) {
my $user_id = $_[1];
- my $sqlstmt = "select name from monarch_groups left join access_list on access_list.object = monarch_groups.group_id ".
+ my $sqlstmt = "select distinct name from monarch_groups left join access_list on access_list.object = monarch_groups.group_id ".
"where access_list.type = 'group_macro' and access_list.usergroup_id in (select usergroup_id from user_group where user_id = '$user_id')";
my $sth = $dbh->prepare($sqlstmt);
$sth->execute;

Discussion