diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/RHRD/rddb.pm | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 10148f8..8f519c6 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -60,9 +60,6 @@ sub init $ctx{'config'}{'specialgroups'}{'alljingles'} = $cfg->val('specialgroups', 'alljingles', 'ALL_JINGLE'); @{$ctx{'config'}{'specialusers'}{'no-update-token'}} = split(' ', $cfg->val('specialusers', 'no-update-token', '')); - @{$ctx{'config'}{'specialusers'}{'admins'}} = split(' ', $cfg->val('specialusers', 'admins', 'admin')); - @{$ctx{'config'}{'specialusers'}{'allshows'}} = split(' ', $cfg->val('specialusers', 'allshows', '')); - @{$ctx{'config'}{'specialusers'}{'allpools'}} = split(' ', $cfg->val('specialusers', 'allpools', '')); $ctx{'config'}{'dropboxes'}{'dropbox-pseudo-station'} = $cfg->val('dropboxes', 'dropbox-pseudo-station', 'import-dropbox'); $ctx{'config'}{'dropboxes'}{'norm-level'} = $cfg->val('dropboxes', 'norm-level', -1200); @@ -1252,7 +1249,11 @@ sub create_show_group or return (undef, 'ERROR', "Database Error: " . $sth->errstr); $sth->finish(); - for my $user (@{$ctx->{'config'}{'specialusers'}{'allshows'}}) { + my @users = get_group_members($ctx, $ctx->{'config'}{'specialgroups'}{'allshows'}); + if(!defined $users[0] && defined $users[1]) { + return (undef, $users[1], $users[2]); + } + for my $user (@users) { ($cnt, $status, $errorstring) = RHRD::rddb::add_group_member($ctx, $groupname, $user); return (undef, $status, $errorstring) unless(defined $cnt); } @@ -1759,14 +1760,46 @@ sub is_musicpools_user return 0 if $username eq ''; - for my $groupuser (@{$ctx->{'config'}{'specialusers'}{'allpools'}}) { - if ($username eq $groupuser) { - return 1; - } + my $sql = qq{select MODIFY_TEMPLATE_PRIV from USERS where LOGIN_NAME = ?;}; + my $sth = $ctx->{'dbh'}->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + $sth->execute($username) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my ($priv) = $sth->fetchrow_array; + $sth->finish(); + + unless(defined $priv) { + return (undef, 'ERROR', "user '" . $username . "' not known by rivendell") + } + + if($priv eq "Y") { + return 1; } return 0; } +sub set_musicpools_user +{ + my ($ctx, $username, $value) = @_; + + if(defined($value) && $value) { + $value = "Y"; + } else { + $value = "N"; + } + + my $sql = qq{update USERS set MODIFY_TEMPLATE_PRIV = ? where LOGIN_NAME = ?;}; + my $rows = $ctx->{'dbh'}->do($sql, undef, $value, $username) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + unless($rows == 1) { + return (undef, 'ERROR', "user '" . $username . "' not known by rivendell") + } + return (1, 'OK', 'success'); +} + sub get_musicpools_clocks { my ($ctx) = @_; |