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

(-)a/installer/data/mysql/atomicupdate/bug_23260.perl (-2 / +7 lines)
Lines 3-8 if( CheckVersion( $DBversion ) ) { Link Here
3
    # you can use $dbh here like:
3
    # you can use $dbh here like:
4
    $dbh->do( "ALTER TABLE items_last_borrower MODIFY COLUMN `borrowernumber` int(11) default NULL" );
4
    $dbh->do( "ALTER TABLE items_last_borrower MODIFY COLUMN `borrowernumber` int(11) default NULL" );
5
5
6
    SetVersion( $DBversion );
6
    $dbh->do(q{
7
    print "Upgrade to $DBversion done (Bug 23260 - make borrowernumber from items_last_borrower nullable)\n";
7
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
8
        ('AnonymiseLastBorrower','0',NULL,'If enabled, anonymise item\'s last borrower','YesNo'),
9
        ('AnonymiseLastBorrowerDays','0',NULL,'Item\'s last borrower older than this preference will be anonymised','Integer')
10
    });
11
12
    NewVersion( $DBversion, 23260, "Make borrowernumber from items_last_borrower nullable, and add AnonymiseLastBorrower and AnonymiseLastBorrowerDays preferences");
8
}
13
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+2 lines)
Lines 54-59 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
54
('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'),
54
('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'),
55
('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'),
55
('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'),
56
('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
56
('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
57
('AnonymiseLastBorrower','0',NULL,'If enabled, anonymise item\'s last borrower','YesNo'),
58
('AnonymiseLastBorrowerDays','0',NULL,'Item\'s last borrower older than this preference will be anonymised','Integer'),
57
('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''),
59
('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''),
58
('ApplyFrameworkDefaults', 'new', 'new|duplicate|changed|imported', 'Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework, or when importing a record', 'multiple'),
60
('ApplyFrameworkDefaults', 'new', 'new|duplicate|changed|imported', 'Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework, or when importing a record', 'multiple'),
59
('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'),
61
('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+8 lines)
Lines 408-413 Patrons: Link Here
408
           type: modaljs
408
           type: modaljs
409
           initiator: populateCookieConsentedJS
409
           initiator: populateCookieConsentedJS
410
           processor: prepareCookieConsentedJS
410
           processor: prepareCookieConsentedJS
411
     -
412
         - pref: AnonymiseLastBorrower
413
           choices:
414
               yes: Anonymise
415
               no: "Don't anonymise"
416
         - " item's last borrower after "
417
         - pref: AnonymiseLastBorrowerDays
418
         - days.
411
    Security:
419
    Security:
412
     -
420
     -
413
         - Login passwords for staff and patrons must be at least
421
         - Login passwords for staff and patrons must be at least
(-)a/misc/cronjobs/anonymise_last_borrowers.pl (-1 / +75 lines)
Line 0 Link Here
0
- 
1
2
#!/usr/bin/perl
3
4
# Copyright 2011, ByWater Solutions.
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# Koha is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21
use strict;
22
use warnings;
23
use Carp;
24
25
BEGIN {
26
27
    # find Koha's Perl modules
28
    # test carefully before changing this
29
    use FindBin;
30
    eval { require "$FindBin::Bin/../kohalib.pl" };
31
}
32
33
use Koha::Script -cron;
34
use C4::Context;
35
use Koha::Patrons;
36
use Getopt::Long;
37
use C4::Log;
38
39
40
sub usage {
41
    print STDERR <<USAGE;
42
Usage: $0  --days DAYS  [-h|--help]
43
   -v --verbose       gives a little more information
44
   -h --help          prints this help message, and exits, ignoring all
45
                      other options
46
Note: If the system preference 'AnonymousPatron' is not defined, NULL will be used.
47
USAGE
48
    exit $_[0];
49
}
50
51
my ( $help, $days, $verbose );
52
53
GetOptions(
54
    'h|help'       => \$help,
55
    'v|verbose'    => \$verbose,
56
) || usage(1);
57
58
if ($help) {
59
    usage(0);
60
}
61
62
my $pref = C4::Context->preference("AnonymiseLastBorrower");
63
64
65
if( !$pref ) {
66
    print "Preference 'AnonymiseLastBorrower' must be enabled to anonymise item's last borrower\n\n";
67
    usage(1);
68
}
69
70
cronlogaction();
71
72
my $rows = Koha::Patrons->anonymise_last_borrowers();
73
$verbose and print int($rows) . " item's last borrowers anonymised.\n";
74
75
exit(0);

Return to bug 23260