summaryrefslogtreecommitdiffstats
path: root/extensions/Voting/Extension.pm
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/Voting/Extension.pm')
-rw-r--r--extensions/Voting/Extension.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/extensions/Voting/Extension.pm b/extensions/Voting/Extension.pm
index a5a3bc11b..aecd2382c 100644
--- a/extensions/Voting/Extension.pm
+++ b/extensions/Voting/Extension.pm
@@ -47,6 +47,10 @@ use constant DEFAULT_VOTES_PER_BUG => 1;
use constant CMT_POPULAR_VOTES => 3;
use constant REL_VOTER => 4;
+BEGIN {
+ *Bugzilla::Bug::user_votes = \&_bug_user_votes;
+}
+
################
# Installation #
################
@@ -122,6 +126,15 @@ sub install_update_db {
# Objects #
###########
+sub _bug_user_votes {
+ my ($self) = @_;
+ return $self->{'user_votes'} if exists $self->{'user_votes'};
+ $self->{'user_votes'} = Bugzilla->dbh->selectrow_array(
+ "SELECT vote_count FROM votes WHERE bug_id = ? AND who = ?",
+ undef, $self->id, Bugzilla->user->id);
+ return $self->{'user_votes'};
+}
+
sub object_columns {
my ($self, $args) = @_;
my ($class, $columns) = @$args{qw(class columns)};
@@ -408,6 +421,7 @@ sub _page_user {
# If a bug_id is given, and we're editing, we'll add it to the votes list.
my $bug_id = $input->{bug_id};
+ $bug_id = $bug_id->[0] if ref($bug_id) eq 'ARRAY';
my $bug = Bugzilla::Bug->check($bug_id) if $bug_id;
my $who_id = $input->{user_id} || $user->id;