summaryrefslogtreecommitdiffstats
path: root/Bugzilla/User.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2014-04-07 08:41:11 +0200
committerDylan William Hardison <dylan@hardison.net>2014-04-22 22:37:52 +0200
commiteab44b1aad3f243dd69b1d30519b73a1e537fda2 (patch)
tree45e67469b8c6905a545dc5f2bd8bbe03bd41ea7c /Bugzilla/User.pm
parent36f56bd9112c2e930fb5bdbee3b5c89334de5247 (diff)
downloadbugzilla-eab44b1aad3f243dd69b1d30519b73a1e537fda2.tar.gz
bugzilla-eab44b1aad3f243dd69b1d30519b73a1e537fda2.tar.xz
Bug 489028 - Record last-visited time of bugs when logged in
r=glob a=justdave
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r--Bugzilla/User.pm53
1 files changed, 53 insertions, 0 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 5cebe728b..0b644a3b4 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -19,9 +19,11 @@ use Bugzilla::Product;
use Bugzilla::Classification;
use Bugzilla::Field;
use Bugzilla::Group;
+use Bugzilla::BugUserLastVisit;
use DateTime::TimeZone;
use List::Util qw(max);
+use List::MoreUtils qw(any);
use Scalar::Util qw(blessed);
use URI;
use URI::QueryParam;
@@ -729,6 +731,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
@@ -2767,6 +2791,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<last_visited>
+
+Returns an arrayref L<Bugzilla::BugUserLastVisit> objects.
+
+=item C<is_involved_in_bug($bug)>
+
+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