From 58e7ace78758e174628a7f138ffd519eaee383ea Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 27 Jul 2016 18:15:35 +0200 Subject: rhrd-user can update grid rights now diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 8f519c6..ccbff24 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -1794,10 +1794,10 @@ sub set_musicpools_user my $rows = $ctx->{'dbh'}->do($sql, undef, $value, $username) or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); - unless($rows == 1) { + if($rows < 1) { return (undef, 'ERROR', "user '" . $username . "' not known by rivendell") } - return (1, 'OK', 'success'); + return ($rows, 'OK', 'success'); } sub get_musicpools_clocks 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) \n" . - " rhrd-user add [ ]\n"; + " rhrd-user (check|remove|groups|is-grids) \n" . + " rhrd-user add [ ]\n" . + " rhrd-user set-grids (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; -- cgit v0.10.2