GROUPLIST_PGM; manually spot-tested, no test script. PW.

This commit is contained in:
Sitaram Chamarty 2012-04-02 21:25:06 +05:30
parent 9b3efb9084
commit 81b503d2bd

View file

@ -232,6 +232,7 @@ sub load_1 {
my @repos = memberships( 'repo', $repo ); my @repos = memberships( 'repo', $repo );
my @users = memberships( 'user', $user, $repo ); my @users = memberships( 'user', $user, $repo );
dbg(\@users);
trace( 3, "memberships: " . scalar(@repos) . " repos and " . scalar(@users) . " users found" ); trace( 3, "memberships: " . scalar(@repos) . " repos and " . scalar(@users) . " users found" );
for my $r (@repos) { for my $r (@repos) {
@ -296,6 +297,8 @@ sub memberships {
push @ret, user_roles( $base, $repo, @ret ); push @ret, user_roles( $base, $repo, @ret );
} }
push @ret, @{ ext_grouplist($base) } if $type eq 'user' and $rc{GROUPLIST_PGM};
@ret = @{ sort_u( \@ret ) }; @ret = @{ sort_u( \@ret ) };
trace( 3, sort @ret ); trace( 3, sort @ret );
return @ret; return @ret;
@ -385,6 +388,20 @@ sub creator {
return $creator; return $creator;
} }
{
my %cache = ();
sub ext_grouplist {
my $user = shift;
my $pgm = $rc{GROUPLIST_PGM};
return [] if not $pgm;
return $cache{$user} if $cache{$user};
my @extgroups = map { s/^@?/@/; $_; } split ' ', `$rc{GROUPLIST_PGM} $user`;
return ($cache{$user} = \@extgroups);
}
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# api functions # api functions
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------