From 1fbae4ef5a9cca5d889a6fed3b930c1c9d641d6e Mon Sep 17 00:00:00 2001 From: "Dylan William Hardison [:dylan]" Date: Tue, 3 Jun 2014 15:57:28 +0800 Subject: Bug 1000917: Backport upstream bug 489028 to bmo/4.2 to allow user last visit searching --- Bugzilla/User.pm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index d9c3756b0..a796ee765 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -51,9 +51,11 @@ use Bugzilla::Classification; use Bugzilla::Field; use Bugzilla::Group; use Bugzilla::Hook; +use Bugzilla::BugUserLastVisit; use DateTime::TimeZone; use List::Util qw(max); +use List::MoreUtils qw(any); use Scalar::Util qw(blessed); use Storable qw(dclone); use URI; @@ -749,6 +751,28 @@ sub groups { return $self->{groups}; } +sub last_visited { + my ($self) = @_; + + return Bugzilla::BugUserLastVisit->match({ user_id => $self->id }); +} + +sub is_involved_in_bug { + my ($self, $bug) = @_; + my $user_id = $self->id; + my $user_login = $self->login; + + return unless $user_id; + return 1 if $user_id == $bug->assigned_to->id; + return 1 if $user_id == $bug->reporter->id; + + if (Bugzilla->params->{'useqacontact'} and $bug->qa_contact) { + return 1 if $user_id == $bug->qa_contact->id; + } + + return any { $user_login eq $_ } @{ $bug->cc }; +} + # It turns out that calling ->id on objects a few hundred thousand # times is pretty slow. (It showed up as a significant time contributor # when profiling xt/search.t.) So we cache the group ids separately from @@ -2694,6 +2718,35 @@ Returns true if the user can attach tags to comments. i.e. if the 'comment_taggers_group' parameter is set and the user belongs to this group. +=item C + +Returns an arrayref L objects. + +=item C + +Returns true if any of the following conditions are met, false otherwise. + +=over + +=item * + +User is the assignee of the bug + +=item * + +User is the reporter of the bug + +=item * + +User is the QA contact of the bug (if Bugzilla is configured to use a QA +contact) + +=item * + +User is in the cc list for the bug. + +=back + =back =head1 CLASS FUNCTIONS -- cgit v1.2.3-24-g4f1b