summaryrefslogtreecommitdiff
path: root/lib/RHRD/rddb.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-09 20:46:22 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-09 20:46:22 (GMT)
commit20ff694433ef9f658cc58da64484f008f95545da (patch)
tree38a24fa67f5a21f8de75dce9982dbc4e0392d20a /lib/RHRD/rddb.pm
parent23710d5bdb141ad4385be12765678659b68607b0 (diff)
added multi-show support (not working yet)
Diffstat (limited to 'lib/RHRD/rddb.pm')
-rwxr-xr-xlib/RHRD/rddb.pm86
1 files changed, 85 insertions, 1 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 7c5bae3..62f43bd 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -54,6 +54,7 @@ sub init
or return (undef , 'ERROR', "RHRD Config File Error: " . join("\n", @Config::IniFiles::errors));
$ctx{'config'}{'specialgroups'}{'system'} = $cfg->val('specialgroups', 'system', 'SYSTEM');
+ $ctx{'config'}{'specialgroups'}{'multishows'} = $cfg->val('specialgroups', 'multishows', 'MULTISHOWS');
$ctx{'config'}{'specialgroups'}{'shows'} = $cfg->val('specialgroups', 'shows', 'SHOWS');
$ctx{'config'}{'specialgroups'}{'allshows'} = $cfg->val('specialgroups', 'allshows', 'ALL_SHOWS');
$ctx{'config'}{'specialgroups'}{'allpools'} = $cfg->val('specialgroups', 'allpools', 'ALL_POOLS');
@@ -1839,6 +1840,9 @@ sub create_show_macro_cart
my $macro = 'LL 1 ' . $logname . ' 0!';
my ($number, $status, $errorstring) = get_next_free_showid($ctx);
+ unless (defined $number) {
+ return (undef, $status, $errorstring);
+ }
my $sql = qq{insert into CART (NUMBER, TYPE, GROUP_NAME, TITLE, MACROS, VALIDITY, METADATA_DATETIME) values (?, 2, ?, ?, ?, 3, NOW())};
@@ -1961,6 +1965,86 @@ sub remove_show
return @actions;
}
+sub list_multi_shows
+{
+ my ($ctx) = @_;
+
+ my $sql = qq{select NUMBER,TITLE,USER_DEFINED from CART where GROUP_NAME = ? order by NUMBER};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($ctx->{'config'}{'specialgroups'}{'multishows'})
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my @mshows;
+ while(my ($id, $title, $shows) = $sth->fetchrow_array()) {
+ my @showlist = split(';', $shows); # TODO split this further...
+
+ my $entry = {};
+ $entry->{'ID'} = $id;
+ $entry->{'TITLE'} = $title;
+ $entry->{'SHOWS'} = @showlist;
+
+ push @mshows, $entry;
+ }
+ $sth->finish();
+
+ return @mshows;
+}
+
+sub get_next_free_multi_showid
+{
+ my ($ctx) = @_;
+
+ my ($low, $high, $type, undef) = RHRD::rddb::get_group_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'multishows'});
+ unless(defined $low) {
+ return (undef, $high, $type);
+ }
+
+ my $sql = qq{select NUMBER from CART where GROUP_NAME = ? order by NUMBER};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($ctx->{'config'}{'specialgroups'}{'multishows'})
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my $showid = $low;
+ while(my ($cart) = $sth->fetchrow_array()) {
+ last if($showid < $cart);
+ $showid += 1;
+ }
+ $sth->finish();
+
+ return ($showid, 'OK', 'success');
+}
+
+sub create_multi_show
+{
+ my $ctx = shift;
+ my $title = shift;
+ my $shows = join(@_, ";");
+
+ my ($number, $status, $errorstring) = get_next_free_multi_showid($ctx);
+ unless (defined $number) {
+ return (undef, $status, $errorstring);
+ }
+
+ my $sql = qq{insert into CART (NUMBER, TYPE, GROUP_NAME, TITLE, USER_DEFINED, VALIDITY, METADATA_DATETIME) values (?, 2, ?, ?, ?, 3, NOW())};
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($number, $ctx->{'config'}{'specialgroups'}{'multishows'}, $title, $shows)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ $sth->finish();
+
+ return ($number, 'OK', 'success');
+}
+
+
########################### MUSICPOOL handling ###########################
sub get_musicpools_cart_range
@@ -2209,8 +2293,8 @@ sub create_musicpool_clock
push @events, { NAME => $shortname, START_TIME => $t, LENGTH => 142500 };
$t += 142500;
if($i > 0 && ($i % 8) == 0) {
- $t += 60000;
# TODO: push jingle event
+ $t += 60000;
}
}