From c26e3f4534cebb136cd85399792d8accffca7748 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 18 May 2017 15:59:49 +0100 Subject: [PATCH] Bug 18625 update lastseen in patron info request Many services use SIP patron req info to validate a patron against the koha database. If recording lastseen sites will also want to record that the user has accessed these library facilities although they have not logged into koha --- C4/SIP/ILS/Patron.pm | 11 +++++++++++ C4/SIP/Sip/MsgType.pm | 1 + 2 files changed, 12 insertions(+) diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm index 0012776..35c62b6 100644 --- a/C4/SIP/ILS/Patron.pm +++ b/C4/SIP/ILS/Patron.pm @@ -24,6 +24,7 @@ use C4::Items qw( GetBarcodeFromItemnumber GetItemnumbersForBiblio); use C4::Auth qw(checkpw); use Koha::Libraries; +use Koha::Patrons; our $kp; # koha patron @@ -411,6 +412,16 @@ sub charge_denied { return "Please contact library staff"; } +sub update_lastseen { + my $self = shift; + my $p; + if (C4::Context->preference('TrackLastPatronActivity') + && $p = Koha::Patrons->find({ borrowernumber => $self->{borrowernumber} })) { + $p->track_login; + } + return; +} + sub _get_address { my $patron = shift; diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 7a1a1e3..9506fb9 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -932,6 +932,7 @@ sub handle_patron_info { $resp = (PATRON_INFO_RESP); if ($patron) { + $patron->update_lastseen(); $resp .= patron_status_string($patron); $resp .= ( defined($lang) and length($lang) == 3 ) ? $lang : $patron->language; $resp .= timestamp(); -- 2.9.4