]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Fix for bug 95634 - Improvements to Param('voteremovedmail')
authorjake%acutex.net <>
Sat, 25 Aug 2001 07:12:12 +0000 (07:12 +0000)
committerjake%acutex.net <>
Sat, 25 Aug 2001 07:12:12 +0000 (07:12 +0000)
Patch by Matthew Tuck <matty@chariot.net.au>
r= jake@acutex.net

defparams.pl
globals.pl

index 418f56cae157fd89c00c1e05d8e1636ea17d5cea..46a00b78f149b2470ac055e691fbb780bea14929 100644 (file)
@@ -555,17 +555,19 @@ DefParam("emailsuffix",
 
 
 DefParam("voteremovedmail",
-q{This is a mail message to send to anyone who gets a vote removed from a bug for any reason.  %to% gets replaced by a comma-separated list of people who used to be voting for this bug.  %bugid% gets replaced by the bug number.  %reason% gets replaced by a short reason describing why the vote was removed.  %count% is how many votes got removed.%<i>anythingelse</i>% gets replaced by the definition of that parameter (as defined on this page).},
+q{This is a mail message to send to anyone who gets a vote removed from a bug for any reason.  %to% gets replaced by the person who used to be voting for this bug.  %bugid% gets replaced by the bug number.  %reason% gets replaced by a short reason describing why the vote(s) were removed.  %votesremoved%, %votesold% and %votesnew% is the number of votes removed, before and after respectively.  %votesremovedtext%, %votesoldtext% and %votesnewtext% are these as sentences, eg "You had 2 votes on this bug."  %count% is also supported for backwards compatibility.  %<i>anythingelse</i>% gets replaced by the definition of that parameter (as defined on this page).},
          "l",
 "From: bugzilla-daemon
 To: %to%
-Subject: [Bug %bugid%] Your vote has been removed from this bug
+Subject: [Bug %bugid%] Some or all of your votes have been removed.
 
-You used to have a vote on bug %bugid%, but it has been removed.
+Some or all of your votes have been removed from bug %bugid%.
 
-Reason: %reason%
+%votesoldtext%
+
+%votesnewtext%
 
-Votes removed: %count%
+Reason: %reason%
 
 %urlbase%show_bug.cgi?id=%bugid%
 ");
index a3ea97c401547844d3da7d602458a1a051d7c2ab..f4dc3141946dcb9f9402060e19c5fc67c1423427 100644 (file)
@@ -1195,33 +1195,45 @@ sub RemoveVotes {
             $whopart);
     my @list;
     while (MoreSQLData()) {
-        my ($name, $userid, $count, $votesperuser, $maxvotesperbug) = (FetchSQLData());
-        push(@list, [$name, $userid, $count, $votesperuser, $maxvotesperbug]);
+        my ($name, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = (FetchSQLData());
+        push(@list, [$name, $userid, $oldvotes, $votesperuser, $maxvotesperbug]);
     }
     if (0 < @list) {
         foreach my $ref (@list) {
-            my ($name, $userid, $count, $votesperuser, $maxvotesperbug) = (@$ref);
+            my ($name, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = (@$ref);
+            my $s;
+
+            $maxvotesperbug = $votesperuser if ($votesperuser < $maxvotesperbug);
 
             # If this product allows voting and the user's votes are in
             # the acceptable range, then don't do anything.
-            next if $votesperuser && $count <= $maxvotesperbug;
+            next if $votesperuser && $oldvotes <= $maxvotesperbug;
 
             # If the user has more votes on this bug than this product
             # allows, then reduce the number of votes so it fits
             my $newvotes = $votesperuser ? $maxvotesperbug : 0;
+
+            my $removedvotes = $oldvotes - $newvotes;
+
+            $s = $oldvotes == 1 ? "" : "s";
+            my $oldvotestext = "You had $oldvotes vote$s on this bug.";
+
+            $s = $removedvotes == 1 ? "" : "s";
+            my $removedvotestext = "You had $removedvotes vote$s removed from this bug.";
+
+            my $newvotestext;
             if ($newvotes) {
                 SendSQL("UPDATE votes SET count = $newvotes " .
                         "WHERE bug_id = $id AND who = $userid");
-                my $s = $newvotes == 1 ? "" : "s";
-                $count = ($count - $newvotes) . 
-                         "\n    You still have $newvotes vote$s on this bug";
+                $s = $newvotes == 1 ? "" : "s";
+                $newvotestext = "You still have $newvotes vote$s on this bug."
             } else {
                 SendSQL("DELETE FROM votes WHERE bug_id = $id AND who = $userid");
-                $count = "$count\n    You have no more votes remaining on this bug";
+                $newvotestext = "You have no more votes remaining on this bug.";
             }
 
             # Notice that we did not make sure that the user fit within the $votesperuser
-            # range.  This is considered to be an acceptable alternative to loosing votes
+            # range.  This is considered to be an acceptable alternative to losing votes
             # during product moves.  Then next time the user attempts to change their votes,
             # they will be forced to fit within the $votesperuser limit.
 
@@ -1233,10 +1245,21 @@ sub RemoveVotes {
             }
             if (open(SENDMAIL, "|/usr/lib/sendmail $sendmailparm -t")) {
                 my %substs;
+
                 $substs{"to"} = $name;
                 $substs{"bugid"} = $id;
                 $substs{"reason"} = $reason;
-                $substs{"count"} = $count;
+
+                $substs{"votesremoved"} = $removedvotes;
+                $substs{"votesold"} = $oldvotes;
+                $substs{"votesnew"} = $newvotes;
+
+                $substs{"votesremovedtext"} = $removedvotestext;
+                $substs{"votesoldtext"} = $oldvotestext;
+                $substs{"votesnewtext"} = $newvotestext;
+
+                $substs{"count"} = $removedvotes . "\n    " . $newvotestext;
+
                 my $msg = PerformSubsts(Param("voteremovedmail"),
                                         \%substs);
                 print SENDMAIL $msg;