From f07d265f157b6938e31eae0c5defa867559b5422 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 28 Nov 2023 13:27:27 +0000 Subject: [PATCH] Bug 23260: Database updates and new system preferences AnonymizeLastBorrower / AnonymizeLastBorrowerDays This patch alters the items_last_borrowers table to allow for NULL borrowers It also adds two new system preferences to allow controlling the anonymization of items_last_borrower data --- .../data/mysql/atomicupdate/bug_23260.perl | 22 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/mandatory/sysprefs.sql | 2 ++ .../en/modules/admin/preferences/patrons.pref | 8 +++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_23260.perl diff --git a/installer/data/mysql/atomicupdate/bug_23260.perl b/installer/data/mysql/atomicupdate/bug_23260.perl new file mode 100644 index 00000000000..57199bf281b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23260.perl @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "23260", + description => "Make borrowernumber from items_last_borrower nullable, and add AnonymizeLastBorrower and AnonymizeLastBorrowerDays preferences", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $dbh->do(q{}); + $dbh->do( "ALTER TABLE items_last_borrower MODIFY COLUMN `borrowernumber` int(11) default NULL" ); + say $out "items_last_borrower updated to allow NULL borrowernumbers"; + + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('AnonymizeLastBorrower','0',NULL,'If enabled, anonymize item\'s last borrower','YesNo'), + ('AnonymizeLastBorrowerDays','0',NULL,'Item\'s last borrower older than this preference will be anonymized','Integer') + }); + say $out "Added new system preferences 'AnonymizeLastBorrower' and 'AnonymizeLastBorrowerDays'"; + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 09a6adcc47f..a0146844b6b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4036,7 +4036,7 @@ DROP TABLE IF EXISTS `items_last_borrower`; CREATE TABLE `items_last_borrower` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemnumber` int(11) NOT NULL, - `borrowernumber` int(11) NOT NULL, + `borrowernumber` int(11) NULL, `created_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `itemnumber` (`itemnumber`), diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b58114d802e..030262d6a44 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -57,6 +57,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'), ('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'), ('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'), +('AnonymizeLastBorrower','0',NULL,'If enabled, anonymise item\'s last borrower','YesNo'), +('AnonymizeLastBorrowerDays','0',NULL,'Item\'s last borrower older than this preference will be anonymised','Integer'), ('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''), ('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'), ('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index c2043b85dd3..c6274f4e8f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -427,6 +427,14 @@ Patrons: initiator: populateCookieConsentedJS processor: prepareCookieConsentedJS - '
NOTE: The cookie consent modal can be customised using the CookieConsentPopup html customisation.' + - + - pref: AnonymizeLastBorrower + choices: + yes: Anonymize + no: "Don't anonymize" + - " item's last borrower after " + - pref: AnonymizeLastBorrowerDays + - days. Security: - - Login passwords for staff and patrons must be at least -- 2.30.2