Lines 74-80
BEGIN {
Link Here
|
74 |
|
74 |
|
75 |
@EXPORT_OK = qw( |
75 |
@EXPORT_OK = qw( |
76 |
checkauth check_api_auth get_session check_cookie_auth checkpw checkpw_internal checkpw_hash |
76 |
checkauth check_api_auth get_session check_cookie_auth checkpw checkpw_internal checkpw_hash |
77 |
get_all_subpermissions get_cataloguing_page_permissions get_user_subpermissions track_login_daily in_iprange |
77 |
get_all_subpermissions get_cataloguing_page_permissions get_user_subpermissions in_iprange |
78 |
get_template_and_user haspermission create_basic_session |
78 |
get_template_and_user haspermission create_basic_session |
79 |
); |
79 |
); |
80 |
|
80 |
|
Lines 1319-1325
sub checkauth {
Link Here
|
1319 |
)); |
1319 |
)); |
1320 |
} |
1320 |
} |
1321 |
|
1321 |
|
1322 |
track_login_daily( $userid, 'login' ); |
1322 |
my $patron = Koha::Patrons->find({ userid => $userid }); |
|
|
1323 |
$patron->update_lastseen('login'); |
1323 |
|
1324 |
|
1324 |
# In case, that this request was a login attempt, we want to prevent that users can repost the opac login |
1325 |
# In case, that this request was a login attempt, we want to prevent that users can repost the opac login |
1325 |
# request. We therefore redirect the user to the requested page again without the login parameters. |
1326 |
# request. We therefore redirect the user to the requested page again without the login parameters. |
Lines 2345-2379
sub getborrowernumber {
Link Here
|
2345 |
return 0; |
2346 |
return 0; |
2346 |
} |
2347 |
} |
2347 |
|
2348 |
|
2348 |
=head2 track_login_daily |
|
|
2349 |
|
2350 |
track_login_daily( $userid ); |
2351 |
|
2352 |
Wraps the call to $patron->track_login, the method used to update borrowers.lastseen. We only call track_login once a day. |
2353 |
|
2354 |
=cut |
2355 |
|
2356 |
sub track_login_daily { |
2357 |
my $userid = shift; |
2358 |
my $activity = shift; |
2359 |
return if !$userid || !$activity || !C4::Context->preference('TrackLastPatronActivity'); |
2360 |
|
2361 |
my $cache = Koha::Caches->get_instance(); |
2362 |
my $cache_key = "track_login_" . $userid; |
2363 |
my $cached = $cache->get_from_cache($cache_key); |
2364 |
my $today = dt_from_string()->ymd; |
2365 |
return if $cached && $cached eq $today; |
2366 |
|
2367 |
my $patron = Koha::Patrons->find({ userid => $userid }); |
2368 |
return unless $patron; |
2369 |
|
2370 |
my $tracked_activities = { map { (lc $_, 1); } split /\s*\,\s*/, C4::Context->preference('TrackLastPatronActivityTriggers') }; |
2371 |
return unless $tracked_activities->{$activity}; |
2372 |
|
2373 |
$patron->track_login; |
2374 |
$cache->set_in_cache( $cache_key, $today ); |
2375 |
} |
2376 |
|
2377 |
END { } # module clean-up code here (global destructor) |
2349 |
END { } # module clean-up code here (global destructor) |
2378 |
1; |
2350 |
1; |
2379 |
__END__ |
2351 |
__END__ |