Browse Source

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>
master
Nick Clemens 1 month ago
parent
commit
234cced91d
6 changed files with 46 additions and 24 deletions
  1. +12
    -1
      catalogue/export.pl
  2. +1
    -1
      installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.perl
  3. +1
    -0
      installer/data/mysql/mandatory/sysprefs.sql
  4. +12
    -12
      koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc
  5. +5
    -6
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
  6. +15
    -4
      opac/opac-export.pl

+ 12
- 1
catalogue/export.pl View File

@@ -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;
}
}

installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.sql → installer/data/mysql/atomicupdate/bug_24108-add_SaveRecordbyControlNumber_syspref.perl View File

@@ -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
- 0
installer/data/mysql/mandatory/sysprefs.sql View File

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


+ 12
- 12
koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc View File

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



+ 5
- 6
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref View File

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


+ 15
- 4
opac/opac-export.pl View File

@@ -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;


Loading…
Cancel
Save