summaryrefslogtreecommitdiff
path: root/utils/rhrd-user
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 /utils/rhrd-user
parent129f006062892600000d46d89d31524eee03fdfe (diff)
rhrd-user can update grid rights now
Diffstat (limited to 'utils/rhrd-user')
-rwxr-xr-xutils/rhrd-user50
1 files changed, 48 insertions, 2 deletions
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;