From bbd061427b2bf627d3d9357142059a971c883231 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 --- C4/Auth.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index cdc4ba80129..dcaac1dbc2b 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -2355,7 +2355,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; @@ -2365,6 +2366,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