diff options
-rwxr-xr-x | lib/RHRD/rddb.pm | 4 | ||||
-rwxr-xr-x | utils/rhrd-group | 58 |
2 files changed, 60 insertions, 2 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 68d8aaa..c209f81 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -548,7 +548,7 @@ sub get_user_groups { my ($ctx, $username) = @_; - my $sql = qq{select GROUP_NAME from USER_PERMS where USER_NAME = ? oder by GROUP_NAME;}; + my $sql = qq{select GROUP_NAME from USER_PERMS where USER_NAME = ? order by GROUP_NAME;}; my $sth = $ctx->{'dbh'}->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); @@ -818,7 +818,7 @@ sub add_group_member ($cnt, my $result, my $errostring) = is_group_member($ctx, $groupname, $username); if($cnt > 0) { - return (undef, 'ERROR', "already a member"); + return (0, 'OK', "already a member"); } $sql = qq{insert into USER_PERMS (GROUP_NAME, USER_NAME) values (?, ?);}; diff --git a/utils/rhrd-group b/utils/rhrd-group index 7aa5f6b..a66597e 100755 --- a/utils/rhrd-group +++ b/utils/rhrd-group @@ -125,6 +125,35 @@ sub add_member return 1; } print int($cnt) . " rows affected\n"; + + my $group_type = ""; + $group_type = "shows" if($groupname eq $ctx->{'config'}{'specialgroups'}{'allshows'}); + $group_type = "jingles" if($groupname eq $ctx->{'config'}{'specialgroups'}{'alljingles'}); + $group_type = "pools" if($groupname eq $ctx->{'config'}{'specialgroups'}{'allpools'}); + + unless($group_type eq "") { + local $| = 1; + + my @groups = RHRD::rddb::list_groups($ctx, $group_type); + if(!defined $groups[0] && defined $groups[1]) { + print STDERR "$groups[1]: $groups[2]"; + return 1; + } + print "also adding to " . scalar(@groups) . " other groups "; + for my $group (@groups) { + my ($cnt, undef, $errorstring) = RHRD::rddb::add_group_member($ctx, $group, $username); + unless(defined $cnt) { + print STDERR "$errorstring\n"; + return 1; + } + if($cnt > 0) { + print "+"; + } else { + print "."; + } + } + print " done.\n"; + } return 0; } @@ -138,6 +167,35 @@ sub remove_member return 1; } print int($cnt) . " rows affected\n"; + + my $group_type = ""; + $group_type = "shows" if($groupname eq $ctx->{'config'}{'specialgroups'}{'allshows'}); + $group_type = "jingles" if($groupname eq $ctx->{'config'}{'specialgroups'}{'alljingles'}); + $group_type = "pools" if($groupname eq $ctx->{'config'}{'specialgroups'}{'allpools'}); + + unless($group_type eq "") { + local $| = 1; + + my @groups = RHRD::rddb::list_groups($ctx, $group_type); + if(!defined $groups[0] && defined $groups[1]) { + print STDERR "$groups[1]: $groups[2]"; + return 1; + } + print "also removing from " . scalar(@groups) . " other groups "; + for my $group (@groups) { + my ($cnt, undef, $errorstring) = RHRD::rddb::remove_group_member($ctx, $group, $username); + unless(defined $cnt) { + print STDERR "$errorstring\n"; + return 1; + } + if($cnt > 0) { + print "-"; + } else { + print "."; + } + } + print " done.\n"; + } return 0; } |