diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-31 16:05:45 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-31 16:05:45 (GMT) |
commit | 131be9a185bd6d92cd0bafc9892a0a51189a3946 (patch) | |
tree | fe7ffc0d7a2158e60ff34143dcb8fe93701e3513 | |
parent | af294a1f65fd66f0a0ecf59e199785703d1b947e (diff) |
removing musicpool is now implemented
-rwxr-xr-x | lib/RHRD/rddb.pm | 9 | ||||
-rwxr-xr-x | utils/rhrd-pool | 25 |
2 files changed, 28 insertions, 6 deletions
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) <short-name>\n" . + " rhrd-pool show <short-name>\n" . + " rhrd-pool remove <short-name> [--force]\n" . " rhrd-pool add <groupname> <title>\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") { |