From e47e51b622ac9b8a475c1c6fa1d4408ef3deb0fb Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 22 Mar 2022 21:26:35 +0000 Subject: [PATCH] Bug 30250: Use ApplyFrameworkDefaults when importing a record This patch adds the case of importing a record to the ApplyFrameworkDefaults options. To test: 1. Update database 2. Confirm the ApplyFrameworkDefaults system preference now has the 'when importing a record via z39.50' option. Do not select it. 3. Go to Cataloguing. Import a record from z39.50, or replace an existing record. 4. Confirm framework defaults are not applied. 5. Go back to the system preference and check the 'when importing a record via z39.50' option. 6. Repeat step 3. This time framework defaults should be applied. Only fields that are empty in the imported record will be replaced by framework defaults. 7. Repeat for authorities. Sponsored-by: Catalyst IT Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b837f1356b0c25801bab09f95f1881c831cf4cd3) Signed-off-by: Lucas Gass (cherry picked from commit 2800e199be5b871790700e8265d4ce23956b8fb0) Signed-off-by: Arthur Suzuki --- authorities/authorities.pl | 3 ++- cataloguing/addbiblio.pl | 6 ++++-- .../bug_30250_-_add_ApplyFrameworkDefaults_syspref.pl | 2 +- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../prog/en/modules/admin/preferences/cataloguing.pref | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 364c4d3b60..f57acfd934 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -119,7 +119,8 @@ sub create_input { my $applydefaults = C4::Context->preference('ApplyFrameworkDefaults'); if ( $value eq '' && ( ( $applydefaults =~ /new/ && !$cgi->param('authid') ) || - ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' ) + ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' ) || + ( $applydefaults =~ /imported/ && $cgi->param('breedingid') ) ) ) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; if (!defined $value) { diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 95fadb676f..cfbbb8bc59 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -285,19 +285,21 @@ sub GetMandatoryFieldZ3950 { sub create_input { my ( $tag, $subfield, $value, $index_tag, $rec, $authorised_values_sth,$cgi ) = @_; - + my $index_subfield = CreateKey(); # create a specifique key for each subfield # Apply optional framework default value when it is a new record, # or when editing as new (duplicating a record), # or when changing a record's framework, + # or when importing a record, # based on the ApplyFrameworkDefaults setting. # Substitute date parts, user name my $applydefaults = C4::Context->preference('ApplyFrameworkDefaults'); if ( $value eq '' && ( ( $applydefaults =~ /new/ && !$cgi->param('biblionumber') ) || ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' ) || - ( $applydefaults =~ /changed/ && $cgi->param('changed_framework') ) + ( $applydefaults =~ /changed/ && $cgi->param('changed_framework') ) || + ( $applydefaults =~ /imported/ && $cgi->param('breedingid') ) ) ) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{}; diff --git a/installer/data/mysql/atomicupdate/bug_30250_-_add_ApplyFrameworkDefaults_syspref.pl b/installer/data/mysql/atomicupdate/bug_30250_-_add_ApplyFrameworkDefaults_syspref.pl index 50f1c3b310..39b7c8ccb5 100644 --- a/installer/data/mysql/atomicupdate/bug_30250_-_add_ApplyFrameworkDefaults_syspref.pl +++ b/installer/data/mysql/atomicupdate/bug_30250_-_add_ApplyFrameworkDefaults_syspref.pl @@ -7,6 +7,6 @@ return { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('ApplyFrameworkDefaults', 'new', "new|duplicate|changed", "Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework", 'multiple') }); + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('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') }); }, }; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 832169e139..81feafc59e 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -54,7 +54,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('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'), ('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''), -('ApplyFrameworkDefaults', 'new', 'new|duplicate|changed', 'Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework', 'multiple'), +('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'), ('ArticleRequestsOpacHostRedirection', '0', NULL, 'Enables redirection from child to host when requesting articles on the Opac', 'YesNo'), ('ArticleRequestsLinkControl', 'calc', 'always|calc', 'Control display of article request link on search results', 'Choice'), 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 3207b1e149..96fe1a2bfc 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 @@ -172,6 +172,7 @@ Cataloging: new: "when cataloguing new records" duplicate: "when editing records as new (duplicating)" changed: "when changing the framework while editing the existing record" + imported: "when importing a record" Display: - - 'Separate main entry and subdivisions with ' -- 2.39.5