From ddddaf2b67207056ebb407ea68f9e0e6a697a37e Mon Sep 17 00:00:00 2001 From: "karl.kornel%mindspeed.com" <> Date: Sun, 30 Jul 2006 10:50:24 +0000 Subject: Bug 100953: Move data/nomail into the DB and implement a UI to edit it Patch by A. Karl Kornel r=wurblzap a=justdave --- Bugzilla/BugMail.pm | 17 +---------------- Bugzilla/DB/Schema.pm | 2 ++ Bugzilla/User.pm | 23 +++++++++++++++++------ 3 files changed, 20 insertions(+), 22 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 1b2fb5429..dd92cd3b4 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -57,20 +57,6 @@ use constant REL_NAMES => { REL_VOTER , "Voter" }; -sub _read_nomail { - my $nomail = Bugzilla->request_cache->{bugmail_nomail}; - return $nomail if $nomail; - if (open(NOMAIL, '<', bz_locations->{'datadir'} . "/nomail")) { - while () { - $nomail->{trim($_)} = 1; - } - close(NOMAIL); - } - Bugzilla->request_cache->{bugmail_nomail} = $nomail; - return $nomail; -} - - sub FormatTriple { my ($a, $b, $c) = (@_); $^A = ""; @@ -465,8 +451,7 @@ sub ProcessOneBug { # Make sure the user isn't in the nomail list, and the insider and # dep checks passed. - my $nomail = _read_nomail(); - if ((!$nomail->{$user->login}) && + if ($user->email_enabled && $insider_ok && $dep_ok) { diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 5396a3d20..9f4670845 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -614,6 +614,8 @@ use constant ABSTRACT_SCHEMA => { cryptpassword => {TYPE => 'varchar(128)'}, realname => {TYPE => 'varchar(255)'}, disabledtext => {TYPE => 'MEDIUMTEXT', NOTNULL => 1}, + disable_mail => {TYPE => 'BOOLEAN', NOTNULL => 1, + DEFAULT => 'FALSE'}, mybugslink => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'}, refreshed_when => {TYPE => 'DATETIME', NOTNULL => 1}, diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 48502326e..924cb0511 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -122,6 +122,7 @@ sub _create { 'showmybugslink' => 0, 'disabledtext' => '', 'flags' => {}, + 'disable_mail' => 0, }; bless ($self, $class); return $self unless $cond && $val; @@ -131,9 +132,9 @@ sub _create { my $dbh = Bugzilla->dbh; - my ($id, $login, $name, $disabledtext, $mybugslink) = + my ($id, $login, $name, $disabledtext, $mybugslink, $disable_mail) = $dbh->selectrow_array(qq{SELECT userid, login_name, realname, - disabledtext, mybugslink + disabledtext, mybugslink, disable_mail FROM profiles WHERE $cond}, undef, $val); @@ -144,6 +145,7 @@ sub _create { $self->{'login'} = $login; $self->{'disabledtext'} = $disabledtext; $self->{'showmybugslink'} = $mybugslink; + $self->{'disable_mail'} = $disable_mail; return $self; } @@ -156,6 +158,8 @@ sub name { $_[0]->{name}; } sub disabledtext { $_[0]->{'disabledtext'}; } sub is_disabled { $_[0]->disabledtext ? 1 : 0; } sub showmybugslink { $_[0]->{showmybugslink}; } +sub email_disabled { $_[0]->{disable_mail}; } +sub email_enabled { !($_[0]->{disable_mail}); } sub set_authorizer { my ($self, $authorizer) = @_; @@ -1339,10 +1343,11 @@ sub get_userlist { } sub insert_new_user { - my ($username, $realname, $password, $disabledtext) = (@_); + my ($username, $realname, $password, $disabledtext, $disable_mail) = (@_); my $dbh = Bugzilla->dbh; $disabledtext ||= ''; + $disable_mail ||= 0; # If not specified, generate a new random password for the user. # If the password is '*', do not encrypt it; we are creating a user @@ -1358,10 +1363,11 @@ sub insert_new_user { # Insert the new user record into the database. $dbh->do("INSERT INTO profiles (login_name, realname, cryptpassword, disabledtext, - refreshed_when) - VALUES (?, ?, ?, ?, '1901-01-01 00:00:00')", + refreshed_when, disable_mail) + VALUES (?, ?, ?, ?, '1901-01-01 00:00:00', ?)", undef, - ($username, $realname, $cryptpassword, $disabledtext)); + ($username, $realname, $cryptpassword, $disabledtext, + $disable_mail)); # Turn on all email for the new user my $new_userid = $dbh->bz_last_key('profiles', 'userid'); @@ -1868,6 +1874,11 @@ Params: $username (scalar, string) - The login name for the new user. If given, the user will be disabled, meaning the account will be unavailable for login. + $disable_mail (scalar, boolean) - Optional, defaults to 0. + If 1, bug-related mail will not be + sent to this user; if 0, mail will + be sent depending on the user's + email preferences. Returns: The password for this user, in plain text, so it can be included in an e-mail sent to the user. -- cgit v1.2.3-24-g4f1b