summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-group30
-rwxr-xr-xutils/rhrd-show10
2 files changed, 32 insertions, 8 deletions
diff --git a/utils/rhrd-group b/utils/rhrd-group
index 4f59c07..1de7e4b 100755
--- a/utils/rhrd-group
+++ b/utils/rhrd-group
@@ -81,6 +81,16 @@ sub remove
{
my ($ctx, $groupname) = @_;
+ my @carts = RHRD::rddb::get_show_group_carts_used($ctx, $groupname);
+ if(!defined $carts[0] && defined $carts[1]) {
+ print STDERR $carts[1] . ": " . $carts[2] . "\n";
+ return 1;
+ }
+ unless(scalar @carts == 0) {
+ print "won't remove group with active shows\n use 'rhrd-show list " . $groupname . "' to find out which show(s) use this group\n";
+ return 1;
+ }
+
my @results = RHRD::rddb::remove_group($ctx, $groupname);
if(!defined $results[0] && defined $results[2]) {
print STDERR "$results[2]\n";
@@ -165,9 +175,23 @@ sub set_carts
$low_cart = RHRD::rddb::RD_INVALID_CART unless($low_cart >= RHRD::rddb::RD_MIN_CART && $low_cart <= RHRD::rddb::RD_MAX_CART);
$high_cart = RHRD::rddb::RD_INVALID_CART unless($high_cart >= RHRD::rddb::RD_MIN_CART && $high_cart <= RHRD::rddb::RD_MAX_CART);
- $cart_type = 1 unless($cart_type == 1 || $cart_type == 2);
- $enforce_cart_range = 'Y' if ($enforce_cart_range eq 'Y' || $enforce_cart_range eq 'y' || $enforce_cart_range eq '1');
- $enforce_cart_range = 'N' unless ($enforce_cart_range eq 'Y');
+ $cart_type = 1 unless(defined($cart_type) && ($cart_type == 1 || $cart_type == 2));
+ $enforce_cart_range = 'Y' if(defined($enforce_cart_range) && ($enforce_cart_range eq 'Y' || $enforce_cart_range eq 'y' || $enforce_cart_range eq '1'));
+ $enforce_cart_range = 'N' unless(defined($enforce_cart_range) &&$enforce_cart_range eq 'Y');
+
+ my @carts = RHRD::rddb::get_show_group_carts_used($ctx, $groupname);
+ if(!defined $carts[0] && defined $carts[1]) {
+ print STDERR $carts[1] . ": " . $carts[2] . "\n";
+ return 1;
+ }
+ unless(scalar @carts == 0) {
+ for my $cart (@carts) {
+ if($cart < $low_cart || $cart > $high_cart) {
+ print "this group has active shows with carts outside of the new range\n use 'rhrd-show list " . $groupname . "' to find out which show(s) use this group\n";
+ return 1;
+ }
+ }
+ }
my ($cnt, undef, $errorstring) = RHRD::rddb::set_group_cart_range($ctx, $groupname, $low_cart, $high_cart, $cart_type, $enforce_cart_range);
unless(defined $cnt) {
diff --git a/utils/rhrd-show b/utils/rhrd-show
index f2a6aed..cc3b859 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -33,16 +33,16 @@ use RHRD::utils;
sub print_usage
{
- print STDERR "Usage: rd-show list\n" .
+ print STDERR "Usage: rd-show list [ <group> ]\n" .
" rd-show (show|remove) <show-id>\n" .
" rd-show add <groupname> <name> <title> <num-carts> <rhythm> <dow> <starttime> <len>\n";
}
sub list
{
- my ($ctx) = @_;
+ my ($ctx, $group) = @_;
- my @shows = RHRD::rddb::list_shows($ctx);
+ my @shows = RHRD::rddb::list_shows($ctx, $group);
if(!defined $shows[0] && defined $shows[1]) {
print STDERR "$shows[1]: $shows[2]";
return 1;
@@ -219,11 +219,11 @@ my $ret = 0;
my ($ctx, $status, $errorstring) = RHRD::rddb::init();
if(defined $ctx) {
if($cmd eq "list") {
- if($num_args != 1) {
+ if($num_args > 2) {
print_usage();
$ret = 1;
} else {
- $ret = list($ctx)
+ $ret = list($ctx, $ARGV[1])
}
}
elsif($cmd eq "show") {