From d9fd2c8e27fc787b99639e87f5d6825b6746bcef 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 --- C4/Auth.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 9b298eed87..ab39ef366d 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -2354,7 +2354,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; @@ -2364,6 +2365,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.41.0