From 990e9ce17301895110e6d74546c084f772b6ab9f Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Thu, 28 Jul 2016 18:37:43 +0200
Subject: implemented list_musicpools lib function


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) = @_;
diff --git a/utils/rhrd-pool b/utils/rhrd-pool
index 7d95082..6152d92 100755
--- a/utils/rhrd-pool
+++ b/utils/rhrd-pool
@@ -38,7 +38,7 @@ sub list
 {
   my ($ctx) = @_;
 
-  my @pools = RHRD::rddb::list_pools($ctx);
+  my @pools = RHRD::rddb::list_musicpools($ctx);
   if(!defined $pools[0] && defined $pools[1]) {
     print STDERR "$pools[1]: $pools[2]";
     return 1;
@@ -53,7 +53,7 @@ sub show
 {
   my ($ctx, $shortname) = @_;
 
-  my ($pool, $status, $errorstring) = RHRD::rddb::get_pool_info($ctx, $shortname);
+  my ($pool, $status, $errorstring) = RHRD::rddb::get_musicpool_info($ctx, $shortname);
   unless (defined $pool) {
     print STDERR "$errorstring\n";
     return 1;
@@ -103,27 +103,27 @@ sub add
   }
 
   print " * creating group '" . $groupname . "'\n";
-  ($result, $status, $errorstring) = RHRD::rddb::create_pool_group($ctx, $groupname);
+  ($result, $status, $errorstring) = RHRD::rddb::create_musicpool_group($ctx, $groupname);
   unless(defined $result) {
     print STDERR $status . ": " . $errorstring . "\n";
     return 1;
   }
 
-  ($result, $status, $errorstring) = RHRD::rddb::create_pool_event($ctx, $shortname, $groupname);
+  ($result, $status, $errorstring) = RHRD::rddb::create_musicpool_event($ctx, $shortname, $groupname);
   unless(defined $result) {
     print STDERR $status . ": " . $errorstring . "\n";
     return 1;
   }
   print " * created event\n";
 
-  ($result, $status, $errorstring) = RHRD::rddb::create_pool_clock($ctx, $shortname, $color);
+  ($result, $status, $errorstring) = RHRD::rddb::create_musicpool_clock($ctx, $shortname, $color);
   unless(defined $result) {
     print STDERR $status . ": " . $errorstring . "\n";
     return 1;
   }
   print " * created clock (color: " . $color . ")\n";
 
-  ($result, $status, $errorstring) = RHRD::rddb::create_show_dropbox($ctx, $groupname, $shortname);
+  ($result, $status, $errorstring) = RHRD::rddb::create_musicpool_dropbox($ctx, $groupname, $shortname);
   unless(defined $result) {
     print STDERR $status . ": " . $errorstring . "\n";
     return 1;
@@ -140,7 +140,7 @@ sub edit
 {
   my ($ctx, $shortname, $title) = @_;
 
-  my ($result, $status, $errorstring) = RHRD::rddb::update_pool_title($ctx, $shortname, $title);
+  my ($result, $status, $errorstring) = RHRD::rddb::update_musicpool_title($ctx, $shortname, $title);
   unless(defined $result) {
     print STDERR $status . ": " . $errorstring . "\n";
     return 1;
@@ -158,7 +158,7 @@ sub remove
 {
   my ($ctx, $shortname) = @_;
 
-  my @results = RHRD::rddb::remove_pool($ctx, $shortname);
+  my @results = RHRD::rddb::remove_musicpool($ctx, $shortname);
   if(!defined $results[0] && defined $results[2]) {
     print STDERR $results[1] . ": " . $results[2] . "\n";
     return 1;
-- 
cgit v0.10.2