From 80c749df80f08be46b895715045b38cd1ded2ed1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 19 Sep 2017 09:59:36 -0300 Subject: [PATCH] Bug 10132: Simplify code, call the method only once Signed-off-by: Jonathan Druart --- C4/AuthoritiesMarc.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index ac109dee40..160ff4ad6a 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -608,15 +608,17 @@ sub AddAuthority { if ($format eq "MARC21") { my $userenv = C4::Context->userenv; my $library; + my $marcorgcode = C4::Context->preference('MARCOrgCode'); if ( $userenv && $userenv->{'branch'} ) { $library = Koha::Libraries->find( $userenv->{'branch'} ); + $marcorgcode = $library->get_effective_marcorgcode; } if (!$record->leader) { $record->leader($leader); } if (!$record->field('003')) { $record->insert_fields_ordered( - MARC::Field->new('003', $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode')) + MARC::Field->new('003', $marcorgcode), ); } my $date=POSIX::strftime("%y%m%d",localtime); @@ -635,8 +637,8 @@ sub AddAuthority { if (!$record->field('040')) { $record->insert_fields_ordered( MARC::Field->new('040','','', - 'a' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode'), - 'c' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode') + 'a' => $marcorgcode, + 'c' => $marcorgcode, ) ); } -- 2.39.5