From 146df161094af0d5faf58ba8add0864dd8b87af0 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 28 Apr 2023 12:39:58 +0000 Subject: [PATCH] Bug 33445: [alternate] Pass through form info if present and use record values otherwise This patch updates the form to pass through values formthe form when searching, and to use record values if nothing is passed in. TO test: 1. Without the patch, edit a personal name authority record, replacing the value in 100 subfield a (200 subfield a for UNIMARC) with your own name. 2. Click "Replace record via Z39.50/SRU search" and note that the prefilled search field contains the original value, not your name. 3. Replace the Author (personal) field with your name again, choose a search target, and click Search. 4. Note that the results of the search are for the original value, not for your name. 5. Apply patch, repeat, noting that the search form is prefilled with your change made in the editor, and any changes you make in the search form are reflected in what the search results return. --- cataloguing/z3950_auth_search.pl | 50 +++++++++++++++----------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/cataloguing/z3950_auth_search.pl b/cataloguing/z3950_auth_search.pl index 5b413201fa..ce6a3bd324 100755 --- a/cataloguing/z3950_auth_search.pl +++ b/cataloguing/z3950_auth_search.pl @@ -33,6 +33,7 @@ my $input = CGI->new; my $dbh = C4::Context->dbh; my $error = $input->param('error'); my $authid = $input->param('authid') || 0; +my $op = $input->param('op')||''; my $record = GetAuthority($authid); my $marc_flavour = C4::Context->preference('marcflavour'); @@ -44,34 +45,31 @@ my $authfields_mapping = { 'subject' => $marc_flavour eq 'MARC21' ? '150' : '250', }; -my $nameany = $input->param('nameany'); -my $authorany = $input->param('authorany'); -my $authorcorp = - $record - ? $record->subfield( $authfields_mapping->{'authorcorp'}, 'a' ) - : $input->param('authorcorp'); -my $authorpersonal = - $record - ? $record->subfield( $authfields_mapping->{'authorpersonal'}, 'a' ) - : $input->param('authorpersonal'); -my $authormeetingcon = - $record - ? $record->subfield( $authfields_mapping->{'authormeetingcon'}, 'a' ) - : $input->param('authormeetingcon'); +my $nameany = $input->param('nameany'); +my $authorany = $input->param('authorany'); +my $title = $input->param('title'); +my $authorpersonal = $input->param('authorpersonal'); +my $authormeetingcon = $input->param('authormeetingcon'); +my $uniformtitle = $input->param('uniformtitle'); +my $subject = $input->param('subject'); +my $authorcorp = $input->param('authorcorp'); +my $subjectsubdiv = $input->param('subjectsubdiv'); +my $srchany = $input->param('srchany'); -my $title = $input->param('title'); -my $uniformtitle = - $record - ? $record->subfield( $authfields_mapping->{'uniformtitle'}, 'a' ) - : $input->param('uniformtitle'); -my $subject = - $record - ? $record->subfield( $authfields_mapping->{'subject'}, 'a' ) - : $input->param('subject'); +# If replacing an existing record we want to initially populate the form with record info, +# however, we want to use entered inputs when searching +if ( $record && $op ne 'do_search' ) { + $authorcorp ||= + $record->subfield( $authfields_mapping->{'authorcorp'}, 'a' ); + $authorpersonal ||= + $record->subfield( $authfields_mapping->{'authorpersonal'}, 'a' ); + $authormeetingcon ||= + $record->subfield( $authfields_mapping->{'authormeetingcon'}, 'a' ); + $uniformtitle ||= + $record->subfield( $authfields_mapping->{'uniformtitle'}, 'a' ); + $subject ||= $record->subfield( $authfields_mapping->{'subject'}, 'a' ); +} -my $subjectsubdiv = $input->param('subjectsubdiv'); -my $srchany = $input->param('srchany'); -my $op = $input->param('op')||''; my $page = $input->param('current_page') || 1; my $index =$input->param('index'); $page = $input->param('goto_page') if $input->param('changepage_goto'); -- 2.30.2