View | Details | Raw Unified | Return to bug 10132
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-3 / +9 lines)
Lines 32-37 use Koha::Authorities; Link Here
32
use Koha::Authority::MergeRequest;
32
use Koha::Authority::MergeRequest;
33
use Koha::Authority::Types;
33
use Koha::Authority::Types;
34
use Koha::Authority;
34
use Koha::Authority;
35
use Koha::Libraries;
35
use Koha::SearchEngine;
36
use Koha::SearchEngine;
36
use Koha::SearchEngine::Search;
37
use Koha::SearchEngine::Search;
37
38
Lines 605-616 sub AddAuthority { Link Here
605
606
606
    SetUTF8Flag($record);
607
    SetUTF8Flag($record);
607
	if ($format eq "MARC21") {
608
	if ($format eq "MARC21") {
609
        my $userenv = C4::Context->userenv;
610
        my $library;
611
        if ( $userenv && $userenv->{'branch'} ) {
612
            $library = Koha::Libraries->find( $userenv->{'branch'} );
613
        }
608
		if (!$record->leader) {
614
		if (!$record->leader) {
609
			$record->leader($leader);
615
			$record->leader($leader);
610
		}
616
		}
611
		if (!$record->field('003')) {
617
		if (!$record->field('003')) {
612
			$record->insert_fields_ordered(
618
			$record->insert_fields_ordered(
613
				MARC::Field->new('003',C4::Context->preference('MARCOrgCode'))
619
                MARC::Field->new('003', $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode'))
614
			);
620
			);
615
		}
621
		}
616
		my $date=POSIX::strftime("%y%m%d",localtime);
622
		my $date=POSIX::strftime("%y%m%d",localtime);
Lines 629-636 sub AddAuthority { Link Here
629
		if (!$record->field('040')) {
635
		if (!$record->field('040')) {
630
		 $record->insert_fields_ordered(
636
		 $record->insert_fields_ordered(
631
        MARC::Field->new('040','','',
637
        MARC::Field->new('040','','',
632
				'a' => C4::Context->preference('MARCOrgCode'),
638
            'a' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode'),
633
				'c' => C4::Context->preference('MARCOrgCode')
639
            'c' => $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode')
634
				) 
640
				) 
635
			);
641
			);
636
    }
642
    }
(-)a/C4/Biblio.pm (-1 / +6 lines)
Lines 569-574 sub LinkBibHeadingsToAuthorities { Link Here
569
# of change to a core API just before the 3.0 release.
569
# of change to a core API just before the 3.0 release.
570
570
571
                    if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
571
                    if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
572
                        my $userenv = C4::Context->userenv;
573
                        my $library;
574
                        if ( $userenv && $userenv->{'branch'} ) {
575
                            $library = Koha::Libraries->find( $userenv->{'branch'} );
576
                        }
572
                        $marcrecordauth->insert_fields_ordered(
577
                        $marcrecordauth->insert_fields_ordered(
573
                            MARC::Field->new(
578
                            MARC::Field->new(
574
                                '667', '', '',
579
                                '667', '', '',
Lines 583-589 sub LinkBibHeadingsToAuthorities { Link Here
583
                        $cite =~ s/[\s\,]*$//;
588
                        $cite =~ s/[\s\,]*$//;
584
                        $cite =
589
                        $cite =
585
                            "Work cat.: ("
590
                            "Work cat.: ("
586
                          . C4::Context->preference('MARCOrgCode') . ")"
591
                          . ( $library ? $library->get_effective_marcorgcode : C4::Context->preference('MARCOrgCode') ) . ")"
587
                          . $bib->subfield( '999', 'c' ) . ": "
592
                          . $bib->subfield( '999', 'c' ) . ": "
588
                          . $cite;
593
                          . $cite;
589
                        $marcrecordauth->insert_fields_ordered(
594
                        $marcrecordauth->insert_fields_ordered(
(-)a/Koha/Library.pm (+8 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Carp;
22
use Carp;
23
23
24
use C4::Context;
25
24
use Koha::Database;
26
use Koha::Database;
25
27
26
use base qw(Koha::Object);
28
use base qw(Koha::Object);
Lines 54-59 sub add_to_categories { Link Here
54
    }
56
    }
55
}
57
}
56
58
59
sub get_effective_marcorgcode {
60
    my ( $self )  = @_;
61
62
    return $self->marcorgcode || C4::Context->preference("MARCOrgCode");
63
}
64
57
=head3 type
65
=head3 type
58
66
59
=cut
67
=cut
(-)a/cataloguing/value_builder/marc21_orgcode.pl (-2 / +4 lines)
Lines 23-31 Link Here
23
use Modern::Perl;
23
use Modern::Perl;
24
use C4::Context;
24
use C4::Context;
25
25
26
use Koha::Libraries;
27
26
my $builder = sub {
28
my $builder = sub {
27
    my ( $params ) = @_;
29
    my ( $params ) = @_;
28
    my $org = C4::Context->preference('MARCOrgCode');
30
    my $library = Koha::Libraries->find( C4::Context->userenv->{'branch'} );
31
    my $org = $library->get_effective_marcorgcode;
29
    return <<"HERE";
32
    return <<"HERE";
30
<script type=\"text/javascript\">
33
<script type=\"text/javascript\">
31
//<![CDATA[
34
//<![CDATA[
32
- 

Return to bug 10132