From 249f62619e37b15564be028ca4f7dc4a9194b69c Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Fri, 25 Oct 2024 17:31:15 +0000 Subject: [PATCH] Bug 32773: Add AllowAsFastAddFrameworks system preference This patch adds a new multiselect system preference that allows making selections from a list of biblioframeworks To test: 1. Apply patch 2. Update database perl installer/data/mysql/updatedatabase.pl 3. Search System preferences for 'AllowAsFastAddFrameworks' 4. See the dropdown list is populated from bibliographic frameworks 5. Go to Administration > MARC Bibliographic frameworks add a new framework 6. Confirm the new option is available in 'AllowAsFastAddFrameworks' --- admin/preferences.pl | 7 ++++++- ..._32773_AllowAsFastAddFrameworks_syspref.pl | 20 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/cataloguing.pref | 5 +++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_32773_AllowAsFastAddFrameworks_syspref.pl diff --git a/admin/preferences.pl b/admin/preferences.pl index d00672b1ae..45e59fe0dc 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -33,6 +33,7 @@ use IO::File; use YAML::XS; use Encode; use List::MoreUtils qw( any uniq ); +use Koha::BiblioFrameworks; sub GetTab { my ( $input, $tab ) = @_; @@ -113,7 +114,11 @@ sub _get_chunk { $options{'choices'} = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search( { category => $options{'source'} } )->as_list }; $add_blank = 1; } - } else { + } elsif ($options{choices} eq 'framework-codes') { + $options{'choices'} = { map { $_->frameworkcode => $_->frameworktext } Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] })->as_list }; + $add_blank = 1; + } + else { die 'Unrecognized source of preference values: ' . $options{'choices'}; } } diff --git a/installer/data/mysql/atomicupdate/bug_32773_AllowAsFastAddFrameworks_syspref.pl b/installer/data/mysql/atomicupdate/bug_32773_AllowAsFastAddFrameworks_syspref.pl new file mode 100755 index 0000000000..643d2e6234 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_32773_AllowAsFastAddFrameworks_syspref.pl @@ -0,0 +1,20 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "32773", + description => "Add `AllowAsFastAddFrameworks` preference", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + try { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) + VALUES ('AllowAsFastAddFrameworks', '', NULL, 'List of Bibliographic frameworks to allow as Fast Add', 'multiple')}); + say_success( $out, "Added system preference 'AllowAsFastAddFrameworks'" ); + } + catch { + say_failure( $out, "Database modification failed with errors: $_" ); + }; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index ede74e6d3f..5e950388f8 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -25,6 +25,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'), ('AggressiveMatchOnISBN','0', NULL,'If enabled, attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records when matching on ISBN with the record import tool','YesNo'), ('AggressiveMatchOnISSN','0', NULL,'If enabled, attempt to match aggressively by trying all variations of the ISSNs in the imported record as a phrase in the ISSN fields of already cataloged records when matching on ISSN with the record import tool','YesNo'), +('AllowAsFastAddFrameworks', '', NULL, 'Allow the selected bibliographic frameworks to be used as Fast Add', 'multiple'), ('AllFinesNeedOverride','1','0','If on, staff will be asked to override every fine, even if it is below noissuescharge.','YesNo'), ('AllowAllMessageDeletion','0','','Allow any Library to delete any message','YesNo'), ('AllowCheckoutNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index ffd9b7e549..2307b9c0e0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -217,6 +217,11 @@ Cataloging: 1: Strip 0: "Don't strip" - leading and trailing whitespace characters (including spaces, tabs, line breaks and carriage returns) and inner newlines from data fields when cataloguing bibliographic and authority records. The leader and control fields will not be affected. + - + - Allow the selected bibliographic frameworks to be used as Fast Add + - pref: AllowAsFastAddFrameworks + choices: framework-codes + class: multiple Display: - - 'Separate main entry and subdivisions with ' -- 2.39.5