From 15db57fb8eb839f48763394f73709a1d5952131b Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@spreadspace.org>
Date: Tue, 29 Sep 2015 03:17:03 +0200
Subject: added type filter for list dropboxes


diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 8fc2b3c..09b307b 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -643,7 +643,7 @@ sub get_showtitle_and_log
   $sth->finish();
 
   unless(defined $title) {
-    return (undef, undef, 'ERROR', "Show with ID=" . $showid .  " not found!")
+    return (undef, undef, 'ERROR', "Show with ID=" . $showid . " not found!")
   }
   unless(defined $macros) {
     return (undef, undef, 'ERROR', "Show with ID=" . $showid . " has no macro!");
@@ -659,7 +659,7 @@ sub get_showtitle_and_log
 
 sub get_dropboxes
 {
-  my ($dbh, $username, $groupname) = @_;
+  my ($dbh, $username, $groupname, $type) = @_;
 
   my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.TO_CART,DROPBOXES.NORMALIZATION_LEVEL,DROPBOXES.AUTOTRIM_LEVEL,DROPBOXES.SET_USER_DEFINED,GROUPS.DEFAULT_LOW_CART,GROUPS.DEFAULT_HIGH_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 and DROPBOXES.STATION_NAME=?;};
   if(defined $groupname) {
@@ -680,6 +680,7 @@ sub get_dropboxes
   my @allowed_dbs;
   while(my ($group, $to_cart, $normlevel, $trimlevel, $params, $lowcart, $highcart, $groupdesc) = $sth->fetchrow_array()) {
     my @p = split(';', $params);
+    next if (defined $type && $type ne $p[0]);
 
     my $entry = {};
     $entry->{'GROUP'} = $group;
@@ -760,8 +761,6 @@ sub get_show_carts
   return @carts;
 }
 
-return 1;
-
 sub get_shows_cart_range
 {
   my ($dbh) = @_;
@@ -803,3 +802,4 @@ sub get_jingles_next_free_slot
 }
 
 #################################  END  ####################################
+return 1;
diff --git a/test/get-dropboxes b/test/get-dropboxes
index abff8d9..b8a5266 100755
--- a/test/get-dropboxes
+++ b/test/get-dropboxes
@@ -28,11 +28,14 @@ use RHRD::rddb;
 
 my $username = $ARGV[0];
 my $groupname = $ARGV[1];
+$groupname = undef if (defined($groupname) && $groupname eq '');
+my $type = $ARGV[2];
+
 
 my @dropboxes = ();
 my ($dbh, $status, $errorstring) = RHRD::rddb::opendb();
 if(defined $dbh) {
-  @dropboxes = RHRD::rddb::get_dropboxes($dbh, $username, $groupname);
+  @dropboxes = RHRD::rddb::get_dropboxes($dbh, $username, $groupname, $type);
   if(!defined $dropboxes[0] && defined $dropboxes[1]) {
     print STDERR "$dropboxes[1]: $dropboxes[2]";
     RHRD::rddb::closedb($dbh);
diff --git a/utils/rd-group b/utils/rd-group
index 72c39e9..c72e7d2 100755
--- a/utils/rd-group
+++ b/utils/rd-group
@@ -31,11 +31,11 @@ if ($> != 0 ) {
 
 my $num_args = $#ARGV + 1;
 if ($num_args < 2) {
-  print STDERR "Usage: rd-group ( (check|remove|get-members|get-carts|get-reports) <groupname>            |\n" .
-               "                   add <groupname> [ <description> ]                                      |\n" .
-               "                   (add-member|remove-member|is-member) <groupname> <user>                |\n" .
-               "                   set-carts <groupname> [ <low> [ <high> [ <type> [ <enforce range> ]]]  |\n" .
-               "                   set-reports <groupname> [ <nownext> [ <traffic> [ <music> ]]]  )\n";
+  print STDERR "Usage: rd-group (check|remove|get-members|get-carts|get-reports) <groupname>\n" .
+               "       rd-group add <groupname> [ <description> ]\n" .
+               "       rd-group (add-member|remove-member|is-member) <groupname> <user>\n" .
+               "       rd-group set-carts <groupname> [ <low> [ <high> [ <type> [ <enforce range> ]]]\n" .
+               "       rd-group set-reports <groupname> [ <nownext> [ <traffic> [ <music> ]]]\n";
   exit 1;
 }
 
-- 
cgit v0.10.2