diff options
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/rhrd-group | 2 | ||||
-rwxr-xr-x | utils/rhrd-user | 50 |
2 files changed, 49 insertions, 3 deletions
diff --git a/utils/rhrd-group b/utils/rhrd-group index 088bc10..7aa5f6b 100755 --- a/utils/rhrd-group +++ b/utils/rhrd-group @@ -150,7 +150,7 @@ sub is_member print STDERR "$errorstring\n"; return 1; } - print $ARGV[2] . " is" . (($cnt) ? "" : " not") . " a member\n"; + print $ARGV[2] . " is" . (($cnt) ? "" : " *not*") . " a member\n"; return (($cnt) ? 0 : 1); } diff --git a/utils/rhrd-user b/utils/rhrd-user index 9d606eb..14e5462 100755 --- a/utils/rhrd-user +++ b/utils/rhrd-user @@ -27,8 +27,9 @@ use String::MkPasswd qw(mkpasswd); sub print_usage { print STDERR "Usage: rhrd-user list\n" . - " rhrd-user (check|remove|groups) <username>\n" . - " rhrd-user add <username> [ <fullname> ]\n"; + " rhrd-user (check|remove|groups|is-grids) <username>\n" . + " rhrd-user add <username> [ <fullname> ]\n" . + " rhrd-user set-grids <username> (1|0)\n"; } sub list @@ -99,6 +100,37 @@ sub groups return 0; } +sub is_grids +{ + my ($ctx, $username) = @_; + + my ($authorized, $status, $errorstring) = RHRD::rddb::is_musicpools_user($ctx, $username); + if(!defined $authorized) { + print STDERR "$status: $errorstring\n"; + return 1; + } + print $username . " is" . (($authorized) ? "" : " *not*") . " allowed to edit music grids\n"; + return (($authorized) ? 0 : 1); +} + +sub set_grids +{ + my ($ctx, $username, $value) = @_; + + unless(defined($value) && ($value == '0' || $value == '1')) { + print_usage(); + return 1; + } + + my ($cnt, $status, $errorstring) = RHRD::rddb::set_musicpools_user($ctx, $username, $value); + if(!defined $cnt) { + print STDERR "$status: $errorstring\n"; + return 1; + } + print int($cnt) . " rows affected\n"; + return 0; +} + my $num_args = $#ARGV + 1; if($num_args < 1) { @@ -147,6 +179,20 @@ if(defined $ctx) { } else { $ret = groups($ctx, $username); } + } elsif($cmd eq "is-grids") { + if($num_args != 2) { + print_usage(); + $ret = 1; + } else { + $ret = is_grids($ctx, $username); + } + } elsif($cmd eq "set-grids") { + if($num_args != 3) { + print_usage(); + $ret = 1; + } else { + $ret = set_grids($ctx, $username, $ARGV[2]); + } } else { print_usage(); $ret = 1; |