Bugzilla – Attachment 115036 Details for
Bug 24108
Configure if biblionumber or control number is used for saved files from detail page or advanced cataloguing editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24108: Make export file names consistent
Bug-24108-Make-export-file-names-consistent.patch (text/plain), 11.94 KB, created by
Nick Clemens (kidclamp)
on 2021-01-11 15:23:25 UTC
(
hide
)
Description:
Bug 24108: Make export file names consistent
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-01-11 15:23:25 UTC
Size:
11.94 KB
patch
obsolete
>From e229c138834a01fe550b07f2ed3ed96a8546ef0a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 11 Jan 2021 14:57:45 +0000 >Subject: [PATCH] Bug 24108: Make export file names consistent > >This patch renames the systempreference to be a bit clearer and uses >explicit options rather than a yes/no > >Additionally it standardizes the export from the advanced cataloging editor >with that from the details page > >To test: > 1 - Apply patches > 2 - Update database and restart all the things > 3 - Open a record in the advanced editor and save it as marc and xml > 4 - Note the file name is 'bib-{biblionumber.{format}' > 5 - Edit the syspref 'DefaultSaveRecordFileID' to be control number > 6 - Repeate 3-4 on a record with and without a control number > 7 - If control number present fiule name should be 'record-{controlnumber}.{format}' > 8 - Otherwise it should be as above > 9 - Repeat tests from the details page of a record >10 - Repeat tests from the opac details page of a record >--- > catalogue/export.pl | 13 +++++++++++- > ...108-add_SaveRecordbyControlNumber_syspref.perl} | 2 +- > installer/data/mysql/mandatory/sysprefs.sql | 1 + > installer/data/mysql/sysprefs.sql | 1 - > .../prog/en/includes/cateditor-ui.inc | 24 +++++++++++----------- > .../en/modules/admin/preferences/cataloguing.pref | 11 +++++----- > opac/opac-export.pl | 19 +++++++++++++---- > 7 files changed, 46 insertions(+), 25 deletions(-) > rename installer/data/mysql/atomicupdate/{bug_24108-add_SaveRecordbyControlNumber_syspref.sql => bug_24108-add_SaveRecordbyControlNumber_syspref.perl} (52%) > delete mode 100644 installer/data/mysql/sysprefs.sql > >diff --git a/catalogue/export.pl b/catalogue/export.pl >index b42b95b7ab..4e5d855045 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -25,11 +25,22 @@ my $error = ''; > if ($op eq "export") { > my $biblionumber = $query->param("bib"); > if ($biblionumber){ >+ my $file_id = $biblionumber; >+ my $file_pre = "bib-"; > > my $marc = GetMarcBiblio({ > biblionumber => $biblionumber, > embed_items => 1 }); > >+ if( C4::Context->preference('DefaultSaveRecordFileID') eq 'controlnumber' ){ >+ my $marcflavour = C4::Context->preference('marcflavour'); #FIXME This option is required but does not change control num behaviour >+ my $control_num = GetRecordControlNum( $marc, $marcflavour ); >+ if( $control_num ){ >+ $file_id = $control_num; >+ $file_pre = "record-"; >+ } >+ } >+ > if ($format =~ /endnote/) { > $marc = marc2endnote($marc); > $format = 'endnote'; >@@ -74,7 +85,7 @@ if ($op eq "export") { > } > print $query->header( > -type => 'application/octet-stream', >- -attachment=>"bib-$biblionumber.$format"); >+ -attachment=>"$file_pre$file_id.$format"); > print $marc; > } > } >diff --git a/installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.sql b/installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.perl >similarity index 52% >rename from installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.sql >rename to installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.perl >index de105c3d54..9e27bcd8c2 100644 >--- a/installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.sql >+++ b/installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.perl >@@ -3,7 +3,7 @@ if( CheckVersion( $DBversion ) ) { > $dbh->do(q{ > INSERT IGNORE INTO systempreferences > (variable, value, explanation, options, type) VALUES >- ('SaveRecordbyControlNumber', '0', 'If set, advanced cataloging editor will use the control number field to populate the name of the save file, otherwise it uses the biblionumber.', NULL, 'YesNo') >+ ('DefaultSaveRecordFileID', 'biblionumber', 'Defines whether the advanced cataloging editor will use the bibliographic record number or control number field to populate the name of the save file.', 'biblionumber|controlnumber', 'Choice') > }); > NewVersion( $DBversion, 24108, "Add system preference SaveRecordbyControlNumber"); > } >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 7f0afaa594..917633de37 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -157,6 +157,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'), > ('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'), > ('DefaultPatronSearchFields', 'surname,firstname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search using the "standard" option. If empty Koha will default to "surname,firstname,othernames,cardnumber,userid". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.','free'), >+('DefaultSaveRecordFileID','biblionumber','biblionumber|controlnumber','Defines whether the advanced cataloging editor will use the bibliographic record number or control number field to populate the name of the save file','Choice') > ('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), > ('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'), > ('DefaultToLoggedInLibraryCircRules', '0', NULL , 'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.', 'YesNo'), >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >deleted file mode 100644 >index 526fea6faf..0000000000 >--- a/installer/data/mysql/sysprefs.sql >+++ /dev/null >@@ -1 +0,0 @@ >-('SaveRecordbyControlNumber','0',NULL,'If set, advanced editor (Rancor) will use the control number field to populate the name of the save file, otherwise it uses the biblionumber.','YesNo') >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index a869ab08ea..822f984e6f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -291,14 +291,14 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > save: function( id, record, done ) { > var recname = 'record.mrc'; > if(state.recordID) { >- recname = state.recordID+'.mrc'; >+ recname = 'bib-'+state.recordID+'.mrc'; > } > >- [% IF (Koha.Preference('SaveRecordbyControlNumber') == '1') %] >- var controlnumfield = record.field('001'); >- if(controlnumfield) { >- recname = controlnumfield.subfield('@')+'.mrc'; >- } >+ [% IF (Koha.Preference('DefaultSaveRecordFileID') == 'controlnumber') %] >+ var controlnumfield = record.field('001'); >+ if(controlnumfield) { >+ recname = 'record-'+controlnumfield.subfield('@')+'.mrc'; >+ } > [% END %] > saveAs( new Blob( [record.toISO2709()], { 'type': 'application/octet-stream;charset=utf-8' } ), recname ); > >@@ -310,14 +310,14 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > save: function( id, record, done ) { > var recname = 'record.xml'; > if(state.recordID) { >- recname = state.recordID+'.xml'; >+ recname = 'bib-'+state.recordID+'.xml'; > } > >- [% IF (Koha.Preference('SaveRecordbyControlNumber') == '1') %] >- var controlnumfield = record.field('001'); >- if(controlnumfield) { >- recname = controlnumfield.subfield('@')+'.xml'; >- } >+ [% IF (Koha.Preference('DefaultSaveRecordFileID') == 'controlnumber') %] >+ var controlnumfield = record.field('001'); >+ if(controlnumfield) { >+ recname = 'record-'+controlnumfield.subfield('@')+'.xml'; >+ } > [% END %] > saveAs( new Blob( [record.toXML()], { 'type': 'application/octe t-stream;charset=utf-8' } ), recname ); > >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 9514784262..bec1975a20 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 >@@ -29,13 +29,12 @@ Cataloging: > - Currently does not include support for UNIMARC or NORMARC fixed fields. > - > - "When saving in a MARC/MARCXML file in the advanced cataloging editor, use the" >- - pref: SaveRecordbyControlNumber >- default: 0 >+ - pref: DefaultSaveRecordFileID >+ default: biblionumber > choices: >- yes: Enable >- yes: "control number" >- no: "record number" >- - "in the file name. The default is to use the bibliographic record number." >+ controlnumber: "control number" >+ biblionumber: "bibliographic record number" >+ - "in the file name." > Spine labels: > - > - When using the quick spine label printer, >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index 402d1fee0d..89db293365 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -61,6 +61,17 @@ if(!$marc) { > exit; > } > >+my $file_id = $biblionumber; >+my $file_pre = "bib-"; >+if( C4::Context->preference('DefaultSaveRecordFileID') eq 'controlnumber' ){ >+ my $marcflavour = C4::Context->preference('marcflavour'); #FIXME This option is required but does not change control num behaviour >+ my $control_num = GetRecordControlNum( $marc, $marcflavour ); >+ if( $control_num ){ >+ $file_id = $control_num; >+ $file_pre = "record-"; >+ } >+} >+ > # ASSERT: There is a biblionumber, because GetMarcBiblio returned something. > my $framework = GetFrameworkCode( $biblionumber ); > my $record_processor = Koha::RecordProcessor->new({ >@@ -136,27 +147,27 @@ else { > print $query->header( > -type => 'application/marc', > -charset=>'ISO-2022', >- -attachment=>"bib-$biblionumber.$format"); >+ -attachment=>"$file_pre$file_id.$format"); > } > elsif ( $format eq 'isbd' ) { > print $query->header( > -type => 'text/plain', > -charset => 'utf-8', >- -attachment => "bib-$biblionumber.txt" >+ -attachment => "$file_pre$file_id.txt" > ); > } > elsif ( $format eq 'ris' ) { > print $query->header( > -type => 'text/plain', > -charset => 'utf-8', >- -attachment => "bib-$biblionumber.$format" >+ -attachment => "$file_pre$file_id.$format" > ); > } else { > binmode STDOUT, ':encoding(UTF-8)'; > print $query->header( > -type => 'application/octet-stream', > -charset => 'utf-8', >- -attachment => "bib-$biblionumber.$format" >+ -attachment => "$file_pre$file_id.$format" > ); > } > print $marc; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24108
:
95989
|
101026
|
101027
|
101032
|
101056
|
101069
|
101381
|
101382
|
101383
|
101384
|
114081
|
114082
|
114243
|
114244
|
115033
|
115034
|
115035
|
115036
|
115038
|
115356
|
115357
|
115358
|
115359
|
116898
|
116899
|
116900
|
116901
|
116902
|
116903
|
116912
|
116913
|
116914
|
116915
|
116916
|
116917
|
116918