summaryrefslogtreecommitdiffstats
path: root/Bugzilla/User.pm
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2010-05-07 14:59:28 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2010-05-07 14:59:28 +0200
commit4ec67697f3ea85ebf73f486f6dea1aba87d7da76 (patch)
tree60ad3d69ac496a5bc360253745f4f46656b53b34 /Bugzilla/User.pm
parentb4c91adafa45e4e1146ca1dabab27404dac6bab6 (diff)
downloadbugzilla-4ec67697f3ea85ebf73f486f6dea1aba87d7da76.tar.gz
bugzilla-4ec67697f3ea85ebf73f486f6dea1aba87d7da76.tar.xz
Bug 561745: Impossible to uncheck boxes in the Email preferences
r/a=mkanat
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r--Bugzilla/User.pm25
1 files changed, 16 insertions, 9 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index d02dc947b..936cf36e4 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -1471,18 +1471,25 @@ sub wants_mail {
# Skip DB query if relationship is explicit
return 1 if $relationship == REL_GLOBAL_WATCHER;
+ my $wants_mail = grep { $self->mail_settings->{$relationship}{$_} } @$events;
+ return $wants_mail ? 1 : 0;
+}
+
+sub mail_settings {
+ my $self = shift;
my $dbh = Bugzilla->dbh;
- my $wants_mail =
- $dbh->selectrow_array('SELECT 1
- FROM email_setting
- WHERE user_id = ?
- AND relationship = ?
- AND event IN (' . join(',', @$events) . ') ' .
- $dbh->sql_limit(1),
- undef, ($self->id, $relationship));
+ if (!defined $self->{'mail_settings'}) {
+ my $data =
+ $dbh->selectall_arrayref('SELECT relationship, event FROM email_setting
+ WHERE user_id = ?', undef, $self->id);
+ my %mail;
+ # The hash is of the form $mail{$relationship}{$event} = 1.
+ $mail{$_->[0]}{$_->[1]} = 1 foreach @$data;
- return defined($wants_mail) ? 1 : 0;
+ $self->{'mail_settings'} = \%mail;
+ }
+ return $self->{'mail_settings'};
}
sub is_mover {