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

(-)a/Koha/MarcEditor.pm (-15 / +16 lines)
Lines 21-28 package Koha::MarcEditor; Link Here
21
21
22
use Modern::Perl;
22
use Modern::Perl;
23
23
24
use Readonly;
24
use C4::Biblio;
25
26
use C4::ClassSource;
25
use C4::ClassSource;
27
use C4::Context;
26
use C4::Context;
28
27
Lines 31-38 use Koha::DateUtils; Link Here
31
use base qw(Class::Accessor);
30
use base qw(Class::Accessor);
32
31
33
# Constants to refer to the standard editor types
32
# Constants to refer to the standard editor types
34
Readonly our $EDITOR_BIBLIO    => 'biblio';
33
use constant {
35
Readonly our $EDITOR_AUTHORITY => 'authority';
34
    EDITOR_BIBLIO    => 'biblio',
35
    EDITOR_AUTHORITY => 'authority',
36
};
36
37
37
=head1 NAME
38
=head1 NAME
38
39
Lines 47-53 Koha::MarcEditor - Koha MARC Editor class Link Here
47
=head2 new
48
=head2 new
48
49
49
    my $editor = Koha::MarcEditor->new({
50
    my $editor = Koha::MarcEditor->new({
50
        type => $Koha::MarcEditor::EDITOR_BIBLIO,
51
        type => Koha::MarcEditor::EDITOR_BIBLIO,
51
        tags => $self->{tags},
52
        tags => $self->{tags},
52
        used_tags => $tagsUsedLib,
53
        used_tags => $tagsUsedLib,
53
        mandatory_z3950 => $mandatory_z3950,
54
        mandatory_z3950 => $mandatory_z3950,
Lines 152-158 sub build_tabs { Link Here
152
                        }
153
                        }
153
                        next if ( $self->{tags}->{$tag}->{$subfield}->{tab} ne $tabloop );
154
                        next if ( $self->{tags}->{$tag}->{$subfield}->{tab} ne $tabloop );
154
                        next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
155
                        next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
155
                            && $self->{type} eq $Koha::MarcEditor::EDITOR_AUTHORITY;
156
                            && $self->{type} eq Koha::MarcEditor::EDITOR_AUTHORITY;
156
                        next
157
                        next
157
                          if ( $self->{tags}->{$tag}->{$subfield}->{kohafield} eq
158
                          if ( $self->{tags}->{$tag}->{$subfield}->{kohafield} eq
158
                            'biblio.biblionumber' );
159
                            'biblio.biblionumber' );
Lines 171-177 sub build_tabs { Link Here
171
                            next if ( length $subfield != 1 );
172
                            next if ( length $subfield != 1 );
172
                            next if ( $self->{tags}->{$tag}->{$subfield}->{tab} ne $tabloop );
173
                            next if ( $self->{tags}->{$tag}->{$subfield}->{tab} ne $tabloop );
173
                            next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
174
                            next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
174
                                && $self->{type} eq $Koha::MarcEditor::EDITOR_AUTHORITY;
175
                                && $self->{type} eq Koha::MarcEditor::EDITOR_AUTHORITY;
175
                            push(
176
                            push(
176
                                @subfields_data,
177
                                @subfields_data,
177
                                $self->_create_input(
178
                                $self->_create_input(
Lines 188-198 sub build_tabs { Link Here
188
                        next if ( $self->{tags}->{$tag}->{$subfield}->{tab} ne $tabloop );
189
                        next if ( $self->{tags}->{$tag}->{$subfield}->{tab} ne $tabloop );
189
                        next if ( $tag < 10 );
190
                        next if ( $tag < 10 );
190
                        next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
191
                        next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
191
                            && $self->{type} eq $Koha::MarcEditor::EDITOR_AUTHORITY;
192
                            && $self->{type} eq Koha::MarcEditor::EDITOR_AUTHORITY;
192
                        next
193
                        next
193
                          if ( ( $self->{tags}->{$tag}->{$subfield}->{hidden} <= -4 )
194
                          if ( ( $self->{tags}->{$tag}->{$subfield}->{hidden} <= -4 )
194
                            or ( $self->{tags}->{$tag}->{$subfield}->{hidden} >= 5 ) )
195
                            or ( $self->{tags}->{$tag}->{$subfield}->{hidden} >= 5 ) )
195
                            and $self->{type} ne $Koha::MarcEditor::EDITOR_AUTHORITY
196
                            and $self->{type} ne Koha::MarcEditor::EDITOR_AUTHORITY
196
                            and not ( $subfield eq "9" and
197
                            and not ( $subfield eq "9" and
197
                                      exists($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
198
                                      exists($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
198
                                      defined($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
199
                                      defined($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
Lines 239-249 sub build_tabs { Link Here
239
                foreach my $subfield ( sort( keys %{ $self->{tags}->{$tag} } ) ) {
240
                foreach my $subfield ( sort( keys %{ $self->{tags}->{$tag} } ) ) {
240
                    next if ( length $subfield != 1 );
241
                    next if ( length $subfield != 1 );
241
                    next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
242
                    next if $self->{tags}->{$tag}->{$subfield}->{hidden} && $subfield ne '9'
242
                        && $self->{type} eq $Koha::MarcEditor::EDITOR_AUTHORITY;
243
                        && $self->{type} eq Koha::MarcEditor::EDITOR_AUTHORITY;
243
                    next
244
                    next
244
                      if ( ( $self->{tags}->{$tag}->{$subfield}->{hidden} <= -4 )
245
                      if ( ( $self->{tags}->{$tag}->{$subfield}->{hidden} <= -4 )
245
                        or ( $self->{tags}->{$tag}->{$subfield}->{hidden} >= 5 ) )
246
                        or ( $self->{tags}->{$tag}->{$subfield}->{hidden} >= 5 ) )
246
                        and $self->{type} ne $Koha::MarcEditor::EDITOR_AUTHORITY
247
                        and $self->{type} ne Koha::MarcEditor::EDITOR_AUTHORITY
247
                        and not ( $subfield eq "9" and
248
                        and not ( $subfield eq "9" and
248
                                exists($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
249
                                exists($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
249
                                defined($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
250
                                defined($self->{tags}->{$tag}->{'a'}->{authtypecode}) and
Lines 365-371 sub _build_authorized_values_list { Link Here
365
        $value = $default_source unless $value;
366
        $value = $default_source unless $value;
366
    }
367
    }
367
    else {
368
    else {
368
        my $branch_limit = $self->{type} ne $Koha::MarcEditor::EDITOR_AUTHORITY && C4::Context->userenv
369
        my $branch_limit = $self->{type} ne Koha::MarcEditor::EDITOR_AUTHORITY && C4::Context->userenv
369
            ? C4::Context->userenv->{'branch'} : '';
370
            ? C4::Context->userenv->{'branch'} : '';
370
371
371
        my $query;
372
        my $query;
Lines 459-465 sub _create_input { Link Here
459
        $subfield_data{z3950_mandatory} = $self->{mandatory_z3950}->{$tag.$subfield};
460
        $subfield_data{z3950_mandatory} = $self->{mandatory_z3950}->{$tag.$subfield};
460
    }
461
    }
461
462
462
    if ($self->{type} eq $Koha::MarcEditor::EDITOR_AUTHORITY) {
463
    if ($self->{type} eq Koha::MarcEditor::EDITOR_AUTHORITY) {
463
        # Authority subfield is hidden unless mandatory or contains something.
464
        # Authority subfield is hidden unless mandatory or contains something.
464
        $subfield_data{visibility} = "display:none;"
465
        $subfield_data{visibility} = "display:none;"
465
            if( $tagdef->{$subfield}->{hidden} and $value ne ''
466
            if( $tagdef->{$subfield}->{hidden} and $value ne ''
Lines 485-491 sub _create_input { Link Here
485
486
486
    # it's a subfield $9 linking to an authority record - see bug 2206
487
    # it's a subfield $9 linking to an authority record - see bug 2206
487
    }
488
    }
488
    elsif ($self->{type} eq $Koha::MarcEditor::EDITOR_BIBLIO and
489
    elsif ($self->{type} eq Koha::MarcEditor::EDITOR_BIBLIO and
489
           $subfield eq "9" and
490
           $subfield eq "9" and
490
           exists($tagdef->{'a'}->{authtypecode}) and
491
           exists($tagdef->{'a'}->{authtypecode}) and
491
           defined($tagdef->{'a'}->{authtypecode}) and
492
           defined($tagdef->{'a'}->{authtypecode}) and
Lines 505-511 sub _create_input { Link Here
505
    }
506
    }
506
    elsif ( $tagdef->{$subfield}->{authtypecode} ) {
507
    elsif ( $tagdef->{$subfield}->{authtypecode} ) {
507
        # when authorities auto-creation is allowed, do not set readonly
508
        # when authorities auto-creation is allowed, do not set readonly
508
        my $is_readonly = $self->{type} eq $Koha::MarcEditor::EDITOR_BIBLIO && !C4::Context->preference("BiblioAddsAuthorities");
509
        my $is_readonly = $self->{type} eq Koha::MarcEditor::EDITOR_BIBLIO && !C4::Context->preference("BiblioAddsAuthorities");
509
510
510
        $subfield_data{marc_value} = {
511
        $subfield_data{marc_value} = {
511
            type      => 'text',
512
            type      => 'text',
(-)a/authorities/authorities.pl (-1 / +1 lines)
Lines 132-138 if ($breedingid) { Link Here
132
132
133
133
134
my $editor = Koha::MarcEditor->new({
134
my $editor = Koha::MarcEditor->new({
135
    type => $Koha::MarcEditor::EDITOR_AUTHORITY,
135
    type => Koha::MarcEditor::EDITOR_AUTHORITY,
136
    tags => GetTagsLabels(1,$authtypecode),
136
    tags => GetTagsLabels(1,$authtypecode),
137
    mandatory_z3950 => GetMandatoryFieldZ3950($authtypecode)
137
    mandatory_z3950 => GetMandatoryFieldZ3950($authtypecode)
138
});
138
});
(-)a/cataloguing/addbiblio.pl (-2 / +1 lines)
Lines 261-267 $template->param( Link Here
261
);
261
);
262
262
263
my $editor = Koha::MarcEditor->new({
263
my $editor = Koha::MarcEditor->new({
264
    type => $Koha::MarcEditor::EDITOR_BIBLIO,
264
    type => Koha::MarcEditor::EDITOR_BIBLIO,
265
    tags => GetMarcStructure( 1, $frameworkcode ),
265
    tags => GetMarcStructure( 1, $frameworkcode ),
266
    used_tags => GetUsedMarcStructure( $frameworkcode ),
266
    used_tags => GetUsedMarcStructure( $frameworkcode ),
267
    mandatory_z3950 => GetMandatoryFieldZ3950($frameworkcode),
267
    mandatory_z3950 => GetMandatoryFieldZ3950($frameworkcode),
268
- 

Return to bug 21280