diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-28 16:37:43 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-28 16:37:43 (GMT) |
commit | 990e9ce17301895110e6d74546c084f772b6ab9f (patch) | |
tree | 99c53385b5840c34c9acec8cf69c9e95c113ffc0 /lib/RHRD | |
parent | 24ec6833f3bb6c665506612105137c71cd82debe (diff) |
implemented list_musicpools lib function
Diffstat (limited to 'lib/RHRD')
-rwxr-xr-x | lib/RHRD/rddb.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index ccbff24..586ae17 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -1754,6 +1754,36 @@ sub get_musicpools_next_free_slot return get_next_free_slot($ctx, $ctx->{'config'}{'specialgroups'}{'allpools'}); } +sub list_musicpools +{ + my ($ctx) = @_; + + my $sql = qq{select DROPBOXES.GROUP_NAME,DROPBOXES.PATH,GROUPS.DESCRIPTION,DROPBOXES.SET_USER_DEFINED from DROPBOXES,GROUPS where DROPBOXES.GROUP_NAME = GROUPS.NAME and DROPBOXES.STATION_NAME = ? order by DROPBOXES.PATH;}; + + my $sth = $ctx->{'dbh'}->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + $sth->execute($ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'}) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + my @pool_dbs; + while(my ($group, $shortname, $title, $params) = $sth->fetchrow_array()) { + my @p = split(';', $params); + next if ('M' ne $p[0]); + + my $entry = {}; + $entry->{'SHORTNAME'} = $shortname; + $entry->{'GROUP'} = $group; + $entry->{'TITLE'} = $title; + + push @pool_dbs, $entry; + } + $sth->finish(); + + return @pool_dbs; +} + + sub is_musicpools_user { my ($ctx, $username) = @_; |