summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-30 01:18:47 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-30 01:18:47 (GMT)
commitfd4ff74330649a6364bfed2a1753311817448246 (patch)
treee85af652b86ceea6a1de36a43c16876b32a115cb
parent4ca5666bd7a183736b531d52027f5a2555e40732 (diff)
removing musicpool - partly implemented
-rwxr-xr-xlib/RHRD/rddb.pm74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 65866fc..e1335fe 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -1865,6 +1865,26 @@ sub get_musicpool_num_from_cart
return ($num, 'OK', 'success');
}
+sub get_musicpool_group
+{
+ my ($ctx, $shortname) = @_;
+
+ my $sql = qq{select GROUP_NAME from DROPBOXES where PATH = ? and DROPBOXES.STATION_NAME = ?;};
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($shortname, $ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'})
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my ($groupname) = $sth->fetchrow_array();
+ $sth->finish();
+
+ unless(defined($groupname)) {
+ return (undef, 'ERROR', "Pool not found");
+ }
+ return ($groupname, 'OK', 'success');
+}
+
sub list_musicpools
{
my ($ctx) = @_;
@@ -2004,6 +2024,60 @@ sub create_musicpool_event
return (1, 'OK', 'success');
}
+sub remove_musicpool
+{
+ my ($ctx, $shortname) = @_;
+
+ my ($groupname, $status, $errorstring) = get_musicpool_group($ctx, $shortname);
+ unless (defined $groupname) {
+ return (undef, $status, $errorstring);
+ }
+
+ my @actions = ({
+ # Delete Event Permissions
+ sql => qq{delete from EVENT_PERMS where EVENT_NAME = ?;},
+ param => $shortname,
+ name => 'event permissions',
+ cnt => 0
+ }, {
+ # Delete Event
+ sql => qq{delete from EVENTS where NAME = ?;},
+ param => $shortname,
+ name => 'events',
+ cnt => 0
+ });
+
+ for my $href (@actions) {
+ my $sth = $ctx->{'dbh'}->prepare($href->{sql})
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+ delete($href->{sql});
+
+ $href->{cnt} = $sth->execute($href->{param})
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ $sth->finish();
+ }
+
+ (my $cnt_pre, $status, $errorstring) = drop_logevent_table($ctx, $shortname, 1);
+ unless (defined $cnt_pre) {
+ return (undef, $status, $errorstring);
+ }
+
+ (my $cnt_post, $status, $errorstring) = drop_logevent_table($ctx, $shortname, 0);
+ unless (defined $cnt_post) {
+ return (undef, $status, $errorstring);
+ }
+ push @actions, { name => 'log-event tables', cnt => ($cnt_pre + $cnt_post) };
+
+ my @group_results = remove_group($ctx, $groupname);
+ if(!defined $group_results[0] && defined $group_results[2]) {
+ return (undef, $group_results[1], $group_results[2]);
+ }
+ push @actions, @group_results;
+
+ return @actions;
+}
+
sub is_musicpools_user
{
my ($ctx, $username) = @_;