summaryrefslogtreecommitdiff
path: root/lib/RHRD
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-09-24 15:50:13 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-09-24 15:50:13 (GMT)
commit5ad1a16fbdfaf12199db58be34eb0a8f8942a841 (patch)
tree18a76d706649447e4297cdd8196dd43a19f21676 /lib/RHRD
parenta81237953717a6d0cf15e8cb0c2692e199c920d3 (diff)
documentated cart ranges
add some constants for cart ranges implemented functions for cart ranges
Diffstat (limited to 'lib/RHRD')
-rwxr-xr-xlib/RHRD/rddb.pm48
1 files changed, 46 insertions, 2 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 36b9dc0..6e83a5e 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -32,6 +32,15 @@ use constant {
DB_VERSION => 245,
RD_CONFIG_FILE => '/etc/rd.conf',
DROPBOX_PSEUDO_STATION_NAME => 'import-dropbox',
+ RD_MIN_CART => 1,
+ RD_MAX_CART => 999999,
+ RD_MIN_CUT => 1,
+ RD_MAX_CUT => 999,
+
+ RHRD_SYSTEM_MACROS_GROUP => 'SYSTEM',
+ RHRD_SHOW_MACROS_GROUP => 'SHOWS',
+ RHRD_ALLSHOWS_GROUP => 'ALL_SHOWS',
+ RHRD_ALLMUSICPOOLS_GROUP => 'ALL_POOLS',
};
########################### connection handling ###########################
@@ -77,6 +86,27 @@ sub closedb
$dbh->disconnect();
}
+########################### utils ###########################
+
+sub get_cart_range
+{
+ my ($dbh, $groupname) = @_;
+
+ my $sql = qq{select DEFAULT_LOW_CART, DEFAULT_HIGH_CART, DEFAULT_TITLE from GROUPS where NAME = ?;};
+ my $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute($groupname)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my ($low_cart, $high_cart, $chunk_size) = $sth->fetchrow_array;
+ $sth->finish();
+
+ unless(defined $low_cart) { return (undef, 'ERROR', "group '" . $groupname . "' does not exist"); }
+
+ return ($low_cart, $high_cart, $chunk_size);
+}
+
########################### TOKEN handling ###########################
sub get_token
@@ -415,8 +445,6 @@ sub set_group_carts
$enforce_cart_range = 'N';
}
- # TODO: check if cart range is already in use by other group
-
my $sql = qq{update GROUPS set DEFAULT_LOW_CART = ?, DEFAULT_HIGH_CART = ?, DEFAULT_CART_TYPE = ? , ENFORCE_CART_RANGE = ? where NAME = ?;};
my $sth = $dbh->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
@@ -600,3 +628,19 @@ sub get_show_carts
}
return 1;
+
+sub get_shows_cart_range
+{
+ my ($dbh) = @_;
+ return get_cart_range($dbh, RHRD_ALLSHOWS_GROUP)
+}
+
+########################### MUSICPOOL handling ###########################
+
+sub get_musicpool_cart_range
+{
+ my ($dbh) = @_;
+ return get_cart_range($dbh, RHRD_ALLMUSICPOOLS_GROUP)
+}
+
+################################# END ####################################