summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-27 16:15:35 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-27 16:15:35 (GMT)
commit58e7ace78758e174628a7f138ffd519eaee383ea (patch)
treeb68b0a8dd77b66aa4f84167ef19188867679a36e
parent129f006062892600000d46d89d31524eee03fdfe (diff)
rhrd-user can update grid rights now
-rwxr-xr-xlib/RHRD/rddb.pm4
-rwxr-xr-xutils/rhrd-group2
-rwxr-xr-xutils/rhrd-user50
3 files changed, 51 insertions, 5 deletions
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) <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;