Bugzilla – Attachment 64187 Details for
Bug 10132
Add option to set MarcOrgCode on branch level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10132 - Ability to set MARC Organization Code at library level
Bug-10132---Ability-to-set-MARC-Organization-Code-.patch (text/plain), 5.58 KB, created by
Josef Moravec
on 2017-06-11 20:19:08 UTC
(
hide
)
Description:
Bug 10132 - Ability to set MARC Organization Code at library level
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-06-11 20:19:08 UTC
Size:
5.58 KB
patch
obsolete
>From d9cc1a6c02c1c6eff7db8b971c798f232c523230 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Sun, 11 Jun 2017 19:23:41 +0000 >Subject: [PATCH] Bug 10132 - Ability to set MARC Organization Code at library > level > >Test plan: >0. Apply patches >1. Update database >2. Go to administration -> libraries, try to update some library and >fill in some value into Marc Organization code field >3. Save this library and edit again - the code should be stored >correctly >4. Go to system preferences and fill in some value into MARCOrgCode >preference, note there is enhanced description mentioning the ability to >set organization code on library level >5. Set active library to the one with own org code stored >6. Go to cataloguing, create new empty record and click into field 003 - >there should be the code you filled for that library >7. Set active library to one withou marc org code >8. Go to cataloguing, create new empty record and click into field 003 - >there should be the code from system preference >9. Go to system preferences again and set AutoCreateAuthorities to >'generate' and BiblioAddsAuthorities to 'allow' >10. Go to cataloguing and create some biblio record, fill in any author >in to create its authority record, save the biblio >11. Go to authorities and find this created authority, go to details and >check the fields: 003, 040$a, 040$c, 670$a - there should be used right org code >12. prove t/db_dependent/AuthoritiesMarc.t t/db_dependent/Biblio.t t/db_dependent/Koha/Libraries.t >--- > C4/AuthoritiesMarc.pm | 12 +++++++++--- > C4/Biblio.pm | 7 ++++++- > Koha/Library.pm | 8 ++++++++ > cataloguing/value_builder/marc21_orgcode.pl | 5 ++++- > 4 files changed, 27 insertions(+), 5 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 87620b4..30cf24d 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -32,6 +32,7 @@ use Koha::Authorities; > use Koha::Authority::MergeRequest; > use Koha::Authority::Types; > use Koha::Authority; >+use Koha::Libraries; > use Koha::SearchEngine; > use Koha::SearchEngine::Search; > >@@ -605,12 +606,17 @@ sub AddAuthority { > > SetUTF8Flag($record); > if ($format eq "MARC21") { >+ my $userenv = C4::Context->userenv; >+ my $library; >+ if ( $userenv && $userenv->{'branch'} ) { >+ $library = Koha::Libraries->find( $userenv->{'branch'} ); >+ } > if (!$record->leader) { > $record->leader($leader); > } > if (!$record->field('003')) { > $record->insert_fields_ordered( >- MARC::Field->new('003',C4::Context->preference('MARCOrgCode')) >+ MARC::Field->new('003', $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode')) > ); > } > my $date=POSIX::strftime("%y%m%d",localtime); >@@ -629,8 +635,8 @@ sub AddAuthority { > if (!$record->field('040')) { > $record->insert_fields_ordered( > MARC::Field->new('040','','', >- 'a' => C4::Context->preference('MARCOrgCode'), >- 'c' => C4::Context->preference('MARCOrgCode') >+ 'a' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode'), >+ 'c' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode') > ) > ); > } >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index d52d780..4a6a927 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -572,6 +572,11 @@ sub LinkBibHeadingsToAuthorities { > # of change to a core API just before the 3.0 release. > > if ( C4::Context->preference('marcflavour') eq 'MARC21' ) { >+ my $userenv = C4::Context->userenv; >+ my $library; >+ if ( $userenv && $userenv->{'branch'} ) { >+ $library = Koha::Libraries->find( $userenv->{'branch'} ); >+ } > $marcrecordauth->insert_fields_ordered( > MARC::Field->new( > '667', '', '', >@@ -586,7 +591,7 @@ sub LinkBibHeadingsToAuthorities { > $cite =~ s/[\s\,]*$//; > $cite = > "Work cat.: (" >- . C4::Context->preference('MARCOrgCode') . ")" >+ . ( $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode') ) . ")" > . $bib->subfield( '999', 'c' ) . ": " > . $cite; > $marcrecordauth->insert_fields_ordered( >diff --git a/Koha/Library.pm b/Koha/Library.pm >index 44088ea..7cfb749 100644 >--- a/Koha/Library.pm >+++ b/Koha/Library.pm >@@ -21,6 +21,8 @@ use Modern::Perl; > > use Carp; > >+use C4::Context; >+ > use Koha::Database; > > use base qw(Koha::Object); >@@ -54,6 +56,12 @@ sub add_to_categories { > } > } > >+sub get_effective_marcorgcode { >+ my ( $self ) = @_; >+ >+ return $self->marcorgcode || C4::Context->preference("MARCOrgCode"); >+} >+ > =head3 type > > =cut >diff --git a/cataloguing/value_builder/marc21_orgcode.pl b/cataloguing/value_builder/marc21_orgcode.pl >index 48a30ab..6724fc8 100755 >--- a/cataloguing/value_builder/marc21_orgcode.pl >+++ b/cataloguing/value_builder/marc21_orgcode.pl >@@ -23,9 +23,12 @@ > use Modern::Perl; > use C4::Context; > >+use Koha::Libraries; >+ > my $builder = sub { > my ( $params ) = @_; >- my $org = C4::Context->preference('MARCOrgCode'); >+ my $library = Koha::Libraries->find( C4::Context->userenv->{'branch'} ); >+ my $org = $library->get_effective_marcorgcode; > return <<"HERE"; > <script type=\"text/javascript\"> > //<![CDATA[ >-- >2.1.4
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 10132
:
64183
|
64184
|
64185
|
64186
|
64187
|
67060
|
67061
|
67062
|
67063
|
67064
|
67065
|
67066
|
67067
|
67208
|
67211