From d89e6ea5025094d0ee1561e9ba2ff739e59df26c Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 11 Apr 2013 16:11:09 +0800 Subject: Bug 859313: fix breakage caused by refactoring --- extensions/TagNewUsers/Extension.pm | 39 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'extensions') diff --git a/extensions/TagNewUsers/Extension.pm b/extensions/TagNewUsers/Extension.pm index 4afebeb78..13a517406 100644 --- a/extensions/TagNewUsers/Extension.pm +++ b/extensions/TagNewUsers/Extension.pm @@ -139,11 +139,17 @@ sub object_before_create { # BEGIN { + *Bugzilla::User::comment_count = \&_comment_count; + *Bugzilla::User::creation_ts = \&_creation_ts; *Bugzilla::User::update_comment_count = \&_update_comment_count; *Bugzilla::User::first_patch_bug_id = \&_first_patch_bug_id; *Bugzilla::User::is_new = \&_is_new; + *Bugzilla::User::creation_age = \&_creation_age; } +sub _comment_count { return $_[0]->{comment_count} } +sub _creation_ts { return $_[0]->{creation_ts} } + sub _update_comment_count { my $self = shift; my $dbh = Bugzilla->dbh; @@ -182,14 +188,25 @@ sub _is_new { if ($self->in_group('canconfirm')) { $self->{is_new} = 0; } else { - $self->{is_new} = ($self->{comment_count} <= COMMENT_COUNT) - || ($self->{creation_age} <= PROFILE_AGE); + $self->{is_new} = ($self->comment_count <= COMMENT_COUNT) + || ($self->creation_age <= PROFILE_AGE); } } return $self->{is_new}; } +sub _creation_age { + my ($self) = @_; + + if (!exists $self->{creation_age}) { + my $age = sprintf("%.0f", (time() - str2time($self->creation_ts)) / 86400); + $self->{creation_age} = $age; + } + + return $self->{creation_age}; +} + # # hooks # @@ -202,24 +219,6 @@ sub bug_end_of_update { Bugzilla->user->update_comment_count(); } -sub template_before_process { - my ($self, $args) = @_; - my ($vars, $file) = @$args{qw(vars file)}; - if ($file eq 'bug/comments.html.tmpl') { - - # only users in canconfirm will see the new-to-bugzilla tag - return unless Bugzilla->user->in_group('canconfirm'); - - # calculate if each user that has commented on the bug is new - foreach my $comment (@{$vars->{bug}{comments}}) { - # store the age in days, for the 'new to bugzilla' tooltip - my $user = $comment->author; - my $age = sprintf("%.0f", (time() - str2time($user->{creation_ts})) / 86400); - $user->{creation_age} = $age; - } - } -} - sub mailer_before_send { my ($self, $args) = @_; my $email = $args->{email}; -- cgit v1.2.3-24-g4f1b