From ea50a2728847fdbe783cdb51388c54919d89945a Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 26 Mar 2024 17:14:05 +0000 Subject: [PATCH] Bug 36453: DB and data changes - kohastructure.sql updates - atomicupdate file - Mandatory data installer updates Signed-off-by: Arthur Suzuki Signed-off-by: Martin Renvoize --- .../data/mysql/atomicupdate/bug_36453.pl | 59 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/mandatory/sysprefs.sql | 2 +- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_36453.pl diff --git a/installer/data/mysql/atomicupdate/bug_36453.pl b/installer/data/mysql/atomicupdate/bug_36453.pl new file mode 100755 index 0000000000..08d6734d15 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_36453.pl @@ -0,0 +1,59 @@ +use Modern::Perl; + +return { + bug_number => "36453", + description => "BlockExpiredPatronOpacActions should allow multiple actions options", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my ($BlockExpiredPatronOpacActions) = $dbh->selectrow_array( + q{ + SELECT value FROM systempreferences WHERE variable = 'BlockExpiredPatronOpacActions'; + } + ); + + if ( $BlockExpiredPatronOpacActions eq 1 ) { + + # Update system preference settings if 1 + $dbh->do( + "UPDATE systempreferences SET value='hold,renew' WHERE variable='BlockExpiredPatronOpacActions' and value=1" + ); + say $out "BlockExpiredPatronOpacActions system preference value updated to 'hold,renew'."; + } elsif ( $BlockExpiredPatronOpacActions eq 0 ) { + + # Update system preference settings if 0 + $dbh->do( + "UPDATE systempreferences SET value='' WHERE variable='BlockExpiredPatronOpacActions' and value=0"); + say $out "BlockExpiredPatronOpacActions system preference value updated to empty string."; + } + + # Update system preference setting to multiple instead of YesNo + $dbh->do("UPDATE systempreferences SET type='multiple' WHERE variable='BlockExpiredPatronOpacActions'"); + say $out "BlockExpiredPatronOpacActions system preference value updated to multiple."; + + # Update categories database table BlockExpiredPatronOpacActions column settings + $dbh->do( + "ALTER TABLE categories MODIFY BlockExpiredPatronOpacActions mediumtext NOT NULL DEFAULT 'follow_syspref_BlockExpiredPatronOpacActions' COMMENT 'specific actions expired patrons of this category are blocked from performing or if the BlockExpiredPatronOpacActions system preference is to be followed'" + ); + say $out "categories column BlockExpiredPatronOpacActions updated."; + + # Update patron categories using -1 + $dbh->do( + "UPDATE categories SET BlockExpiredPatronOpacActions = 'follow_syspref_BlockExpiredPatronOpacActions' WHERE BlockExpiredPatronOpacActions = '-1'" + ); + say $out + "Patron categories BlockExpiredPatronOpacActions = -1 have been updated to follow the syspref BlockExpiredPatronOpacActions."; + + # Update patron categories using 0 + $dbh->do("UPDATE categories SET BlockExpiredPatronOpacActions = '' WHERE BlockExpiredPatronOpacActions = '0'"); + say $out "Patron categories BlockExpiredPatronOpacActions = 0 have been updated to an empty string ('')."; + + # Update patron categories using 1 + $dbh->do( + "UPDATE categories SET BlockExpiredPatronOpacActions = 'hold,renew' WHERE BlockExpiredPatronOpacActions = '1' " + ); + say $out "Patron categories BlockExpiredPatronOpacActions = 1 have been updated to hold,renew'."; + + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 91c1bec42f..7afeabffc0 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1796,7 +1796,7 @@ CREATE TABLE `categories` ( `reservefee` decimal(28,6) DEFAULT NULL COMMENT 'cost to place holds', `hidelostitems` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'are lost items shown to this category (1 for yes, 0 for no)', `category_type` varchar(1) NOT NULL DEFAULT 'A' COMMENT 'type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)', - `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL DEFAULT -1 COMMENT 'wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions', + `BlockExpiredPatronOpacActions` mediumtext NOT NULL DEFAULT 'follow_syspref_BlockExpiredPatronOpacActions' COMMENT 'specific actions expired patrons of this category are blocked from performing or if the BlockExpiredPatronOpacActions system preference is to be followed', `default_privacy` enum('default','never','forever') NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category', `checkprevcheckout` varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.', `can_place_ill_in_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'can this patron category place interlibrary loan requests', diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index dffaaadd49..08542a8dd1 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -117,7 +117,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('BiblioDefaultView','normal','normal|marc|isbd','Choose the default detail view in the catalog; choose between normal, marc or isbd','Choice'), ('BiblioItemtypeInfo','0','0','Control which itemtype info displays for biblio level itemtypes','YesNo'), ('BibtexExportAdditionalFields', '', NULL , 'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea'), -('BlockExpiredPatronOpacActions','1',NULL,'Set whether an expired patron can perform opac actions such as placing holds or renew books, can be overridden on a per patron-type basis','YesNo'), +('BlockExpiredPatronOpacActions','','hold,renew','Specific actions expired patrons of this category are blocked from performing or if the BlockExpiredPatronOpacActions system preference is to be followed','multiple'), ('BlockReturnOfLostItems','0','0','If enabled, items that are marked as lost cannot be returned.','YesNo'), ('BlockReturnOfWithdrawnItems','1','0','If enabled, items that are marked as withdrawn cannot be returned.','YesNo'), ('BorrowerMandatoryField','surname|cardnumber',NULL,'Choose the mandatory fields for a patron\'s account','free'), -- 2.39.5