]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Added user preference controlling how much email they get.
authorterry%mozilla.org <>
Thu, 13 May 1999 00:20:39 +0000 (00:20 +0000)
committerterry%mozilla.org <>
Thu, 13 May 1999 00:20:39 +0000 (00:20 +0000)
CHANGES
changepassword.cgi
makeprofilestable.sh
processmail
query.cgi

diff --git a/CHANGES b/CHANGES
index eb2fbb78bde776b6cd33df0a829d2bea887ea57f..93d6e051a889556abf821001c563215b168e9496 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,11 @@ query the CVS tree.  For example,
 will tell you what has been changed in the last week.
 
 
+5/12/99 Added a pref to control how much email you get.  This needs a new
+column in the profiles table, so feed the following to mysql:
+
+       alter table profiles add column emailnotification enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges";
+
 5/5/99 Added the ability to search by creation date.  To make this perform
 well, you ought to do the following:
 
index a3a17e39a3d54b47bd5fb449f1b658950f850b18..25ea4e7c358c884a350336d19151df943272eb8d 100755 (executable)
@@ -23,28 +23,65 @@ require "CGI.pl";
 
 confirm_login();
 
-if (! defined $::FORM{'pwd1'}) {
-    print "Content-type: text/html
+print "Content-type: text/html\n\n";
 
-<H1>Change your password</H1>
+if (! defined $::FORM{'pwd1'}) {
+    PutHeader("Preferences", "Change your password and other preferences",
+              $::COOKIE{'Bugzilla_login'});
+
+    my $qacontactpart = "";
+    if (Param('useqacontact')) {
+        $qacontactpart = ", the current QA Contact";
+    }
+    SendSQL("select emailnotification from profiles where login_name = " .
+            SqlQuote($::COOKIE{'Bugzilla_login'}));
+    my ($emailnotification) = (FetchSQLData());
+    print qq{
 <form method=post>
+<hr>
 <table>
 <tr>
 <td align=right>Please enter the new password for <b>$::COOKIE{'Bugzilla_login'}</b>:</td>
-<td><input type=password name=pwd1></td>
+<td><input type=password name="pwd1"></td>
 </tr>
 <tr>
 <td align=right>Re-enter your new password:</td>
-<td><input type=password name=pwd2></td>
+<td><input type=password name="pwd2"></td>
+</table>
+<hr>
+<table>
+<tr>
+<td align=right>Bugzilla will send out email notification of changed bugs to 
+the current owner, the submitter of the bug$qacontactpart, and anyone on the
+CC list.  However, you can suppress some of those email notifications.
+On which of these bugs would you like email notification of changes?</td>
+<td><SELECT NAME="emailnotification">
+};
+    foreach my $i (["ExcludeSelfChanges", "All qualifying bugs except those which I change"],
+                   ["CConly", "Only those bugs which I am listed on the CC line"],
+                   ["All", "All qualifying bugs"]) {
+        my ($tag, $desc) = (@$i);
+        my $selectpart = "";
+        if ($tag eq $emailnotification) {
+            $selectpart = " SELECTED";
+        }
+        print qq{<OPTION$selectpart VALUE="$tag">$desc\n};
+    }
+    print "
+</SELECT>
+</td>
+</tr>
 </table>
-<input type=submit value=Submit>\n";
+<hr>
+<input type=submit value=Submit>
+<hr>
+";
+    navigation_header();
     exit;
 }
 
 if ($::FORM{'pwd1'} ne $::FORM{'pwd2'}) {
-    print "Content-type: text/html
-
-<H1>Try again.</H1>
+    print "<H1>Try again.</H1>
 The two passwords you entered did not match.  Please click <b>Back</b> and try again.\n";
     exit;
 }
@@ -53,36 +90,43 @@ The two passwords you entered did not match.  Please click <b>Back</b> and try a
 my $pwd = $::FORM{'pwd1'};
 
 
-if ($pwd !~ /^[a-zA-Z0-9-_]*$/ || length($pwd) < 3 || length($pwd) > 15) {
-    print "Content-type: text/html
+sub x {
+    my $sc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
+    return substr($sc, int (rand () * 100000) % (length ($sc) + 1), 1);
+}
 
-<H1>Sorry; we're picky.</H1>
+if ($pwd ne "") {
+    if ($pwd !~ /^[a-zA-Z0-9-_]*$/ || length($pwd) < 3 || length($pwd) > 15) {
+        print "<H1>Sorry; we're picky.</H1>
 Please choose a password that is between 3 and 15 characters long, and that
 contains only numbers, letters, hyphens, or underlines.
 <p>
 Please click <b>Back</b> and try again.\n";
-    exit;
-}
-
-
-print "Content-type: text/html\n\n";
-
+        exit;
+    }
+    
+    
 # Generate a random salt.
-
-sub x {
-    my $sc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
-    return substr($sc, int (rand () * 100000) % (length ($sc) + 1), 1);
+    
+    my $salt  = x() . x();
+    
+    my $encrypted = crypt($pwd, $salt);
+    
+    SendSQL("update profiles set password='$pwd',cryptpassword='$encrypted' where login_name=" .
+            SqlQuote($::COOKIE{'Bugzilla_login'}));
+    
+    SendSQL("update logincookies set cryptpassword = '$encrypted' where cookie = $::COOKIE{'Bugzilla_logincookie'}");
 }
-my $salt  = x() . x();
 
-my $encrypted = crypt($pwd, $salt);
 
-SendSQL("update profiles set password='$pwd',cryptpassword='$encrypted' where login_name=" .
+SendSQL("update profiles set emailnotification='$::FORM{'emailnotification'}' where login_name = " .
         SqlQuote($::COOKIE{'Bugzilla_login'}));
 
-SendSQL("update logincookies set cryptpassword = '$encrypted' where cookie = $::COOKIE{'Bugzilla_logincookie'}");
 
-print "<H1>OK, done.</H1>
-Your new password has been set.
+PutHeader("Preferences updated.");
+
+
+print "
+Your preferences have been updated.
 <p>
 <a href=query.cgi>Back to query page.</a>\n";
index be4c03e4bf8fda8243e76f86a1b56bafeff38dbb..0dd5eaba0ed307703d2175fe65651f380a9f0ba0 100755 (executable)
@@ -34,6 +34,7 @@ password varchar(16),
 cryptpassword varchar(64),
 realname varchar(255),
 groupset bigint not null,
+emailnotification enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges";
 index(login_name)
 );
 
index 48eba91936ee4bc13c43bfb8025f444ffe8fc134..b5852bbb8d25cff2625625b0eb45dbdf2b08e2cd 100755 (executable)
@@ -178,13 +178,29 @@ $::bug{'long_desc'}
 }
 
 
-
+my $didexclude = 0;
 sub fixaddresses {
-    my ($list) = (@_);
+    my ($field, $list) = (@_);
     my @result;
     my %seen;
     foreach my $i (@$list) {
-        if ($i ne $nametoexclude && $i ne "" && !defined $::nomail{$i} && !defined $seen{$i}) {
+        if ($i eq "") {
+            next;
+        }
+        SendSQL("select emailnotification from profiles where login_name = " .
+                SqlQuote($i));
+        my $emailnotification = FetchOneColumn();
+        if ($emailnotification eq "CConly") {
+            if ($field ne "cc") {
+                next;
+            }
+        }
+        if ($emailnotification eq "ExcludeSelfChanges" && $i eq $nametoexclude) {
+            $didexclude = 1;
+            next;
+        }
+        
+        if (!defined $::nomail{$i} && !defined $seen{$i}) {
             push @result, $i;
             $seen{$i} = 1;
         }
@@ -224,9 +240,10 @@ sub ProcessOneBug {
     close FID;
     if (Different($old, $new)) {
         system("diff -c -b $old $new > $diffs");
-        my $tolist = fixaddresses([$::bug{'assigned_to'}, $::bug{'reporter'},
+        my $tolist = fixaddresses("to",
+                                  [$::bug{'assigned_to'}, $::bug{'reporter'},
                                    $::bug{'qa_contact'}]);
-        my $cclist = fixaddresses($::bug{'cclist'});
+        my $cclist = fixaddresses("cc", $::bug{'cclist'});
         my $logstr = "Bug $i $verb";
         if ($tolist ne "" || $cclist ne "") {
             my %substs;
@@ -251,7 +268,10 @@ sub ProcessOneBug {
                 print SENDMAIL $msg;
                 close SENDMAIL;
                 $logstr = "$logstr; mail sent to $tolist, $cclist";
-               print "<B>Email sent to:</B> $tolist $cclist <B>Excluding:</B> $nametoexclude\n";
+               print "<B>Email sent to:</B> $tolist $cclist\n";
+                if ($didexclude) {
+                    print "<B>Excluding:</B> $nametoexclude (<a href=changepassword.cgi>change your preferences</a> if you wish not to be excluded)\n";
+                }
             }
         }
         unlink($diffs);
index 102f655f278d0724cb2f69995666447b29582b1c..ac62a0db58406c6c0e1e5c01b216e034700ee208 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -556,7 +556,7 @@ if (UserInGroup("editcomponents")) {
 if (defined $::COOKIE{"Bugzilla_login"}) {
     print "<a href=relogin.cgi>Log in as someone besides <b>$::COOKIE{'Bugzilla_login'}</b></a><br>\n";
 }
-print "<a href=changepassword.cgi>Change your password.</a><br>\n";
+print "<a href=changepassword.cgi>Change your password or preferences.</a><br>\n";
 print "<a href=\"enter_bug.cgi\">Create a new bug.</a><br>\n";
 print "<a href=\"createaccount.cgi\">Open a new Bugzilla account</a><br>\n";
 print "<a href=\"reports.cgi\">Bug reports</a><br>\n";