summaryrefslogtreecommitdiffstats
path: root/whine.pl
diff options
context:
space:
mode:
authorerik%dasbistro.com <>2005-02-19 07:41:09 +0100
committererik%dasbistro.com <>2005-02-19 07:41:09 +0100
commitcc73e8e4f6726abd0421c78445b18bd21b28169e (patch)
tree4cb7bf4e825e06346250e9b6aa8f5dbd76df5ae3 /whine.pl
parent1ab7c9d7a1495c0f95e6e8ae12249a7ccb3c1465 (diff)
downloadbugzilla-cc73e8e4f6726abd0421c78445b18bd21b28169e.tar.gz
bugzilla-cc73e8e4f6726abd0421c78445b18bd21b28169e.tar.xz
Bug 253721: Add group-based lists to whining
Patch by Erik Stambaugh <erik@dasbistro.com> r=joel, r,a=justdave
Diffstat (limited to 'whine.pl')
-rwxr-xr-xwhine.pl38
1 files changed, 31 insertions, 7 deletions
diff --git a/whine.pl b/whine.pl
index d3584db68..997e4a58a 100755
--- a/whine.pl
+++ b/whine.pl
@@ -75,7 +75,7 @@ my $sth_next_scheduled_event = $dbh->prepare(
# get all pending schedules matching an eventid
my $sth_schedules_by_event = $dbh->prepare(
- "SELECT id, mailto_userid " .
+ "SELECT id, mailto_type, mailto " .
"FROM whine_schedules " .
"WHERE eventid=? AND run_next <= NOW()"
);
@@ -245,18 +245,42 @@ sub get_next_event {
# Add the users from those schedules to the list
while (my $row = $sth_schedules_by_event->fetch) {
- my ($sid, $mailto) = @{$row};
+ my ($sid, $mailto_type, $mailto) = @{$row};
# Only bother doing any work if this user has whine permission
if ($owner->in_group('bz_canusewhines')) {
- if (not defined $user_objects{$mailto}) {
- if ($mailto == $owner_id) {
- $user_objects{$mailto} = $owner;
+
+ if ($mailto_type == MAILTO_USER) {
+ if (not defined $user_objects{$mailto}) {
+ if ($mailto == $owner_id) {
+ $user_objects{$mailto} = $owner;
+ }
+ elsif ($whineatothers) {
+ $user_objects{$mailto} = Bugzilla::User->new($mailto);
+ }
}
- elsif ($whineatothers) {
- $user_objects{$mailto} = Bugzilla::User->new($mailto);
+ }
+ elsif ($mailto_type == MAILTO_GROUP) {
+ my $sth = $dbh->prepare("SELECT name FROM groups " .
+ "WHERE id=?");
+ $sth->execute($mailto);
+ my $groupname = $sth->fetch->[0];
+ my $group_id = Bugzilla::Group::ValidateGroupName(
+ $groupname, $owner);
+ if ($group_id) {
+ $sth = $dbh->prepare("SELECT user_id FROM " .
+ "user_group_map " .
+ "WHERE group_id=?");
+ $sth->execute($group_id);
+ for my $row (@{$sth->fetchall_arrayref}) {
+ if (not defined $user_objects{$row->[0]}) {
+ $user_objects{$row->[0]} =
+ Bugzilla::User->new($row->[0]);
+ }
+ }
}
}
+
}
reset_timer($sid);