summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/DB/Schema.pm2
-rw-r--r--Bugzilla/Install/DB.pm4
-rwxr-xr-xeditwhines.cgi13
-rw-r--r--template/en/default/whine/schedule.html.tmpl10
-rwxr-xr-xwhine.pl20
5 files changed, 37 insertions, 12 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index fc4361d17..aacbe386b 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -1334,6 +1334,8 @@ use constant ABSTRACT_SCHEMA => {
DELETE => 'CASCADE'}},
subject => {TYPE => 'varchar(128)'},
body => {TYPE => 'MEDIUMTEXT'},
+ mailifnobugs => {TYPE => 'BOOLEAN', NOTNULL => 1,
+ DEFAULT => 'FALSE'},
],
},
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index de1d48361..2247e58b3 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -564,6 +564,10 @@ sub update_table_definitions {
$dbh->bz_alter_column('group_control_map', 'canedit',
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'});
+ # 2009-01-16 oreomike@gmail.com - Bug 302420
+ $dbh->bz_add_column('whine_events', 'mailifnobugs',
+ { TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'});
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
diff --git a/editwhines.cgi b/editwhines.cgi
index 06717fe2c..37f52349e 100755
--- a/editwhines.cgi
+++ b/editwhines.cgi
@@ -143,20 +143,22 @@ if ($cgi->param('update')) {
$sth->execute($eventid, $userid);
}
else {
- # check the subject and body for changes
+ # check the subject, body and mailifnobugs for changes
my $subject = ($cgi->param("event_${eventid}_subject") or '');
my $body = ($cgi->param("event_${eventid}_body") or '');
+ my $mailifnobugs = $cgi->param("event_${eventid}_mailifnobugs") ? 1 : 0;
trick_taint($subject) if $subject;
trick_taint($body) if $body;
if ( ($subject ne $events->{$eventid}->{'subject'})
+ || ($mailifnobugs != $events->{$eventid}->{'mailifnobugs'})
|| ($body ne $events->{$eventid}->{'body'}) ) {
$sth = $dbh->prepare("UPDATE whine_events " .
- "SET subject=?, body=? " .
+ "SET subject=?, body=?, mailifnobugs=? " .
"WHERE id=?");
- $sth->execute($subject, $body, $eventid);
+ $sth->execute($subject, $body, $mailifnobugs, $eventid);
}
# add a schedule
@@ -438,14 +440,15 @@ sub get_events {
my $dbh = Bugzilla->dbh;
my $events = {};
- my $sth = $dbh->prepare("SELECT DISTINCT id, subject, body " .
+ my $sth = $dbh->prepare("SELECT DISTINCT id, subject, body, mailifnobugs " .
"FROM whine_events " .
"WHERE owner_userid=?");
$sth->execute($userid);
- while (my ($ev, $sub, $bod) = $sth->fetchrow_array) {
+ while (my ($ev, $sub, $bod, $mno) = $sth->fetchrow_array) {
$events->{$ev} = {
'subject' => $sub || '',
'body' => $bod || '',
+ 'mailifnobugs' => $mno || 0,
};
}
return $events;
diff --git a/template/en/default/whine/schedule.html.tmpl b/template/en/default/whine/schedule.html.tmpl
index 6fe19957b..245a3e4a9 100644
--- a/template/en/default/whine/schedule.html.tmpl
+++ b/template/en/default/whine/schedule.html.tmpl
@@ -124,6 +124,16 @@
</td>
</tr>
+ <tr>
+ <td valign="top" align="right">
+ Send a message even if there are no [% terms.bugs %] in the search result:
+ </td>
+ <td colspan="2">
+ <input type="checkbox" name="event_[% event.key %]_mailifnobugs"
+ [%- IF event.value.mailifnobugs == 1 %] checked [% END %]>
+ </td>
+ </tr>
+
[% IF event.value.schedule.size == 0 %]
<tr>
diff --git a/whine.pl b/whine.pl
index 3eb757dd4..36cf9c5af 100755
--- a/whine.pl
+++ b/whine.pl
@@ -65,7 +65,8 @@ my $sth_next_scheduled_event = $dbh->prepare(
" whine_schedules.eventid, " .
" whine_events.owner_userid, " .
" whine_events.subject, " .
- " whine_events.body " .
+ " whine_events.body, " .
+ " whine_events.mailifnobugs " .
"FROM whine_schedules " .
"LEFT JOIN whine_events " .
" ON whine_events.id = whine_schedules.eventid " .
@@ -200,6 +201,7 @@ $sched_h->finish();
# users - array of user objects for recipients
# subject - Subject line for the email
# body - the text inserted above the bug lists
+# mailifnobugs - send message even if there are no query or query results
sub get_next_event {
my $event = {};
@@ -214,7 +216,7 @@ sub get_next_event {
my $fetched = $sth_next_scheduled_event->fetch;
$sth_next_scheduled_event->finish;
return undef unless $fetched;
- my ($eventid, $owner_id, $subject, $body) = @{$fetched};
+ my ($eventid, $owner_id, $subject, $body, $mailifnobugs) = @{$fetched};
my $owner = Bugzilla::User->new($owner_id);
@@ -282,6 +284,7 @@ sub get_next_event {
'mailto' => \@users,
'subject' => $subject,
'body' => $body,
+ 'mailifnobugs' => $mailifnobugs,
};
}
}
@@ -296,6 +299,7 @@ sub get_next_event {
# mailto (array of user objects for mail targets)
# subject (subject line for message)
# body (text blurb at top of message)
+# mailifnobugs (send message even if there are no query or query results)
while (my $event = get_next_event) {
my $eventid = $event->{'eventid'};
@@ -316,12 +320,14 @@ while (my $event = get_next_event) {
# run the queries for this schedule
my $queries = run_queries($args);
- # check to make sure there is something to output
- my $there_are_bugs = 0;
- for my $query (@{$queries}) {
- $there_are_bugs = 1 if scalar @{$query->{'bugs'}};
+ # If mailifnobugs is false, make sure there is something to output
+ if (!$event->{'mailifnobugs'}) {
+ my $there_are_bugs = 0;
+ for my $query (@{$queries}) {
+ $there_are_bugs = 1 if scalar @{$query->{'bugs'}};
+ }
+ next unless $there_are_bugs;
}
- next unless $there_are_bugs;
$args->{'queries'} = $queries;