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

(-)a/Koha/Template/Plugin/ViewLog.pm (+43 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::ViewLog;
2
3
=head1 NAME
4
5
Koha::Template::Plugin::ViewLog - A module for logging when a particular template is rendered and viewed by staff.
6
7
=head1 DESCRIPTION
8
9
This plugin contains methods to log when sensitive information is viewed by staff in order to mitigate or aid in
10
investigating GDPR personal data breach incidents.
11
12
=head2 Methods
13
14
=head3 log_patron_view
15
16
[% Desks.log_patron_view(borrowernumber) %]
17
18
Writes to action log that a patron with C<borrowernumber> has been viewd by the current user.
19
20
=cut
21
22
use Modern::Perl;
23
use C4::Context;
24
use C4::Log qw( logaction );
25
26
use Template::Plugin;
27
use base qw( Template::Plugin );
28
29
sub log_patron_view {
30
    my ($self, $patron_borrowernumber ) = @_;
31
    if (C4::Context->preference('PatronViewLog')) {
32
        my $ip = $ENV{REMOTE_ADDR};
33
        my $uri = $ENV{REQUEST_URI};
34
        logaction(
35
            'MEMBERS',
36
            'VIEW',
37
            $patron_borrowernumber,
38
            "borrowernumber: $patron_borrowernumber, ip: $ip, uri: $uri"
39
        );
40
    }
41
};
42
43
1;
(-)a/installer/data/mysql/atomicupdate/bug-30279-log-patron-view.pl (+12 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "30279",
5
    description => "Add' PatronViewLog' system preference",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        $dbh->do(q{ INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('PatronViewLog', '0', NULL, 'If enabled, log when patron personal data is viewed in staff interface', 'YesNo') });
10
        say $out "System preference added";
11
    },
12
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 528-533 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
528
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
528
('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'),
529
('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate their account.','YesNo'),
529
('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate their account.','YesNo'),
530
('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'),
530
('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'),
531
('PatronViewLog','0',NULL,'If enabled, log when patron personal data is viewed in staff interface','YesNo'),
531
('PatronQuickAddFields',  '', NULL ,  'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry',  'Free' ),
532
('PatronQuickAddFields',  '', NULL ,  'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry',  'Free' ),
532
('PhoneNotification','0',NULL,'If ON, enables generation of phone notifications to be sent by plugins','YesNo'),
533
('PhoneNotification','0',NULL,'If ON, enables generation of phone notifications to be sent by plugins','YesNo'),
533
('PrefillGuaranteeField', 'phone,email,streetnumber,address,city,state,zipcode,country', NULL, 'Prefill these fields in guarantee member entry form from guarantor patron record', 'Multiple'),
534
('PrefillGuaranteeField', 'phone,email,streetnumber,address,city,state,zipcode,country', NULL, 'Prefill these fields in guarantee member entry form from guarantor patron record', 'Multiple'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (+2 lines)
Lines 1-7 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE ViewLog %]
3
[% PROCESS 'member-display-address-style.inc' %]
4
[% PROCESS 'member-display-address-style.inc' %]
4
[% IF ( patron.borrowernumber ) %]
5
[% IF ( patron.borrowernumber ) %]
6
[% ViewLog.log_patron_view(patron.borrowernumber) %]
5
[% SET patron_is_staff = patron.has_permission({ 'catalogue' => 1 }) %]
7
[% SET patron_is_staff = patron.has_permission({ 'catalogue' => 1 }) %]
6
[% SET patron_is_superlibrarian = patron.is_superlibrarian %]
8
[% SET patron_is_superlibrarian = patron.is_superlibrarian %]
7
[% SET patron_type_class = 'is-not-staff' %]
9
[% SET patron_type_class = 'is-not-staff' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref (-1 / +6 lines)
Lines 108-113 Logging: Link Here
108
                  1: Log
108
                  1: Log
109
                  0: "Don't log"
109
                  0: "Don't log"
110
            - " changes to news entries and other contents managed in the news tool."
110
            - " changes to news entries and other contents managed in the news tool."
111
        -
112
            - pref: PatronViewLog
113
              choices:
114
                  1: Log
115
                  0: "Don't log"
116
            - " when patron personal information is viewed in the staff interface."
111
    Debugging:
117
    Debugging:
112
        -
118
        -
113
            - pref: DumpTemplateVarsIntranet
119
            - pref: DumpTemplateVarsIntranet
114
- 

Return to bug 30279