Bug 18625: Update lastseen in patron info request
authorColin Campbell <colin.campbell@ptfs-europe.com>
Thu, 18 May 2017 14:59:49 +0000 (15:59 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 11 Apr 2018 19:45:19 +0000 (16:45 -0300)
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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Verified that Patron Info request (63) updates lastseen when the pref has
been enabled.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/SIP/ILS/Patron.pm
C4/SIP/Sip/MsgType.pm

index 81b6268..81036c9 100644 (file)
@@ -441,6 +441,25 @@ sub charge_denied {
     return "Please contact library staff";
 }
 
+=head2 update_lastseen
+
+    $patron->update_lastseen();
+
+    Patron method to update lastseen field in borrower
+    to record that patron has been seen via sip connection
+
+=cut
+
+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;
 
index ac2ac16..9ec126e 100644 (file)
@@ -936,6 +936,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();