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 53-58 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
53
('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'),
53
('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'),
54
('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'),
54
('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'),
55
('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
55
('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
56
('AnonymiseLastBorrower','0',NULL,'If enabled, anonymise item\'s last borrower','YesNo'),
57
('AnonymiseLastBorrowerDays','0',NULL,'Item\'s last borrower older than this preference will be anonymised','Integer'),
56
('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',''),
58
('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',''),
57
('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'),
59
('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'),
58
('ArticleRequestsLinkControl', 'calc', 'always|calc', 'Control display of article request link on search results', 'Choice'),
60
('ArticleRequestsLinkControl', 'calc', 'always|calc', 'Control display of article request link on search results', 'Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+8 lines)
Lines 319-324 Patrons: Link Here
319
         - days and remove anonymized patron accounts after
319
         - days and remove anonymized patron accounts after
320
         - pref: PatronRemovalDelay
320
         - pref: PatronRemovalDelay
321
         - "days.<br>IMPORTANT: No action is performed when these delays are empty (no text). But a zero value ('0') is interpreted as no delay (do it now)! The actions are performed by the cleanup database cron job."
321
         - "days.<br>IMPORTANT: No action is performed when these delays are empty (no text). But a zero value ('0') is interpreted as no delay (do it now)! The actions are performed by the cleanup database cron job."
322
     -
323
         - pref: AnonymiseLastBorrower
324
           choices:
325
               yes: Anonymise
326
               no: "Don't anonymise"
327
         - " item's last borrower after "
328
         - pref: AnonymiseLastBorrowerDays
329
         - days.
322
    Security:
330
    Security:
323
     -
331
     -
324
         - Login passwords for staff and patrons must be at least
332
         - 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