View | Details | Raw Unified | Return to bug 15504
Collapse All | Expand All

(-)a/Koha/Patron.pm (-2 / +2 lines)
Lines 842-848 sub is_active { Link Here
842
    # Enrollment within this period?
842
    # Enrollment within this period?
843
    return 1 if DateTime->compare( dt_from_string( $self->dateenrolled ), $dt ) > -1;
843
    return 1 if DateTime->compare( dt_from_string( $self->dateenrolled ), $dt ) > -1;
844
844
845
    # Last seen? Updated each login when you track patron activity
845
    # Last seen? Updated for tracked patron activities
846
    if ( C4::Context->preference('TrackLastPatronActivityTriggers') ) {
846
    if ( C4::Context->preference('TrackLastPatronActivityTriggers') ) {
847
        return 1 if DateTime->compare( dt_from_string( $self->lastseen ), $dt ) > -1;
847
        return 1 if DateTime->compare( dt_from_string( $self->lastseen ), $dt ) > -1;
848
    }
848
    }
Lines 1189-1195 sub update_lastseen { Link Here
1189
    my $cache_key = "track_activity_" . $self->borrowernumber;
1189
    my $cache_key = "track_activity_" . $self->borrowernumber;
1190
    my $cached    = $cache->get_from_cache($cache_key);
1190
    my $cached    = $cache->get_from_cache($cache_key);
1191
    my $now       = dt_from_string();
1191
    my $now       = dt_from_string();
1192
    return if $cached && $cached eq $now->ymd;
1192
    return $self if $cached && $cached eq $now->ymd;
1193
1193
1194
    $self->lastseen($now)->store;
1194
    $self->lastseen($now)->store;
1195
    $cache->set_in_cache( $cache_key, $now->ymd );
1195
    $cache->set_in_cache( $cache_key, $now->ymd );
(-)a/installer/data/mysql/atomicupdate/bug_15504-add-tracklastpatronactivityoptions.pl (-5 / +9 lines)
Lines 8-28 return { Link Here
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
9
10
        # Get existing value from the TrackLastPatronActivity system preference
10
        # Get existing value from the TrackLastPatronActivity system preference
11
        my ($tracklastactivity) = $dbh->selectrow_array( q|
11
        my ($tracklastactivity) = $dbh->selectrow_array(
12
            q|
12
            SELECT value FROM systempreferences WHERE variable='TrackLastPatronActivity';
13
            SELECT value FROM systempreferences WHERE variable='TrackLastPatronActivity';
13
        |);
14
        |
15
        );
14
16
15
        my $triggers = $tracklastactivity ? 'check_out,connection,login' : '';
17
        my $triggers = $tracklastactivity ? 'check_out,connection,login' : '';
16
        $dbh->do(
18
        $dbh->do(
17
            qq{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('TrackLastPatronActivityTriggers',?,NULL,'If set, the field borrowers.lastseen will be updated every time a patron is does a selected option','multiple') },
19
            qq{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('TrackLastPatronActivityTriggers',?,NULL,'If set, the field borrowers.lastseen will be updated every time a patron performs a selected action','multiple') },
18
            undef, $triggers,
20
            undef, $triggers,
19
        );
21
        );
20
22
21
        say $out "Added system preference 'TrackLastPatronActivityTriggers'";
23
        say $out "Added system preference 'TrackLastPatronActivityTriggers'";
22
24
23
        $dbh->do(q{
25
        $dbh->do(
26
            q{
24
            DELETE FROM systempreferences WHERE variable='TrackLastPatronActivity'
27
            DELETE FROM systempreferences WHERE variable='TrackLastPatronActivity'
25
        });
28
        }
29
        );
26
30
27
        say $out "Removed system preference 'TrackLastPatronActivity'";
31
        say $out "Removed system preference 'TrackLastPatronActivity'";
28
    },
32
    },
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 747-753 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
747
('TraceCompleteSubfields','0','0','Force subject tracings to only match complete subfields.','YesNo'),
747
('TraceCompleteSubfields','0','0','Force subject tracings to only match complete subfields.','YesNo'),
748
('TraceSubjectSubdivisions','0','1','Create searches on all subdivisions for subject tracings.','YesNo'),
748
('TraceSubjectSubdivisions','0','1','Create searches on all subdivisions for subject tracings.','YesNo'),
749
('TrackClicks','0',NULL,'Track links clicked','Integer'),
749
('TrackClicks','0',NULL,'Track links clicked','Integer'),
750
('TrackLastPatronActivityTriggers','',NULL,'If set, the field borrowers.lastseen will be updated everytime a patron is does a selected option','multiple'),
750
('TrackLastPatronActivityTriggers','',NULL,'If set, the field borrowers.lastseen will be updated everytime a patron performs a selected action','multiple'),
751
('TransfersBlockCirc','1',NULL,'Should the transfer modal block circulation staff from continuing scanning items','YesNo'),
751
('TransfersBlockCirc','1',NULL,'Should the transfer modal block circulation staff from continuing scanning items','YesNo'),
752
('TransfersMaxDaysWarning','3',NULL,'Define the days before a transfer is suspected of having a problem','Integer'),
752
('TransfersMaxDaysWarning','3',NULL,'Define the days before a transfer is suspected of having a problem','Integer'),
753
('TransferWhenCancelAllWaitingHolds','0',NULL,'Transfer items when cancelling all waiting holds','YesNo'),
753
('TransferWhenCancelAllWaitingHolds','0',NULL,'Transfer items when cancelling all waiting holds','YesNo'),
(-)a/misc/cronjobs/delete_patrons.pl (-3 / +2 lines)
Lines 39-45 $expired_before = dt_from_string( $expired_before, 'iso' ) Link Here
39
  if $expired_before;
39
  if $expired_before;
40
40
41
if ( $last_seen and not C4::Context->preference('TrackLastPatronActivityTriggers') ) {
41
if ( $last_seen and not C4::Context->preference('TrackLastPatronActivityTriggers') ) {
42
    pod2usage(q{The --last_seen will be ineffective if there are not TrackLastPatronActivityTriggers enabled});
42
    pod2usage(q{The option --last_seen will be ineffective if preference TrackLastPatronActivityTriggers is empty});
43
}
43
}
44
44
45
unless ( $not_borrowed_since or $expired_before or $last_seen or @category_code or $branchcode or $file ) {
45
unless ( $not_borrowed_since or $expired_before or $last_seen or @category_code or $branchcode or $file ) {
Lines 185-191 Delete patrons with an account expired before this date. Link Here
185
185
186
Delete patrons who have not been active since this date.
186
Delete patrons who have not been active since this date.
187
187
188
The system preference TrackLastPatronActivityTriggers must be contain least trigger to use this option.
188
The system preference TrackLastPatronActivityTriggers must contain at least one trigger to use this option.
189
189
190
=item B<--category_code>
190
=item B<--category_code>
191
191
192
- 

Return to bug 15504