summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/RHRD/rddb.pm19
-rwxr-xr-xutils/rhrd-group15
2 files changed, 25 insertions, 9 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index bfa31fd..10148f8 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -551,7 +551,7 @@ sub get_user_groups
{
my ($ctx, $username) = @_;
- my $sql = qq{select GROUP_NAME from USER_PERMS where USER_NAME = ?;};
+ my $sql = qq{select GROUP_NAME from USER_PERMS where USER_NAME = ? oder by GROUP_NAME;};
my $sth = $ctx->{'dbh'}->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
@@ -852,17 +852,28 @@ sub remove_group_member
sub list_groups
{
- my ($ctx) = @_;
+ my ($ctx, $type) = @_;
+
+ my $min_cart = RD_MIN_CART;
+ my $max_cart = RD_MAX_CART;
+ if(defined $type) {
+ ($min_cart, $max_cart) = get_shows_cart_range($ctx) if($type eq "shows");
+ ($min_cart, $max_cart) = get_jingles_cart_range($ctx) if($type eq "jingles");
+ ($min_cart, $max_cart) = get_musicpools_cart_range($ctx) if($type eq "pools");
+ }
- my $sql = qq{select NAME from GROUPS order by DEFAULT_LOW_CART;};
+ my $sql = qq{select NAME from GROUPS where DEFAULT_LOW_CART >= ? and DEFAULT_HIGH_CART <= ? order by DEFAULT_LOW_CART;};
my $sth = $ctx->{'dbh'}->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
- $sth->execute()
+ $sth->execute($min_cart, $max_cart)
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
my @groups;
while(my ($group) = $sth->fetchrow_array()) {
+ next if($group eq $ctx->{'config'}{'specialgroups'}{'allshows'});
+ next if($group eq $ctx->{'config'}{'specialgroups'}{'alljingles'});
+ next if($group eq $ctx->{'config'}{'specialgroups'}{'allpools'});
push @groups, $group;
}
$sth->finish();
diff --git a/utils/rhrd-group b/utils/rhrd-group
index 9d73adb..088bc10 100755
--- a/utils/rhrd-group
+++ b/utils/rhrd-group
@@ -25,7 +25,7 @@ use RHRD::rddb;
sub print_usage
{
- print STDERR "Usage: rhrd-group list\n" .
+ print STDERR "Usage: rhrd-group list [ (shows|jingles|pools) ]\n" .
" rhrd-group (check|remove|get-members|get-carts|get-reports) <groupname>\n" .
" rhrd-group add <groupname> [ <description> ]\n" .
" rhrd-group (add-member|remove-member|is-member) <groupname> <user>\n" .
@@ -35,9 +35,14 @@ sub print_usage
sub list
{
- my ($ctx) = @_;
+ my ($ctx, $type) = @_;
- my @groups = RHRD::rddb::list_groups($ctx);
+ if(defined($type) && $type ne "shows" && $type ne "jingles" && $type ne "pools") {
+ print_usage();
+ return 1;
+ }
+
+ my @groups = RHRD::rddb::list_groups($ctx, $type);
if(!defined $groups[0] && defined $groups[1]) {
print STDERR "$groups[1]: $groups[2]";
return 1;
@@ -242,11 +247,11 @@ my $ret = 0;
my ($ctx, $status, $errorstring) = RHRD::rddb::init();
if(defined $ctx) {
if($cmd eq "list") {
- if($num_args != 1) {
+ if($num_args < 1 || $num_args > 2) {
print_usage();
$ret = 1;
} else {
- $ret = list($ctx);
+ $ret = list($ctx, $ARGV[1]);
}
}
elsif($cmd eq "check") {