]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
fix for bug found in original 17464 patch, where removal from the CC list was not...
authordmose%mozilla.org <>
Thu, 15 Feb 2001 04:41:24 +0000 (04:41 +0000)
committerdmose%mozilla.org <>
Thu, 15 Feb 2001 04:41:24 +0000 (04:41 +0000)
process_bug.cgi
processmail
userprefs.cgi

index 4acabf8e7158af382d3d072d344c834cf03ada69..256e1cd3450cd575f3ed36564719c1d387453a8f 100755 (executable)
@@ -398,6 +398,7 @@ ConnectToDatabase();
 my $formCcSet = new RelationSet;
 my $origCcSet = new RelationSet;
 my $origCcString;
+my $removedCcString = "";
 
 # We make sure to check out the CC list before we actually start touching any
 # bugs.  mergeFromString() ultimately searches the database using a quoted
@@ -409,6 +410,11 @@ if (defined $::FORM{'newcc'} && defined $::FORM{'id'}) {
     $formCcSet->mergeFromDB("select who from cc where bug_id = $::FORM{'id'}");
     $origCcString = $origCcSet->toString();  # cache a copy of the string vers
     if ((exists $::FORM{'removecc'}) && (exists $::FORM{'cc'})) {
+
+      # save off the folks removed from the CC list so they can be given to 
+      # the processmaill command line so they can be sent mail about it.
+      #
+      $removedCcString = join (',', @{$::MFORM{'cc'}});
       $formCcSet->removeItemsInArray(@{$::MFORM{'cc'}});
     }
     $formCcSet->mergeFromString($::FORM{'newcc'});
@@ -896,6 +902,12 @@ The changes made were:
     #
     my @newvalues = SnapShotBug($id);
 
+    # for passing to processmail to ensure that when someone is removed
+    # from one of these fields, they get notified of that fact (if desired)
+    #
+    my $origOwner = "";
+    my $origQaContact = "";
+
     foreach my $c (@::log_columns) {
         my $col = $c;           # We modify it, don't want to modify array
                                 # values in place.
@@ -908,13 +920,24 @@ The changes made were:
             $new = "";
         }
         if ($old ne $new) {
-            if ($col eq 'assigned_to' || $col eq 'qa_contact') {
+
+            # save off the old value for passing to processmail so the old
+            # owner can be notified
+            #
+            if ($col eq 'assigned_to') {
+                $old = ($old) ? DBID_to_name($old) : "";
+                $new = ($new) ? DBID_to_name($new) : "";
+                $origOwner = $old;
+            }
+
+            # ditto for the old qa contact
+            #
+            if ($col eq 'qa_contact') {
                 $old = ($old) ? DBID_to_name($old) : "";
                 $new = ($new) ? DBID_to_name($new) : "";
-                $origCcString .= ",$old"; # make sure to send mail to people
-                                          # if they are going to no longer get
-                                          # updates about this bug.
+                $origQaContact = $old;
             }
+
             if ($col eq 'product') {
                 RemoveVotes($id, 0,
                             "This bug has been moved to a different product");
@@ -930,7 +953,20 @@ The changes made were:
     
     print "<TABLE BORDER=1><TD><H2>Changes to bug $id submitted</H2>\n";
     SendSQL("unlock tables");
-    system("./processmail", "-forcecc", $origCcString, $id, $::FORM{'who'});
+
+    my @ARGLIST = ("./processmail");
+    if ( $removedCcString ne "" ) {
+        push @ARGLIST, ("-forcecc", $removedCcString);
+    }
+    if ( $origOwner ne "" ) {
+        push @ARGLIST, ("-forceowner", $origOwner);
+    }
+    if ( $origQaContact ne "") { 
+        push @ARGLIST, ( "-forceqacontact", $origQaContact);
+    }
+    push @ARGLIST, ($id, $::FORM{'who'});
+    system @ARGLIST;
+
     print "<TD><A HREF=\"show_bug.cgi?id=$id\">Back To BUG# $id</A></TABLE>\n";
 
     foreach my $k (keys(%dependencychanged)) {
index 15b0c636667db80b3e5dc234752e7df7d1f6899e..c1665add75c0d1d8ee5e7f7d1f8fddbfca0ddce6 100755 (executable)
@@ -46,7 +46,11 @@ my @excludedAddresses = ();
 # disable email flag for offline debugging work
 my $enableSendMail = 1;
 
-my @forcecc;
+my %force;
+@{$force{'QAcontact'}} = ();
+@{$force{'Owner'}} = ();
+@{$force{'Reporter'}} = ();
+@{$force{'CClist'}} = ();
 
 sub Lock {
     if ($::lockcount <= 0) {
@@ -548,19 +552,19 @@ sub NewProcessOneBug {
         }
 
     } else {
-    my $count = 0;
-    my @personlist = ($values{'assigned_to'}, $values{'reporter'},
-                      split(/,/, $values{'cc'}),
-                      @voterlist,
-                      @forcecc);
-    if ($values{'qa_contact'}) { push @personlist, $values{'qa_contact'} }
-    for my $person (@personlist) {
-        $count++;
-
-        my $match = "^[^@, ]*@[^@, ]*\.[^@, ]*\$";
-        if ($person !~ /$match/) {
-          $person = $person . Param('emailsuffix');
-        }
+        my $count = 0;
+        my @personlist = ($values{'assigned_to'}, $values{'reporter'},
+                          split(/,/, $values{'cc'}),
+                          @voterlist,
+                          $force{'CClist'});
+        if ($values{'qa_contact'}) { push @personlist, $values{'qa_contact'} }
+        for my $person (@personlist) {
+            $count++;
+
+            my $match = "^[^@, ]*@[^@, ]*\.[^@, ]*\$";
+            if ($person !~ /$match/) {
+                $person = $person . Param('emailsuffix');
+            }
 
             if ( !defined(NewProcessOnePerson($person, $count, \@headerlist, 
                                               \%values, \%defmailhead, 
@@ -715,6 +719,11 @@ sub filterEmailGroup ($$$) {
     my @emailList = split(/,/,$emailList);
     my @filteredList = ();
     
+
+    # the force list for this email group needs to be checked as well
+    #
+    push @emailList, @{$force{$emailGroup}};
+
     foreach my $person (@emailList) {
         
         my $userid;
@@ -762,46 +771,73 @@ sub filterEmailGroup ($$$) {
             push(@filteredList,$person);
         }
         else {
-            
+
+            # the 255 param is here, because without a third param, 
+            # split will trim any trailing null fields, which causes perl 
+            # to eject lots of warnings.  any suitably large number would 
+            # do.
+                
+            my %userFlags = split(/~/, $userFlagString, 255);
+
             # The default condition is to send each person email.
             # If we match the email attribute with the user flag, and
             # they do not want email, then remove them from the list.
-            
-            push(@filteredList,$person);
-            
+
+            push(@filteredList,$person);            
+
             foreach my $attribute (@emailAttributes) {
 
                 my $matchName = 'email' . $emailGroup . $attribute;
-
-                # the 255 param is here, because without a third param, 
-                # split will trim any trailing null fields, which causes perl 
-                # to eject lots of warnings.  any suitably large number would 
-                # do.
-                
-                my %userFlags = split(/~/, $userFlagString, 255);
                 
                 while ((my $flagName, my $flagValue) = each %userFlags) {
                     
-                    if ($flagName !~ /$emailGroup/) { next; }
+                    if ($flagName !~ /$emailGroup/) { 
+                        next; 
+                    }
 
-                                        if ( $flagName eq $matchName 
-                                             && $flagValue ne 'on') {
-                                            pop(@filteredList);
-                                        }
+                    if ( $flagName eq $matchName  && $flagValue ne 'on') {
+                        pop(@filteredList);
+                    }
 
                 } # for each userFlag
 
             } # for each email attribute
 
+            # check to see if the person was removed from this email 
+            # group.
+
+            if ( grep ($_ eq $person, @{$force{$emailGroup}} ) ) {
+
+                # if so, see if they want mail about that
+                #
+                if ( $userFlags{'email' . $emailGroup . 'Removeme'} eq 'on' ) {
+
+                    # we definitely want mail sent to this person, since
+                    # inclusion on a mail takes precedence over the previous
+                    # exclusion
+
+                    # have they been filtered for some other reason?
+                    #
+                    if (@filteredList == $lastCount) {
+                        
+                        # if so, put them back
+                        #
+                        push (@filteredList, $person);
+                    }
+                }
+            }
+
         } # if $userFlagString is valid
 
-        # If email was not sent to the person, then put on excluded
-        # addresses list.
+        # has the person been moved off the filtered list?
+        #
+        if (@filteredList == $lastCount ) {
 
-        if (@filteredList == $lastCount) {
+            # mark them as excluded
+            #
             push (@excludedAddresses,$person);
-        }
-
+        } 
+            
     } # for each person
 
     return @filteredList;
@@ -980,7 +1016,8 @@ sub ProcessOneBug {
         foreach my $v (split(/,/, "$::bug{'cclist'},$::bug{'voterlist'}")) {
             push @combinedcc, $v;
         }
-        push (@combinedcc, (@forcecc));
+        push (@combinedcc, (@{$force{'CClist'}}, @{$force{'QAcontact'}}, 
+                            @{$force{'Reporter'}}, @{$force{'Owner'}}));
         my $cclist = fixaddresses("cc", \@combinedcc);
         my $logstr = "Bug $i $verb";
         if ($tolist ne "" || $cclist ne "") {
@@ -1094,12 +1131,25 @@ if ($#ARGV >= 0 && $ARGV[0] eq "regenerate") {
 if ($#ARGV >= 0 && $ARGV[0] eq "-forcecc") {
     shift(@ARGV);
     foreach my $i (split(/,/, shift(@ARGV))) {
-        push(@forcecc, trim($i));
+        push(@{$force{'CClist'}}, trim($i));
     }
 }
 
+if ($#ARGV >= 0 && $ARGV[0] eq "-forceowner") {
+    shift(@ARGV);
+    @{$force{'Owner'}} = (trim(shift(@ARGV)));
+}
+
+if ($#ARGV >= 0 && $ARGV[0] eq "-forceqacontact") {
+    shift(@ARGV);
+    @{$force{'QAcontact'}} = (trim(shift(@ARGV)));
+}
+
 if (($#ARGV < 0) || ($#ARGV > 1)) {
-    print "Usage error: processmail {bugid} {nametoexclude}\nOr: processmail regenerate\n";
+    print "Usage:\n processmail {bugid} {nametoexclude} " . 
+      "[-forcecc list,of,users]\n             [-forceowner name] " .
+      "[-forceqacontact name]\nor\n processmail regenerate\nor\n" .
+      " processmail rescanall\n";
     exit;
 }
 
index 05d4324d0f9ca7980b95b8dbf1754ea8de4d6493..641317bad7bf8dbb9ae18462b851337525f9117c 100755 (executable)
@@ -49,6 +49,7 @@ my @emailGroups = (
         );
 
 my @emailFlags = (
+        'Removeme',     'If I am removed from that capacity',
         'Comments',     'New Comments',
         'Attachments',  'New Attachments',
         'Status',       'Priority, status, severity, and milestone changes',
@@ -60,6 +61,7 @@ my @emailFlags = (
 
 my $defaultEmailFlagString =
 
+        'emailOwnerRemoveme~'        . 'on~' .
         'emailOwnerComments~'        . 'on~' .
         'emailOwnerAttachments~'     . 'on~' .
         'emailOwnerStatus~'          . 'on~' .
@@ -68,6 +70,7 @@ my $defaultEmailFlagString =
         'emailOwnerCC~'              . 'on~' .
         'emailOwnerOther~'           . 'on~' .
 
+        'emailReporterRemoveme~'     . 'on~' .
         'emailReporterComments~'     . 'on~' .
         'emailReporterAttachments~'  . 'on~' .
         'emailReporterStatus~'       . 'on~' .
@@ -76,6 +79,7 @@ my $defaultEmailFlagString =
         'emailReporterCC~'           . 'on~' .
         'emailReporterOther~'        . 'on~' .
 
+        'emailQAcontactRemoveme~'    . 'on~' .
         'emailQAcontactComments~'    . 'on~' .
         'emailQAcontactAttachments~' . 'on~' .
         'emailQAcontactStatus~'      . 'on~' .
@@ -84,6 +88,7 @@ my $defaultEmailFlagString =
         'emailQAcontactCC~'          . 'on~' .
         'emailQAcontactOther~'       . 'on~' .
 
+        'emailCClistRemoveme~'       . 'on~' .
         'emailCClistComments~'       . 'on~' .
         'emailCClistAttachments~'    . 'on~' .
         'emailCClistStatus~'         . 'on~' .