From: terry%mozilla.org <> Date: Fri, 8 Oct 1999 06:54:47 +0000 (+0000) Subject: Added the ability for users to "vote" on which bugs they think should X-Git-Tag: bugzilla-2.8~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6f80310afc00cf7d5114e638cbaaefde3914da0;p=thirdparty%2Fbugzilla.git Added the ability for users to "vote" on which bugs they think should be fixed. --- diff --git a/CHANGES b/CHANGES index 2c5f2994f4..b71d84a871 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,13 @@ query the CVS tree. For example, will tell you what has been changed in the last week. +10/7/99 Added voting ability. You must run the new script +"makevotestable.sh". You must also feed the following to mysql: + + alter table products add column votesperuser smallint not null; + + + 9/15/99 Apparently, newer alphas of MySQL won't allow you to have "when" as a column name. So, I have had to rename a column in the bugs_activity table. You must feed the below to mysql or you won't diff --git a/README b/README index a335dfd896..4030c3d1a5 100644 --- a/README +++ b/README @@ -282,6 +282,7 @@ command. Order does not matter, but this one is fine: ./makeproducttable.sh ./makeprofilestable.sh ./makeversiontable.sh + ./makevotestable.sh You may want to edit the scripts; once bugs are entered it gets very hard to make changes. Think carefully about how you want database users to describe bugs. Here's one diff --git a/bug_form.pl b/bug_form.pl index c563daf06c..665d82f62b 100644 --- a/bug_form.pl +++ b/bug_form.pl @@ -111,7 +111,7 @@ my $id = $::FORM{'id'}; my $query = " select - bug_id, + bugs.bug_id, product, version, rep_platform, @@ -130,10 +130,12 @@ select status_whiteboard, date_format(creation_ts,'Y-m-d'), groupset, - delta_ts -from bugs -where bug_id = $id -and bugs.groupset & $::usergroupset = bugs.groupset"; + delta_ts, + sum(votes.count) +from bugs left join votes using(bug_id) +where bugs.bug_id = $id +and bugs.groupset & $::usergroupset = bugs.groupset +group by bugs.bug_id"; SendSQL($query); my %bug; @@ -145,7 +147,7 @@ if (@row = FetchSQLData()) { "bug_severity", "component", "assigned_to", "reporter", "bug_file_loc", "short_desc", "target_milestone", "qa_contact", "status_whiteboard", "creation_ts", - "groupset", "delta_ts") { + "groupset", "delta_ts", "votes") { $bug{$field} = shift @row; if (!defined $bug{$field}) { $bug{$field} = ""; @@ -368,6 +370,16 @@ if (Param("usedependencies")) { print "\n"; } +if ($::prodmaxvotes{$bug{'product'}}) { + print qq{ + +
Votes for bug $id: +$bug{'votes'} +   Vote for this bug +
+}; +} + print "
Additional Comments: diff --git a/buglist.cgi b/buglist.cgi index d780e2af2d..6c8e6ef169 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -173,6 +173,7 @@ DefCol("version", "substring(bugs.version, 1, 5)", "Vers", "bugs.version"); DefCol("os", "substring(bugs.op_sys, 1, 4)", "OS", "bugs.op_sys"); DefCol("target_milestone", "bugs.target_milestone", "TargetM", "bugs.target_milestone"); +DefCol("votes", "sum(votes.count)", "Votes", "sum(votes.count)"); my @collist; if (defined $::COOKIE{'COLUMNLIST'}) { @@ -208,11 +209,12 @@ bugs.bug_status"; $query .= " -from bugs, +from bugs left join votes using(bug_id), profiles assign, profiles report left join profiles qacont on bugs.qa_contact = qacont.userid, versions projector + where bugs.assigned_to = assign.userid and bugs.reporter = report.userid and bugs.product = projector.program @@ -226,7 +228,7 @@ if ((defined $::FORM{'emailcc1'} && $::FORM{'emailcc1'}) || # We need to poke into the CC table. Do weird SQL left join stuff so that # we can look in the CC table, but won't reject any bugs that don't have # any CC fields. - $query =~ s/bugs,/bugs left join cc using (bug_id) left join profiles ccname on cc.who = ccname.userid,/; + $query =~ s/bugs left join,/bugs left join cc using (bug_id) left join profiles ccname on cc.who = ccname.userid left join,/; } if (defined $::FORM{'sql'}) { @@ -431,6 +433,8 @@ foreach my $f ("short_desc", "long_desc", "bug_file_loc", } +$query .= "group by bugs.bug_id\n"; + if (defined $::FORM{'order'} && $::FORM{'order'} ne "") { $query .= "order by "; ORDER: for ($::FORM{'order'}) { diff --git a/changepassword.cgi b/changepassword.cgi index 068180fbdd..c6d408562e 100755 --- a/changepassword.cgi +++ b/changepassword.cgi @@ -83,6 +83,8 @@ On which of these bugs would you like email notification of changes?
+Review your votes +
"; navigation_header(); exit; diff --git a/colchange.cgi b/colchange.cgi index 2dd1b350b8..eb3eafd39d 100755 --- a/colchange.cgi +++ b/colchange.cgi @@ -31,7 +31,7 @@ print "Content-type: text/html\n"; my @masterlist = ("opendate", "changeddate", "severity", "priority", "platform", "owner", "reporter", "status", "resolution", - "component", "product", "version", "project", "os"); + "component", "product", "version", "project", "os", "votes"); if (Param("usetargetmilestone")) { push(@masterlist, "target_milestone"); diff --git a/defparams.pl b/defparams.pl index a7c4ba0607..7efdc40539 100644 --- a/defparams.pl +++ b/defparams.pl @@ -339,5 +339,20 @@ 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. %anythingelse% gets replaced by the definition of thatparameter (as defined on this page).}, + "l", +"From: bugzilla-daemon +To: %to% +Subject: [Bug %bugid%] Your vote has been removed from this bug + +You used to have a vote on bug %bugid%, but it has been removed. + +Reason: %reason% + +%urlbase%show_bug.cgi?id=%bugid% +"); + + 1; diff --git a/doeditcomponents.cgi b/doeditcomponents.cgi index bfe09e93df..7f138f285d 100755 --- a/doeditcomponents.cgi +++ b/doeditcomponents.cgi @@ -96,12 +96,12 @@ GetVersionTable(); my $prodcode = "P000"; foreach my $product (@::legal_product) { - SendSQL("select description, milestoneurl, disallownew from products where product='$product'"); + SendSQL("select description, milestoneurl, disallownew, votesperuser from products where product='$product'"); my @row = FetchSQLData(); if (!@row) { next; } - my ($description, $milestoneurl, $disallownew) = (@row); + my ($description, $milestoneurl, $disallownew, $votesperuser) = (@row); $prodcode++; Check($product, $::FORM{"prodcode-$prodcode"}); @@ -111,6 +111,7 @@ foreach my $product (@::legal_product) { DoOne($milestoneurl, "$prodcode-milestoneurl", $where); } DoOne($disallownew, "$prodcode-disallownew", $where); + DoOne($votesperuser, "$prodcode-votesperuser", $where); SendSQL("select value, initialowner, initialqacontact, description from components where program=" . SqlQuote($product) . " order by value"); my $c = 0; diff --git a/doeditvotes.cgi b/doeditvotes.cgi new file mode 100755 index 0000000000..03c4c1d88e --- /dev/null +++ b/doeditvotes.cgi @@ -0,0 +1,102 @@ +#!/usr/bonsaitools/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public License +# Version 1.0 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations +# under the License. +# +# The Original Code is the Bugzilla Bug Tracking System. +# +# The Initial Developer of the Original Code is Netscape Communications +# Corporation. Portions created by Netscape are Copyright (C) 1998 +# Netscape Communications Corporation. All Rights Reserved. +# +# Contributor(s): Terry Weissman + +use diagnostics; +use strict; + +require "CGI.pl"; + +confirm_login(); + +print "Content-type: text/html\n\n"; + +ConnectToDatabase(); +GetVersionTable(); + +my $who = DBNameToIdAndCheck($::COOKIE{'Bugzilla_login'}); + +if ($who ne $::FORM{'who'}) { + PutHeader("Wrong login."); + print "The login info got confused. If you want to adjust the votes\n"; + print "for $::COOKIE{'Bugzilla_login'}, then please\n"; + print "click here.
\n"; + navigation_header(); + exit(); +} + +my @buglist = grep {/^\d+$/} keys(%::FORM); + +if (0 == @buglist) { + PutHeader("Oops?"); + print "Something got confused. Please click Back and try again."; + navigation_header(); + exit(); +} + +foreach my $id (@buglist) { + $::FORM{$id} = trim($::FORM{$id}); + if ($::FORM{$id} !~ /\d+/ || $::FORM{$id} < 0) { + PutHeader("Numbers only, please"); + print "Only use numeric values for your bug votes.\n"; + print "Please click Back and try again.
\n"; + navigation_header(); + exit(); + } +} + +SendSQL("select bug_id, product from bugs where bug_id = " . + join(" or bug_id = ", @buglist)); + +my %prodcount; + +while (MoreSQLData()) { + my ($id, $prod) = (FetchSQLData()); + if (!defined $prodcount{$prod}) { + $prodcount{$prod} = 0; + } + $prodcount{$prod} += $::FORM{$id}; +} + +foreach my $prod (keys(%prodcount)) { + if ($prodcount{$prod} > $::prodmaxvotes{$prod}) { + PutHeader("Don't overstuff!", "Illegal vote"); + print "You may only use $::prodmaxvotes{$prod} votes for bugs in the\n"; + print "$prod product, but you are using $prodcount{$prod}.\n"; + print "Please click Back and try again.
\n"; + navigation_header(); + exit(); + } +} + +SendSQL("delete from votes where who = $who"); +foreach my $id (@buglist) { + if ($::FORM{$id} > 0) { + SendSQL("insert into votes (who, bug_id, count) values ($who, $id, $::FORM{$id})"); + } +} + +PutHeader("Voting tabulated", "Voting tabulated", $::COOKIE{'Bugzilla_login'}); +print "Your votes have been recorded.\n"; +print qq{

Review your votes


\n}; +navigation_header(); +exit(); + + diff --git a/editcomponents.cgi b/editcomponents.cgi index a7e1e660ed..e4b6a23dea 100755 --- a/editcomponents.cgi +++ b/editcomponents.cgi @@ -59,12 +59,12 @@ GetVersionTable(); my $prodcode = "P000"; foreach my $product (@::legal_product) { - SendSQL("select description, milestoneurl, disallownew from products where product='$product'"); + SendSQL("select description, milestoneurl, disallownew, votesperuser from products where product='$product'"); my @row = FetchSQLData(); if (!@row) { next; } - my ($description, $milestoneurl, $disallownew) = (@row); + my ($description, $milestoneurl, $disallownew, $votesperuser) = (@row); $prodcode++; print "\n"; @@ -77,6 +77,9 @@ foreach my $product (@::legal_product) { print "\n"; } + print qq{Maximum votes per user:\n}; + print qq{}; + print qq{\n}; my $check0 = !$disallownew ? " SELECTED" : ""; my $check1 = $disallownew ? " SELECTED" : ""; print ""; + } + print qq{ + + +$id +$strike$summary$endstrike +$count + +}; + } + my $plural = (($sum == 1) ? "" : "s"); + print "$sum vote$plural used out of\n"; + print "$::prodmaxvotes{$product} allowed.\n"; + } + print "\n"; + if ($canedit) { + print qq{\n}; + print "
To change your votes, type in new numbers (using zero to\n"; + print "mean no votes), and then click Submit.\n"; + } + print ""; + print "\n"; + SendSQL("delete from votes where count <= 0"); + SendSQL("unlock tables"); +} + +print qq{Help! I don't understand this voting stuff}; + +navigation_header(); + diff --git a/votehelp.html b/votehelp.html index 46b7de744f..da76fa91ef 100644 --- a/votehelp.html +++ b/votehelp.html @@ -48,5 +48,10 @@ To vote for a bug: may rebalance your votes as necessary. +You will automatically get email notifying you of any changes that +occur on bugs you vote for. + +

+ You may review your votes at any time by clicking on the "Change your password or preferences" link at the bottom of the query page.