Bugzilla – Attachment 19156 Details for
Bug 9921
Make it possible to force 001 = biblionumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9921 - Make it possible to force 001 = biblionumber
Bug-9921---Make-it-possible-to-force-001--biblionu.patch (text/plain), 8.70 KB, created by
Marcel de Rooy
on 2013-06-19 14:55:45 UTC
(
hide
)
Description:
Bug 9921 - Make it possible to force 001 = biblionumber
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-06-19 14:55:45 UTC
Size:
8.70 KB
patch
obsolete
>From ae9be70ab500ba986b250dd75e8673f7e585fc56 Mon Sep 17 00:00:00 2001 >From: =?utf8?q?Nu=C3=B1o=20L=C3=B3pez=20Ans=C3=B3tegui?= <nunyo@masmedios.com> >Date: Wed, 19 Jun 2013 14:35:41 +0200 >Subject: [PATCH] Bug 9921 - Make it possible to force 001 = biblionumber >Content-Type: text/plain; charset=utf-8 > >Field 001 is controlled by a system preference, which will have three options: > >The option "biblionumber" will set field 001 to the biblionumber when you save >the record. >The option "1,2,3" uses preference incrementalControlNumber to generate the >next sequential number. >The option "not generated automatically" allows for manual entry. >--- > C4/Biblio.pm | 21 ++++++ > cataloguing/value_builder/marc21_field_001.pl | 69 ++++++++++++++++++++ > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 25 +++++++ > .../en/modules/admin/preferences/cataloguing.pref | 13 ++++ > 5 files changed, 130 insertions(+), 0 deletions(-) > create mode 100755 cataloguing/value_builder/marc21_field_001.pl > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 7af8619..ca03e18 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -271,6 +271,27 @@ sub AddBiblio { > # update MARC subfield that stores biblioitems.cn_sort > _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); > >+ # update the control number (001) in MARC >+ if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){ >+ unless($record->field('001')){ >+ $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber)); >+ }elsif($record->field('001')->data() eq 'biblionumber'){ >+ $record->field('001')->update($biblionumber); >+ } >+ }elsif(C4::Context->preference('autoControlNumber') eq 'incremental'){ >+ if(!defined($record->field('001')) or (defined($record->field('001')) and $record->field('001')->data() eq 'incremental')){ >+ my $incrementalCN=C4::Context->preference('incrementalControlNumber'); >+ my $sth = $dbh->prepare(q{UPDATE systempreferences SET value = ? WHERE variable = 'incrementalControlNumber'}); >+ $sth->execute($incrementalCN+1); >+ $sth->finish(); >+ unless($record->field('001')){ >+ $record->insert_fields_ordered(MARC::Field->new('001', $incrementalCN)); >+ }else{ >+ $record->field('001')->update($incrementalCN); >+ } >+ } >+ } >+ > # now add the record > ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save; > >diff --git a/cataloguing/value_builder/marc21_field_001.pl b/cataloguing/value_builder/marc21_field_001.pl >new file mode 100755 >index 0000000..8a83d44 >--- /dev/null >+++ b/cataloguing/value_builder/marc21_field_001.pl >@@ -0,0 +1,69 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 Spanish Ministry of Education, Culture and Sport >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use C4::Context; >+ >+# This is a new style cataloging plugin, using $building_plugin >+ >+our $building_plugin; >+if(defined $building_plugin) { >+ marc21_field001_plugin_javascript(); >+} >+else { #nothing to do (no popup) >+} >+ >+#------------------------------------------------------------------------------- >+ >+sub marc21_field001_plugin_javascript { >+ my $field_number= $building_plugin->{subfieldid}; >+ my $function_name= $field_number; >+ >+ #depending on preference, adjust Focus function >+ my $autoControlNumber = C4::Context->preference('autoControlNumber'); >+ my $focusline=''; >+ if( $autoControlNumber ne 'OFF' ) { >+ $focusline= "document.getElementById(\"$field_number\").value='$autoControlNumber';\n"; >+ } >+ $focusline.='return 1;'; >+ >+ #build the actual javascript >+ my $res = " >+<script type=\"text/javascript\"> >+//<![CDATA[ >+function Blur$function_name(subfield_managed) { >+ return 1; >+} >+function Focus$function_name(subfield_managed) { >+ $focusline >+} >+function Clic$function_name(index) { >+ return 1; >+} >+//]]> >+</script> >+"; >+ >+ #return to caller via global hash >+ $building_plugin->{function}= $function_name; >+ $building_plugin->{javascript}= $res; >+} >+ >+1; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index fbd0387..2896709 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -427,3 +427,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo'); > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); >+INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('autoControlNumber','OFF','incremental|biblionumber|OFF','Used to autogenerate a Control Number: incremental will be of the form 1, 2, 3; biblionumber will be as biblionumber;','Choice'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('incrementalControlNumber', '1', 'Set the number (controlnumber) of the next bibliographic record.',NULL,''); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 5963d24..06ef0c9 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7010,6 +7010,31 @@ CREATE TABLE IF NOT EXISTS borrower_files ( > SetVersion($DBversion); > } > >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do( >+ q{ >+INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('autoControlNumber','OFF','incremental|biblionumber|OFF','Used to autogenerate a Control Number: incremental will be of the form 1, 2, 3; biblionumber will be as biblionumber;','Choice'); >+} >+ ); >+ $dbh->do( >+ q{ >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('incrementalControlNumber', '1', 'Set the number (controlnumber) of the next bibliographic record.',NULL,''); >+} >+ ); >+ if (C4::Context->preference("marcflavour") eq 'MARC21') { >+ $dbh->do( >+ q{ >+UPDATE marc_subfield_structure SET value_builder = 'marc21_field_001.pl' WHERE tagfield = '001' AND tagsubfield = '@' >+AND (value_builder = '' OR value_builder IS NULL); >+ } >+ ); >+ } >+ print >+"Upgrade to $DBversion done (Bug 9921 - Make it possible to force 001 = biblionumber)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >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 96f3603..d1c67e8 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 >@@ -109,6 +109,19 @@ Cataloging: > - pref: UNIMARCField100Language > class: short > - as default language in the UNIMARC field 100 when creating a new record or in the field plugin. >+ - >+ - Control Number (001) is >+ - pref: autoControlNumber >+ choices: >+ biblionumber: generated as biblionumber. >+ incremental: generated in the form 1, 2, 3. >+ "OFF": not generated automatically. >+ - (You should fill in a value in incrementalControlNumber preference.) >+ - >+ - Use Control Number (001) >+ - pref: incrementalControlNumber >+ class: integer >+ - as incremental number. (This requires generated in the form 1, 2, 3 in autoControlNumber preference.) > Display: > - > - 'Separate multiple displayed authors, series or subjects with ' >-- >1.7.7.6
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 9921
:
16896
|
18700
|
18701
|
18707
|
18862
|
18863
|
19062
|
19099
|
19153
|
19156
|
19170
|
19176
|
118424
|
118425
|
118460