Bugzilla – Attachment 91040 Details for
Bug 23111
Setting a custom framework as the default for cataloguing is not possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23111: Set custom bibliographic framework as default
Bug-23111-Set-custom-bibliographic-framework-as-de.patch (text/plain), 11.51 KB, created by
Hayley Pelham
on 2019-06-27 01:12:47 UTC
(
hide
)
Description:
Bug 23111: Set custom bibliographic framework as default
Filename:
MIME Type:
Creator:
Hayley Pelham
Created:
2019-06-27 01:12:47 UTC
Size:
11.51 KB
patch
obsolete
>From 733453ed9786d5b6fa3aea003fe3239f8895a34f Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 10 Jun 2019 03:09:55 +0000 >Subject: [PATCH] Bug 23111: Set custom bibliographic framework as default > >This patch adds a new system preference (DefaultBibliographicFramework). Using >this a librarian can select the bibliographic framework code to set the >the bibliographic framework that will be >displayed as default when: > >* Importing batch of biblio records >* Editing a biblio record with no mapped biblio framework > >Test plan: >1. Apply patch > >2. Run ./updatedatabase.pl (in installer/data/mysql) from the Koha shell to implement db changes > >3. Search for the syspref DefaultBibliographicFramework in Administration module > >4. Notice the syspref has the value 'Default' > >5. Locate and edit the record of a bibliographic record not mapped to a >framework and notice 'Default' is ticked when you click >on 'Settings' > >6. Click 'Save' and confirm the frameworkcode of the bibliorecord is >Default (stored in the database as empty). You can do this by running the SQL: >SELECT frameworkcode FROM biblio WHERE biblionumber=<biblionumber>; > >7. Import a batch of biblio records and notice that 'Default' is >displayed as the framework to be used > >8. Confirm the frameworkcode of one of the imported biblio records is >default. Do this by running the SQL: >SELECT frameworkcode FROM biblio WHERE biblionumber=<biblionumber of >biblio imported in step 7>; > >9. Select a different framework (such as Acquisitions) in the DefaultBibliographicFramework syspref > >10. Repeat step 5 but notice the DefaultBibliographicFramework framework as shown as the framework > >11. Confirm the biblio has the new frameworkcode. You can do this by >running the SQL: SELECT frameworkcode FROM biblio WHERE biblionumber=<biblionumber>; > >12. Repeat step 7 and notice the DefaultBibliographicFramework is shown as >the framework to be used > >13. Confirm the biblios imported in step 12 have the correct >frameworkcode by running the following SQL: >SELECT frameworkcode FROM biblio WHERE biblionumber=<biblionumber of >imported biblio in step 12>; > >Authored-by: Alex Buckley >Sponsored-by: Brimbank Library, Australia >--- > Koha/BiblioFramework.pm | 20 ++++++++++++++++++ > admin/preferences.pl | 9 ++++++++ > cataloguing/addbiblio.pl | 8 +++++++- > ...r290627_set_default_bibliographic_framework.sql | 1 + > installer/data/mysql/sysprefs.sql | 1 + > .../en/modules/admin/preferences/cataloguing.pref | 5 +++++ > .../prog/en/modules/tools/manage-marc-import.tt | 24 +++++++++++++++------- > tools/manage-marc-import.pl | 6 ++++++ > 8 files changed, 66 insertions(+), 8 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql > >diff --git a/Koha/BiblioFramework.pm b/Koha/BiblioFramework.pm >index d9ade57b2b..ee369c473f 100644 >--- a/Koha/BiblioFramework.pm >+++ b/Koha/BiblioFramework.pm >@@ -41,4 +41,24 @@ sub _type { > return 'BiblioFramework'; > } > >+=head2 GetFrameworkSources >+ >+ my $sources = GetFrameworkSources(); >+ >+ Returns reference to hash of references to >+ the framework sources, keyed on frameworkcode. >+ >+=cut >+ >+sub GetFrameworkSources { >+ my %framework_sources = (); >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare("SELECT * FROM `biblio_framework`"); >+ $sth->execute(); >+ while (my $source = $sth->fetchrow_hashref) { >+ $framework_sources{ $source->{'frameworkcode'} } = $source; >+ } >+ return \%framework_sources; >+ } >+ > 1; >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 92c5bbee72..fc4bcf3879 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -29,6 +29,7 @@ use C4::Log; > use C4::Output; > use C4::Templates; > use Koha::Acquisition::Currencies; >+use Koha::BiblioFramework; > use File::Spec; > use IO::File; > use YAML::Syck qw(); >@@ -89,6 +90,14 @@ sub _get_chunk { > if ( $options{'choices'} eq 'class-sources' ) { > my $sources = GetClassSources(); > $options{'choices'} = { map { $_ => $sources->{$_}->{'description'} } keys %$sources }; >+ } elsif ( $options{'choices'} eq 'framework-sources' ) { >+ my $sources = Koha::BiblioFramework::GetFrameworkSources(); >+ >+ #Add framework to syspref dropdown with a frameworkcode of 'Default' so users can choose to not use >+ #custom bibliographic frameworks as default bib framework >+ $sources->{'Default'}->{'frameworktext'} = 'Default'; >+ >+ $options{'choices'} = { map { $_ => $sources->{$_}->{'frameworktext'} } keys %$sources }; > } elsif ( $options{'choices'} eq 'opac-templates' ) { > $options{'choices'} = { map { $_ => $_ } getallthemes( 'opac' ) } > } elsif ( $options{'choices'} eq 'staff-templates' ) { >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 6478bb2dfe..cab930adfa 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -35,6 +35,7 @@ use C4::ClassSource; > use C4::ImportBatch; > use C4::Charset; > use Koha::BiblioFrameworks; >+use Koha::BiblioFramework; > use Koha::DateUtils; > > use Koha::ItemTypes; >@@ -709,7 +710,12 @@ if ($frameworkcode eq 'FA'){ > $userflags = 'fast_cataloging'; > } > >-$frameworkcode = '' if ( $frameworkcode eq 'Default' ); >+if (( C4::Context->preference("DefaultBibliographicFramework") && C4::Context->preference("DefaultBibliographicFramework") ne 'Default' )) { >+ $frameworkcode = C4::Context->preference("DefaultBibliographicFramework"); >+} else { >+ $frameworkcode = '' if ( $frameworkcode eq 'Default' ); >+} >+ > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "cataloguing/addbiblio.tt", >diff --git a/installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql b/installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql >new file mode 100644 >index 0000000000..315df4adbc >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql >@@ -0,0 +1 @@ >+INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('DefaultBibliographicFramework','Default',NULL,'Default bibliographic framework used by the Cataloging module','FrameworkSources'); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index a0d1132d25..dbe557829c 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -134,6 +134,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('decreaseLoanHighHoldsDuration',NULL,'','Specifies a number of days that a loan is reduced to when used in conjunction with decreaseLoanHighHolds','Integer'), > ('decreaseLoanHighHoldsIgnoreStatuses', '', 'damaged|itemlost|notforloan|withdrawn', "Ignore items with these statuses for dynamic high holds checking", 'Choice'), > ('decreaseLoanHighHoldsValue',NULL,'','Specifies a threshold for the minimum number of holds needed to trigger a reduction in loan duration (used with decreaseLoanHighHolds)','Integer'), >+('DefaultBibliographicFramework','Default',NULL,'Default bibliographic framework used by the Cataloging module','FrameworkSources'), > ('DefaultClassificationSource','ddc',NULL,'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.','ClassSources'), > ('DefaultCountryField008','','','Fill in the default country code for field 008 Range 15-17 of MARC21 - Place of publication, production, or execution. See <a href=\"http://www.loc.gov/marc/countries/countries_code.html\">MARC Code List for Countries</a>','Free'), > ('DefaultLanguageField008','','','Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see <a href=\"http://www.loc.gov/marc/languages/language_code.html\">MARC Code List for Languages</a>)','Free'), >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 dbfd788c66..9e866fd08d 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 >@@ -7,6 +7,11 @@ Cataloging: > choices: class-sources > - as the default classification source. > - >+ - Use >+ - pref: DefaultBibliographicFramework >+ choices: framework-sources >+ - as the default bibliographic framework to be used by cataloging module. >+ - > - pref: advancedMARCeditor > choices: > yes: "Don't display" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >index e384b13fdb..dbf973af49 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >@@ -1,5 +1,6 @@ > [% USE raw %] > [% USE Asset %] >+[% USE Koha %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Manage staged MARC records >@@ -203,15 +204,24 @@ > <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" /> > <fieldset class="action"> > [% IF ( record_type != 'auth' ) %] >- Add new bibliographic records into this framework: >- <select name="framework" id="frameworks"> >- <option value="">Default</option> >- [% FOREACH framework IN frameworks %] >- <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option> >- [% END %] >- </select> >+ Add new bibliographic records into this framework: >+ <select name="framework" id="frameworks"> >+ >+ [% IF defaultframework %] >+ <option value="[% defaultframework.frameworkcode | html %]" selected="selected">[% defaultframework.frameworktext | html %]</option> >+ [% ELSE %] >+ <option value="" selected="selected">Default</option> >+ [% END %] >+ >+ [% FOREACH framework IN frameworks %] >+ [% IF defaultframework.frameworkcode != framework.frameworkcode %] >+ <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option> >+ [% END %] >+ [% END %] >+ </select> > [% END %] > <br/> >+ > <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" /> > </fieldset> > </form> >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index 4fea4005d7..446a15cd0b 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -63,7 +63,13 @@ our $sessionID = $cookies{'CGISESSID'}->value; > our $dbh = C4::Context->dbh; > > my $frameworks = Koha::BiblioFrameworks->search({ tagfield => { 'not' => undef } }, { join => 'marc_tag_structure', distinct => 'frameworkcode', order_by => ['frameworktext'] }); >+ > $template->param( frameworks => $frameworks ); >+if ( (C4::Context->preference('DefaultBibliographicFramework') && C4::Context->preference('DefaultBibliographicFramework') ne 'Default')) { >+ my $frameworkcode = C4::Context->preference('DefaultBibliographicFramework'); >+ my $defaultframework = Koha::BiblioFrameworks->find($frameworkcode); >+ $template->param( defaultframework => $defaultframework ); >+} > > if ($op eq "create_labels") { > #create a batch of labels, then lose $op & $import_batch_id so we get back to import batch list. >-- >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 23111
:
90550
|
90587
|
90588
|
91039
|
91040
|
91791
|
92184
|
102602
|
102603
|
104058
|
104059
|
104060
|
104061
|
104062
|
106560
|
112354
|
112468
|
138766
|
138767
|
138768
|
138769
|
138770
|
141565
|
141566
|
141567
|
141568
|
141569
|
157717
|
157718
|
157719
|
157720
|
157721
|
157722
|
157723