summaryrefslogtreecommitdiff
path: root/lib/RHRD/rddb.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-26 22:14:02 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-26 22:14:02 (GMT)
commit6ac2fd07b57a25aa9ae2f8128f6e3e65cb8001ed (patch)
treeaab469fd94fd231456f1b25995e49d6309e65b17 /lib/RHRD/rddb.pm
parent343ac9e3baec46fef765d7193a92555fea7e288c (diff)
no more specialusers config (use DB instead)
Diffstat (limited to 'lib/RHRD/rddb.pm')
-rwxr-xr-xlib/RHRD/rddb.pm49
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) = @_;