diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/rddb.pm | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/rddb.pm b/lib/rddb.pm index 823629d..c834dda 100755 --- a/lib/rddb.pm +++ b/lib/rddb.pm @@ -77,6 +77,26 @@ sub check_token return (0, 'ERROR', "wrong password"); } +sub get_showtitle +{ + my ($dbh, $showid) = @_; + + my $sql = qq{select TITLE from CART where NUMBER = ?;}; + my $sth = $dbh->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); + + $sth->execute($showid) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my ($title) = $sth->fetchrow_array; + $sth->finish(); + + unless(defined $title) { + return (undef, 'ERROR', "Show wid ID=" . $showid . " not found!") + } + return ($title, 'OK', 'success'); +} + sub get_dropboxes { my ($dbh, $username) = @_; @@ -102,7 +122,13 @@ sub get_dropboxes $entry->{'PARAM'} = $params; if($type eq "show") { $entry->{'SHOWID'} = $showid; - # $params has the format: 1111-01-1600-060 + + my ($title, $status, $errorstring) = get_showtitle($dbh, $showid); + unless (defined $title) { + return (undef, $status, $errorstring); + } + $entry->{'SHOWTITLE'} = $title; + if($params =~ /^([01]{4})-([0-9]{2})-([0-9]{2})([0-9]{2})-([0-9]{3})$/) { $entry->{'RHYTHM'} = $1; $entry->{'DOW'} = int $2; |