From 131be9a185bd6d92cd0bafc9892a0a51189a3946 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 31 Jul 2016 18:05:45 +0200 Subject: removing musicpool is now implemented diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 5141ff5..3d19ff5 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -2269,9 +2269,14 @@ sub remove_musicpool return (undef, $status, $errorstring); } - # TODO: remove grid/clock entries! my @actions = ({ # Delete Clock Permissions + sql => qq{update SVC_CLOCKS set CLOCK_NAME = NULL where CLOCK_NAME = ?;}, + param => $shortname, + name => 'grid entries', + cnt => 0 + }, { + # Delete Clock Permissions sql => qq{delete from CLOCK_PERMS where CLOCK_NAME = ?;}, param => $shortname, name => 'clock permissions', @@ -2448,7 +2453,7 @@ sub set_musicgrid_clock or return (undef, 'ERROR', "Database Error: " . $sth->errstr); unless($cnt == 1) { - return (undef, 'ERROR', "clock does not exist") + return (undef, 'ERROR', "updateting clock failed") } return (1, 'OK', 'success'); } diff --git a/utils/rhrd-pool b/utils/rhrd-pool index 93e943c..23b1cb2 100755 --- a/utils/rhrd-pool +++ b/utils/rhrd-pool @@ -29,7 +29,8 @@ use Date::Calc; sub print_usage { print STDERR "Usage: rhrd-pool list\n" . - " rhrd-pool (show|remove) \n" . + " rhrd-pool show \n" . + " rhrd-pool remove [--force]\n" . " rhrd-pool add \n" . " rhrd-pool edit <short-name> <title>\n"; } @@ -179,7 +180,23 @@ sub edit sub remove { - my ($ctx, $shortname) = @_; + my ($ctx, $shortname, $force) = @_; + + if(defined($force) && $force ne "--force") { + print_usage(); + return 1; + } + + my @slots = RHRD::rddb::get_musicpool_clock_usage($ctx, $shortname); + if(!defined $slots[0] && defined $slots[1]) { + print STDERR "$slots[1]: $slots[2]"; + return 1; + } + if(scalar(@slots) > 0) { + print STDERR "musicpool is still in use (" . scalar(@slots) . " grid entries)\n"; + return 1 unless(defined($force)); + print STDERR " *** forced removal ***\n" + } my @results = RHRD::rddb::remove_musicpool($ctx, $shortname); if(!defined $results[0] && defined $results[2]) { @@ -220,11 +237,11 @@ if(defined $ctx) { } } elsif($cmd eq "remove") { - if($num_args != 2) { + if($num_args < 2 || $num_args > 3) { print_usage(); $ret = 1; } else { - $ret = remove($ctx, $ARGV[1]); + $ret = remove($ctx, $ARGV[1], $ARGV[2]); } } elsif($cmd eq "add") { -- cgit v0.10.2