Ver a proveniência

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

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Nick Clemens há 3 anos
cometido por Jonathan Druart
ascendente
cometimento
234cced91d
  1. 13
      catalogue/export.pl
  2. 2
      installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.perl
  3. 1
      installer/data/mysql/mandatory/sysprefs.sql
  4. 24
      koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc
  5. 11
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
  6. 19
      opac/opac-export.pl

13
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 = GetMarcControlnumber( $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;
}
}

2
installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.sql → 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");
}

1
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'),

24
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 );

11
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,

19
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 = GetMarcControlnumber( $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;

Carregando…
Cancelar
Guardar