Bugzilla – Attachment 96501 Details for
Bug 3426
Add support for multiple tags to the itemcallnumber system preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 3426: Allow for multiple fields in itemcallnumber syspref
Bug-3426-Allow-for-multiple-fields-in-itemcallnumb.patch (text/plain), 6.08 KB, created by
Nick Clemens
on 2019-12-19 23:48:54 UTC
(
hide
)
Description:
Bug 3426: Allow for multiple fields in itemcallnumber syspref
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2019-12-19 23:48:54 UTC
Size:
6.08 KB
patch
obsolete
>From 734da41b72a7af5a39309e24f14806a76715b3f9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 19 Dec 2019 05:29:47 +0000 >Subject: [PATCH] Bug 3426: Allow for multiple fields in itemcallnumber syspref > >Note that we change both cataloguing/additem.pl and C4/Items->PrepareItemrecordfordisplay > >I can find no code that uses callnumber from the C4/Items sub, except for the itemrecorddisplay script >which is not called with an itemnumber from Koha and should be deprecated for REST or ILSDI or OAI (imho) > >To test: > 1 - Define itemcallnumber syspref as "082ab,092ab,9520,245a" > 2 - Find a record with no items > 3 - Ensure it has no 082 field, but an 092 field > 4 - Go to add an item - itemcallnumber is empty > 5 - Apply patch > 6 - Go to add item, itemcallnumber should be the 092ab fields > 7 - Delete the 092 field > 8 - Go to add item, itemcallnumber should be the 245a > 9 - Edit the callnumber to be "testing" and save item >10 - For should now show itemcallnumber="testing" as default >11 - Browse to http://localhost:8081/cgi-bin/koha/services/itemrecorddisplay.pl?itemnumber=## subbing the correct itemnumber >12 - Ensure the callnumber is defaulting to testing >13 - delete the item you created >14 - browse to URL above - callnumber should now be 245 again >15 - Add an 092 field to record and ensure it is now default callnumber >16 - Add an 082 field, it should now be default >--- > C4/Items.pm | 12 +++++++----- > cataloguing/additem.pl | 12 ++++++------ > .../prog/en/modules/admin/preferences/cataloguing.pref | 4 ++-- > 3 files changed, 15 insertions(+), 13 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 4f6a587db2..9071c71bd1 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -2401,11 +2401,13 @@ sub PrepareItemrecordDisplay { > > # search for itemcallnumber if applicable > if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' >- && C4::Context->preference('itemcallnumber') ) { >- my $CNtag = substr( C4::Context->preference('itemcallnumber'), 0, 3 ); >- my $CNsubfield = substr( C4::Context->preference('itemcallnumber'), 3, 1 ); >- if ( $itemrecord and my $field = $itemrecord->field($CNtag) ) { >- $defaultvalue = $field->subfield($CNsubfield); >+ && C4::Context->preference('itemcallnumber') && $itemrecord) { >+ foreach my $itemcn_pref (split(/,/,C4::Context->preference('itemcallnumber'))){ >+ my $CNtag = substr( $itemcn_pref, 0, 3 ); >+ next unless my $field = $itemrecord->field($CNtag); >+ my $CNsubfields = substr( $itemcn_pref, 3 ); >+ $defaultvalue = $field->as_string( $CNsubfields, ' '); >+ last if $defaultvalue; > } > } > if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index babf6d3d4c..0fa84374d9 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -154,12 +154,14 @@ sub generate_subfield_form { > > my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); > if (!$value && $subfieldlib->{kohafield} eq 'items.itemcallnumber' && $pref_itemcallnumber) { >- my $CNtag = substr( $pref_itemcallnumber, 0, 3 ); # 3-digit tag number >- my $CNsubfields = substr( $pref_itemcallnumber, 3 ); # Any and all subfields >- my $temp2 = $temp->field($CNtag); >+ foreach my $pref_itemcallnumber_part (split(/,/, $pref_itemcallnumber)){ >+ my $CNtag = substr( $pref_itemcallnumber_part, 0, 3 ); # 3-digit tag number >+ my $CNsubfields = substr( $pref_itemcallnumber_part, 3 ); # Any and all subfields >+ my $temp2 = $temp->field($CNtag); > >- if ($temp2) { >+ next unless $temp2; > $value = $temp2->as_string( $CNsubfields, ' ' ); >+ last if $value; > } > } > >@@ -881,8 +883,6 @@ foreach my $subfield_code (sort keys(%witness)) { > my @loop_data =(); > my $i=0; > >-my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); >- > my $branch = $input->param('branch') || C4::Context->userenv->{branch}; > my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. > for my $library ( @$libraries ) { >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..61bf51dd44 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 >@@ -72,9 +72,9 @@ Cataloging: > no: bibliographic record > - as the authoritative item type (for determining circulation and fines rules, for displaying an item type icon on either opac detail or results page, etc). > - >- - Map the MARC subfield >+ - Map the MARC subfields > - pref: itemcallnumber >- - "to an item's callnumber. (This can contain multiple subfields to look in; for instance <code>082ab</code> would look in 082 subfields a and b.)<br />Examples (for MARC21 records): <strong>Dewey</strong>: <code>082ab</code> or <code>092ab</code>; <strong>LOC</strong>: <code>050ab</code> or <code>090ab</code>; <strong>from the item record</strong>: <code>852hi</code>" >+ - "to an item's callnumber. List multiple comma-separated fields to check them sequentially. Each field can include multiple subfields. For example: '082ab,092ab' will look in the 082$a and 082$b, then the 092$a and 092$b. Examples (for MARC21 records): Dewey: 082ab,092ab; LOC: 050ab,090ab; from the item record: 952hi" > - > - Display MARC subfield > - pref: AlternateHoldingsField >-- >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 3426
:
96468
|
96498
|
96501
|
96559
|
97636
|
97637