From 30f80cb40e59f1b7d173e01ab0c1cb508c8a99be Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 14 Jun 2023 14:11:08 +0000 Subject: [PATCH] Bug 15504: Update track_login_daily to accept triggers This patch adds triggers to track_login_daily so that it only tracks activity when that trigger is active Signed-off-by: Martin Renvoize Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- C4/Auth.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 3623b439c5..ae62b1bca0 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -2358,7 +2358,8 @@ Wraps the call to $patron->track_login, the method used to update borrowers.last sub track_login_daily { my $userid = shift; - return if !$userid || !C4::Context->preference('TrackLastPatronActivity'); + my $activity = shift; + return if !$userid || !$activity || !C4::Context->preference('TrackLastPatronActivity'); my $cache = Koha::Caches->get_instance(); my $cache_key = "track_login_" . $userid; @@ -2368,6 +2369,10 @@ sub track_login_daily { my $patron = Koha::Patrons->find({ userid => $userid }); return unless $patron; + + my $tracked_activities = { map { (lc $_, 1); } split /\s*\,\s*/, C4::Context->preference('TrackLastPatronActivityTriggers') }; + return unless $tracked_activities->{$activity}; + $patron->track_login; $cache->set_in_cache( $cache_key, $today ); } -- 2.42.0