summaryrefslogtreecommitdiffstats
path: root/userprefs.cgi
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-04-11 09:11:32 +0200
committerByron Jones <bjones@mozilla.com>2013-04-11 09:11:32 +0200
commit861dd56bc901477eec23e060a143e24cc8b79384 (patch)
tree2c45b26f357d47f324ffa8320363a7d38c2927a8 /userprefs.cgi
parentb7dbc39db88b25921af9a0b75c4bf43b8c2538f5 (diff)
downloadbugzilla-861dd56bc901477eec23e060a143e24cc8b79384.tar.gz
bugzilla-861dd56bc901477eec23e060a143e24cc8b79384.tar.xz
Bug 859480: Ability to ignore specific bugs (not get email from them, even as the reporter)
Diffstat (limited to 'userprefs.cgi')
-rwxr-xr-xuserprefs.cgi45
1 files changed, 43 insertions, 2 deletions
diff --git a/userprefs.cgi b/userprefs.cgi
index f0d5a8e53..e614d8111 100755
--- a/userprefs.cgi
+++ b/userprefs.cgi
@@ -338,6 +338,47 @@ sub SaveEmail {
$dbh->bz_commit_transaction();
}
+
+ ###########################################################################
+ # Ignore Bugs
+ ###########################################################################
+ my %ignored_bugs = map { $_->{'id'} => 1 } @{$user->bugs_ignored};
+
+ # Validate the new bugs to ignore by checking that they exist and also
+ # if the user gave an alias
+ my @add_ignored = split(/[\s,]+/, $cgi->param('add_ignored_bugs'));
+ @add_ignored = map { Bugzilla::Bug->check($_)->id } @add_ignored;
+ map { $ignored_bugs{$_} = 1 } @add_ignored;
+
+ # Remove any bug ids the user no longer wants to ignore
+ foreach my $key (grep(/^remove_ignored_bug_/, $cgi->param)) {
+ my ($bug_id) = $key =~ /(\d+)$/;
+ delete $ignored_bugs{$bug_id};
+ }
+
+ # Update the database with any changes made
+ my ($removed, $added) = diff_arrays([ map { $_->{'id'} } @{$user->bugs_ignored} ],
+ [ keys %ignored_bugs ]);
+
+ if (scalar @$removed || scalar @$added) {
+ $dbh->bz_start_transaction();
+
+ if (scalar @$removed) {
+ $dbh->do('DELETE FROM email_bug_ignore WHERE user_id = ? AND ' .
+ $dbh->sql_in('bug_id', $removed),
+ undef, $user->id);
+ }
+ if (scalar @$added) {
+ my $sth = $dbh->prepare('INSERT INTO email_bug_ignore
+ (user_id, bug_id) VALUES (?, ?)');
+ $sth->execute($user->id, $_) foreach @$added;
+ }
+
+ # Reset the cache of ignored bugs if the list changed.
+ delete $user->{bugs_ignored};
+
+ $dbh->bz_commit_transaction();
+ }
}
@@ -345,9 +386,9 @@ sub DoPermissions {
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
my (@has_bits, @set_bits);
-
+
my $groups = $dbh->selectall_arrayref(
- "SELECT DISTINCT name, description FROM groups WHERE id IN (" .
+ "SELECT DISTINCT name, description FROM groups WHERE id IN (" .
$user->groups_as_string . ") ORDER BY name");
foreach my $group (@$groups) {
my ($nam, $desc) = @$group;