From befdcc8f9a30f55e91227bac0ee1813a661002b3 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 4 Oct 2011 18:43:47 -0400 Subject: more porting work --- extensions/Voting/Extension.pm | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'extensions/Voting/Extension.pm') diff --git a/extensions/Voting/Extension.pm b/extensions/Voting/Extension.pm index 44344d7f5..26fb58fa3 100644 --- a/extensions/Voting/Extension.pm +++ b/extensions/Voting/Extension.pm @@ -56,6 +56,21 @@ BEGIN { # Installation # ################ +BEGIN { + *Bugzilla::Bug::votes = \&votes; +} + +sub votes { + my $self = shift; + my $dbh = Bugzilla->dbh; + + return $self->{votes} if exists $self->{votes}; + + $self->{votes} = $dbh->selectrow_array('SELECT votes FROM bugs WHERE bug_id = ?', + undef, $self->id); + return $self->{votes}; +} + sub db_schema_abstract_schema { my ($self, $args) = @_; $args->{'schema'}->{'votes'} = { @@ -676,7 +691,7 @@ sub _modify_bug_votes { } } - $changes->{'too_many_votes'} = \@toomanyvotes_list; + $changes->{'_too_many_votes'} = \@toomanyvotes_list; # 2. too many total votes for a single user. # This part doesn't work in the general case because _remove_votes @@ -723,7 +738,7 @@ sub _modify_bug_votes { } } - $changes->{'too_many_total_votes'} = \@toomanytotalvotes_list; + $changes->{'_too_many_total_votes'} = \@toomanytotalvotes_list; # 3. enough votes to confirm my $bug_list = $dbh->selectcol_arrayref( @@ -736,7 +751,7 @@ sub _modify_bug_votes { my $confirmed = _confirm_if_vote_confirmed($bug_id); push (@updated_bugs, $bug_id) if $confirmed; } - $changes->{'confirmed_bugs'} = \@updated_bugs; + $changes->{'_confirmed_bugs'} = \@updated_bugs; # Now that changes are done, we can send emails to voters. foreach my $msg (@msgs) { @@ -746,7 +761,7 @@ sub _modify_bug_votes { foreach my $bug_id (@updated_bugs) { my $sent_bugmail = Bugzilla::BugMail::Send( $bug_id, { changer => Bugzilla->user }); - $changes->{'confirmed_bugs_sent_bugmail'}->{$bug_id} = $sent_bugmail; + $changes->{'_confirmed_bugs_sent_bugmail'}->{$bug_id} = $sent_bugmail; } } @@ -819,7 +834,7 @@ sub _remove_votes { }; my $voter = new Bugzilla::User($userid); - my $template = Bugzilla->template_inner($voter->settings->{'lang'}->{'value'}); + my $template = Bugzilla->template_inner($voter->setting('lang')); my $msg; $template->process("voting/votes-removed.txt.tmpl", $vars, \$msg); -- cgit v1.2.3-24-g4f1b