summaryrefslogtreecommitdiff
path: root/utils/rhrd-group
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-09 17:40:46 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-10-09 17:40:46 (GMT)
commitc253bf234deafa69ed2e462c8ec2d8f41b484e9e (patch)
tree27e4abb33d56ebf23ac0877baebfc0fde1cfa850 /utils/rhrd-group
parentc6c891b3921dce1cb3575e67a6f45f0fb24f722d (diff)
added some checks before drastic changes of a group
Diffstat (limited to 'utils/rhrd-group')
-rwxr-xr-xutils/rhrd-group30
1 files changed, 27 insertions, 3 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) {