DELETE => 'CASCADE'}},
subject => {TYPE => 'varchar(128)'},
body => {TYPE => 'MEDIUMTEXT'},
+ mailifnobugs => {TYPE => 'BOOLEAN', NOTNULL => 1,
+ DEFAULT => 'FALSE'},
],
},
$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 #
################################################################
$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
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;
</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>
" 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 " .
# 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 = {};
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);
'mailto' => \@users,
'subject' => $subject,
'body' => $body,
+ 'mailifnobugs' => $mailifnobugs,
};
}
}
# 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'};
# 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;