summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.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/Bug.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/Bug.pm')
-rw-r--r--Bugzilla/Bug.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index b53847790..b66ad1e26 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -28,6 +28,7 @@ use Bugzilla::Group;
use Bugzilla::Status;
use Bugzilla::Comment;
use Bugzilla::BugUrl;
+use Bugzilla::BugUserLastVisit;
use List::MoreUtils qw(firstidx uniq part);
use List::Util qw(min max first);
@@ -4081,6 +4082,23 @@ sub LogActivityEntry {
}
}
+# Update bug_user_last_visit table
+sub update_user_last_visit {
+ my ($self, $user, $last_visit_ts) = @_;
+ my $lv = Bugzilla::BugUserLastVisit->match({ bug_id => $self->id,
+ user_id => $user->id })->[0];
+
+ if ($lv) {
+ $lv->set(last_visit_ts => $last_visit_ts);
+ $lv->update;
+ }
+ else {
+ Bugzilla::BugUserLastVisit->create({ bug_id => $self->id,
+ user_id => $user->id,
+ last_visit_ts => $last_visit_ts });
+ }
+}
+
# Convert WebService API and email_in.pl field names to internal DB field
# names.
sub map_fields {
@@ -4407,6 +4425,7 @@ sub _multi_select_accessor {
1;
+__END__
=head1 B<Methods>
=over
@@ -4415,6 +4434,11 @@ sub _multi_select_accessor {
Ensures the accessors for custom fields are always created.
+=item C<update_user_last_visit($user, $last_visit)>
+
+Creates or updates a L<Bugzilla::BugUserLastVisit> for this bug and the supplied
+$user, the timestamp given as $last_visit.
+
=back
=head1 B<Methods in need of POD>