diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/rddb.pm | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/lib/rddb.pm b/lib/rddb.pm index b8188e2..823629d 100755 --- a/lib/rddb.pm +++ b/lib/rddb.pm @@ -81,7 +81,7 @@ sub get_dropboxes { my ($dbh, $username) = @_; - my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH,DROPBOXES.TO_CART,GROUPS.DESCRIPTION from USER_PERMS, DROPBOXES, GROUPS where USER_PERMS.USER_NAME= ? and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME and DROPBOXES.GROUP_NAME=GROUPS.NAME;}; + my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH,DROPBOXES.TO_CART,DROPBOXES.NORMALIZATION_LEVEL,DROPBOXES.AUTOTRIM_LEVEL,DROPBOXES.SET_USER_DEFINED,GROUPS.DESCRIPTION from USER_PERMS, DROPBOXES, GROUPS where USER_PERMS.USER_NAME= ? and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME and DROPBOXES.GROUP_NAME=GROUPS.NAME;}; my $sth = $dbh->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); @@ -90,37 +90,32 @@ sub get_dropboxes or return (undef, 'ERROR', "Database Error: " . $sth->errstr); my @allowed_dbs; - while(my ($group, $path, $to_cart, $desc) = $sth->fetchrow_array()) { - $path =~ s/\/\*$//; - my $name = $path; - if($name =~ /^([0-9]{2}-[A-Za-z]+)\/([0-9]{2})([0-9]{2})-([01]{4})-([0-9]{3})\/(.*)$/) { - $name = "$1 - $2:$3 - $6 ($4, $5)"; + while(my ($group, $type, $showid, $normlevel, $trimlevel, $params, $groupdesc) = $sth->fetchrow_array()) { + + my $entry = {}; + $entry->{'GROUP'} = $group; + $entry->{'GROUPDESC'} = $groupdesc; + $entry->{'TYPE'} = $type; + $entry->{'SHOWID'} = -1; + $entry->{'NORMLEVEL'} = $normlevel; + $entry->{'TRIMLEVEL'} = $trimlevel; + $entry->{'PARAM'} = $params; + if($type eq "show") { + $entry->{'SHOWID'} = $showid; + # $params has the format: 1111-01-1600-060 + if($params =~ /^([01]{4})-([0-9]{2})-([0-9]{2})([0-9]{2})-([0-9]{3})$/) { + $entry->{'RHYTHM'} = $1; + $entry->{'DOW'} = int $2; + $entry->{'STARTTIME'} = "$3:$4"; + $entry->{'LENGTH'} = int $5; + } } - elsif($name =~ /^([0-9]{2}-[A-Za-z]+)\/jingle$/ || $name =~ /^jingles\/(.*)$/) { - $name = "Jingles - $1"; - } - elsif($name =~ /^pool\/pool(.*)$/) { - $name = "Pool $1 - $desc"; - } - elsif($name =~ /^pool\/(.*)$/) { - $name = "Pool - $1"; - } - elsif($name =~ /^sondersendungen\/(.*)$/) { - $name = "Sondersendungen - $1"; - } - elsif($name =~ /^autoimport\/(.*)$/) { - $name = "autoimport - $1"; - } - my $perm = {}; - $perm->{'GROUP'} = $group; - $perm->{'PATH'} = $path; - $perm->{'TO_CART'} = $to_cart; - $perm->{'NAME'} = $name; - push @allowed_dbs, $perm; + + push @allowed_dbs, $entry; } $sth->finish(); - return sort { uc($a->{'NAME'}) cmp uc($b->{'NAME'}) } @allowed_dbs; + return @allowed_dbs; } |