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

(-)a/Koha/Authority.pm (-30 / +15 lines)
Lines 113-151 sub controlled_indicators { Link Here
113
    });
113
    });
114
}
114
}
115
115
116
=head3 get_identifiers
116
=head3 get_identifiers_and_information
117
117
118
    my $identifiers = $author->get_identifiers;
118
    my $information = $author->get_identifiers_and_information;
119
119
120
Return a list of identifiers of the authors which are in 024$2$a
120
Return a list of information of the authors (syspref OPACAuthorIdentifiersAndInformation)
121
121
122
=cut
122
=cut
123
123
124
sub get_identifiers {
124
sub get_identifiers_and_information {
125
    my ( $self ) = @_;
126
127
    my $record = $self->record;
128
129
    my @identifiers;
130
    for my $field ( $record->field('024') ) {
131
        my $sf_2 = $field->subfield('2');
132
        my $sf_a = $field->subfield('a');
133
        next unless $sf_2 && $sf_a;
134
        push @identifiers, {source => $sf_2, number => $sf_a, };
135
    }
136
137
    return \@identifiers;
138
}
139
140
=head3 get_information
141
142
    my $information = $author->get_information;
143
144
Return a list of information of the authors (syspref OPACAuthorInformation)
145
146
=cut
147
148
sub get_information {
149
    my ($self) = @_;
125
    my ($self) = @_;
150
126
151
    my $record = $self->record;
127
    my $record = $self->record;
Lines 154-161 sub get_information { Link Here
154
    return if C4::Context->preference('marcflavour') eq 'UNIMARC';
130
    return if C4::Context->preference('marcflavour') eq 'UNIMARC';
155
131
156
    my $information;
132
    my $information;
157
    for my $info ( split ',', C4::Context->preference('OPACAuthorInformation') ) {
133
    for my $info ( split ',', C4::Context->preference('OPACAuthorIdentifiersAndInformation') ) {
158
        if ( $info eq 'activity' ) {
134
        if ( $info eq 'identifiers' ) {
135
136
            # identifiers (024$2$a)
137
            for my $field ( $record->field('024') ) {
138
                my $sf_2 = $field->subfield('2');
139
                my $sf_a = $field->subfield('a');
140
                next unless $sf_2 && $sf_a;
141
                push @{ $information->{identifiers} }, { source => $sf_2, number => $sf_a, };
142
            }
143
        } elsif ( $info eq 'activity' ) {
159
144
160
            # activity: Activity (372$a$s$t)
145
            # activity: Activity (372$a$s$t)
161
            for my $field ( $record->field('372') ) {
146
            for my $field ( $record->field('372') ) {
(-)a/installer/data/mysql/atomicupdate/bug_29948.pl (-7 / +15 lines)
Lines 1-16 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
return {
3
return {
4
    bug_number => "29948",
4
    bug_number  => "29948",
5
    description => "Display author information for researchers",
5
    description => "Display author information for researchers",
6
    up => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        $dbh->do(q{
9
        my ($OPACAuthorIdentifiers) =
10
            $dbh->selectrow_array(q{SELECT value FROM systempreferences WHERE variable="OPACAuthorIdentifiers"});
11
        my $value = $OPACAuthorIdentifiers ? 'identifiers' : '';
12
13
        $dbh->do(
14
            q{
10
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
15
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
11
            ('OPACAuthorInformation','0','','Display author information on the OPAC detail page','multiple_sortable')
16
            ('OPACAuthorIdentifiersAndInformation', ?, '', 'Display author information on the OPAC detail page','multiple_sortable')
12
        });
17
        }, undef, $value
18
        );
19
        say $out "Added new system preference 'OPACAuthorIdentifiersAndInformation'";
13
20
14
        say $out "Added new system preference 'OPACAuthorInformation'";
21
        $dbh->do(q{DELETE FROM systempreferences WHERE variable="OPACAuthorIdentifiers"});
22
        say $out "  Removed system preference 'OPACAuthorIdentifiers'";
15
    },
23
    },
16
};
24
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-10 / +5 lines)
Lines 524-550 OPAC: Link Here
524
                  1: Enable
524
                  1: Enable
525
                  0: Disable
525
                  0: Disable
526
            - "interface for browsing all holdings (Elasticsearch only)."
526
            - "interface for browsing all holdings (Elasticsearch only)."
527
        -
528
            - pref: OPACAuthorIdentifiers
529
              default: 0
530
              choices:
531
                  1: Display
532
                  0: "Don't display"
533
            - "identifiers for authors and contributors to the detail pages in the OPAC."
534
            - "This feature requires authorities with 024$2 and 024$a."
535
            - "Valid source codes in $2 are currently: orcid, scopus, loop, rid and viaf."
536
        -
527
        -
537
            - "Display the following information for authors and contributors to the detail pages in the OPAC."
528
            - "Display the following information for authors and contributors to the detail pages in the OPAC."
538
            - pref: OPACAuthorInformation
529
            - pref: OPACAuthorIdentifiersAndInformation
539
              multiple:
530
              multiple:
540
                activity: Activity (372$a$s$t)
531
                activity: Activity (372$a$s$t)
541
                address: Address (371$a$b$d$e)
532
                address: Address (371$a$b$d$e)
542
                associated_group: Associated group (373$a$s$t$u$v$0)
533
                associated_group: Associated group (373$a$s$t$u$v$0)
543
                email_address: Electronic mail address (371$m)
534
                email_address: Electronic mail address (371$m)
535
                identifiers: Identifiers (024$2$a)
544
                occupation: Occupation (374$a$s$t$u$v$0)
536
                occupation: Occupation (374$a$s$t$u$v$0)
545
                place_of_birth: Place of birth (370$a)
537
                place_of_birth: Place of birth (370$a)
546
                place_of_death: Place of death (370$b)
538
                place_of_death: Place of death (370$b)
547
                uri: URI (371$u)
539
                uri: URI (371$u)
540
            - "<p>Indentifiers: identifiers for authors and contributors to the detail pages in the OPAC."
541
            - "This feature requires authorities with 024$2 and 024$a."
542
            - "Valid source codes in $2 are currently: orcid, scopus, loop, rid and viaf.</p>"
548
        -
543
        -
549
            - "Calculate the amount a patron has 'saved' by using the library based on replacement prices, and display:"
544
            - "Calculate the amount a patron has 'saved' by using the library based on replacement prices, and display:"
550
            - pref: OPACShowSavings
545
            - pref: OPACShowSavings
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-identifiers.inc (-27 lines)
Lines 1-27 Link Here
1
[% SWITCH identifier.source.lower %]
2
[% CASE 'orcid' %]
3
    <li>
4
        <span>ORCID: </span>
5
        <a href="https://orcid.org/[% identifier.number | url %]">[% identifier.number | html %]</a>
6
    </li>
7
[% CASE 'scopus' %]
8
    <li>
9
        <span>ScopusID: </span>
10
        <a href="https://www.scopus.com/authid/detail.uri?authorId=[% identifier.number | url %]">[% identifier.number | html %]</a>
11
    </li>
12
[% CASE 'loop' %]
13
    <li>
14
        <span>loop: </span>
15
        <a href="https://loop.frontiersin.org/people/[% identifier.number | url %]">[% identifier.number | html %]</a>
16
    </li>
17
[% CASE 'rid' %]
18
    <li>
19
        <span>Publons: </span>
20
        <a href="https://publons.com/researcher/[% identifier.number | url %]">[% identifier.number | html %]</a>
21
    </li>
22
[% CASE 'viaf' %]
23
    <li>
24
        <span>VIAF: </span>
25
        <a href="https://viaf.org/viaf/[% identifier.number | url %]">[% identifier.number | html %]</a>
26
    </li>
27
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc (+20 lines)
Lines 1-5 Link Here
1
[% FOREACH info IN information %]
1
[% FOREACH info IN information %]
2
    [% SWITCH info_type %]
2
    [% SWITCH info_type %]
3
    [% CASE 'identifiers' %]
4
        <li>
5
        [% SWITCH info.source.lower %]
6
            [% CASE 'orcid' %]
7
                <span>ORCID: </span>
8
                <a href="https://orcid.org/[% info.number | url %]">[% info.number | html %]</a>
9
            [% CASE 'scopus' %]
10
                <span>ScopusID: </span>
11
                <a href="https://www.scopus.com/authid/detail.uri?authorId=[% info.number | url %]">[% info.number | html %]</a>
12
            [% CASE 'loop' %]
13
                <span>loop: </span>
14
                <a href="https://loop.frontiersin.org/people/[% info.number | url %]">[% info.number | html %]</a>
15
            [% CASE 'rid' %]
16
                <span>Publons: </span>
17
                <a href="https://publons.com/researcher/[% info.number | url %]">[% info.number | html %]</a>
18
            [% CASE 'viaf' %]
19
                <span>VIAF: </span>
20
                <a href="https://viaf.org/viaf/[% info.number | url %]">[% info.number | html %]</a>
21
            [% END %]
22
        </li>
3
    [% CASE 'activity' %]
23
    [% CASE 'activity' %]
4
        <li>
24
        <li>
5
            <span>
25
            <span>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt (-7 / +7 lines)
Lines 38-49 Link Here
38
                            [% INCLUDE 'navigation.inc' %]
38
                            [% INCLUDE 'navigation.inc' %]
39
                        </div>
39
                        </div>
40
                    </div>
40
                    </div>
41
                    [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
41
                    [% IF Koha.Preference( 'OPACAuthorIdentifiersAndInformation' ) && author_information.size %]
42
                        <div class="col-lg-5 order-first order-md-first order-lg-2">
42
                        <div class="col-lg-5 order-first order-md-first order-lg-2">
43
                    [% ELSE %]
43
                    [% ELSE %]
44
                        <div class="col-lg-10 order-first order-md-first order-lg-2">
44
                        <div class="col-lg-10 order-first order-md-first order-lg-2">
45
                    [% END %]
45
                    [% END %]
46
                [% ELSIF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
46
                [% ELSIF Koha.Preference( 'OPACAuthorIdentifiersAndInformation' ) && author_information.size %]
47
                    <div class="col-lg-6 order-first order-md-first order-lg-2">
47
                    <div class="col-lg-6 order-first order-md-first order-lg-2">
48
                [% ELSE %]
48
                [% ELSE %]
49
                    <div class="col order-first order-md-first order-lg-2">
49
                    <div class="col order-first order-md-first order-lg-2">
Lines 176-192 Link Here
176
176
177
                    </div> <!-- / .#userauthdetails -->
177
                    </div> <!-- / .#userauthdetails -->
178
                </div> <!-- / .col-lg-10/12 -->
178
                </div> <!-- / .col-lg-10/12 -->
179
                [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
179
                [% IF Koha.Preference( 'OPACAuthorIdentifiersAndInformation' ) && author_information.size %]
180
                    [% IF ( OpacNav || OpacNavBottom ) %]
180
                    [% IF ( OpacNav || OpacNavBottom ) %]
181
                        <div class="col-lg-5 order-lg-3">
181
                        <div class="col-lg-5 order-lg-3">
182
                    [% ELSE %]
182
                    [% ELSE %]
183
                        <div class="col-lg-6 order-lg-3">
183
                        <div class="col-lg-6 order-lg-3">
184
                    [% END %]
184
                    [% END %]
185
                        <div class="author_identifier">
185
                        <div class="author_identifier_info">
186
                            <span>Identifiers</span>
186
                            <span>Identifiers/information</span>
187
                            <ul>
187
                            <ul>
188
                            [% FOR identifier IN author_identifiers %]
188
                            [% FOR info IN author_information.keys %]
189
                                [% PROCESS "authority-identifiers.inc" identifier => identifier %]
189
                                [% PROCESS "authority-information.inc" information => author_information.$info, info_type => info %]
190
                            [% END %]
190
                            [% END %]
191
                            </ul>
191
                            </ul>
192
                        </div>
192
                        </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-18 / +3 lines)
Lines 493-506 Link Here
493
                            [% END %]
493
                            [% END %]
494
                        [% END %]
494
                        [% END %]
495
495
496
                        [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size || Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
496
                        [% IF Koha.Preference( 'OPACAuthorIdentifiersAndInformation' ) && author_information.size %]
497
                            [% WRAPPER tab_item tabname= "author_identifiers_info" %]
497
                            [% WRAPPER tab_item tabname= "author_identifiers_info" %]
498
                                [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size && Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
498
                                [% IF Koha.Preference( 'OPACAuthorIdentifiersAndInformation' ) && author_information.size %]
499
                                    <span>Author identifiers/information</span>
499
                                    <span>Author identifiers/information</span>
500
                                [% ELSIF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %]
501
                                    <span>Author identifiers</span>
502
                                [% ELSIF Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
503
                                    <span>Author information</span>
504
                                [% END %]
500
                                [% END %]
505
                            [% END %]
501
                            [% END %]
506
                        [% END %]
502
                        [% END %]
Lines 947-953 Link Here
947
                            [% END # /tab_panel#images %]
943
                            [% END # /tab_panel#images %]
948
                        [% END # / IF OPACLocalCoverImages && localimages.size %]
944
                        [% END # / IF OPACLocalCoverImages && localimages.size %]
949
945
950
                        [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size || Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %]
946
                        [% IF Koha.Preference( 'OPACAuthorIdentifiersAndInformation' ) && author_information.size %]
951
                            [% WRAPPER tab_panel tabname="author_identifiers_info" %]
947
                            [% WRAPPER tab_panel tabname="author_identifiers_info" %]
952
                                [% FOR author IN author_information %]
948
                                [% FOR author IN author_information %]
953
                                    <div class="author_information">
949
                                    <div class="author_information">
Lines 959-975 Link Here
959
                                        </ul>
955
                                        </ul>
960
                                    </div>
956
                                    </div>
961
                                [% END %]
957
                                [% END %]
962
963
                                [% FOR author IN author_identifiers %]
964
                                    <div class="author_identifier">
965
                                        <span class="author_name"><a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% author.authid | uri %]">[% author.name | html %]</a></span>
966
                                        <ul>
967
                                        [% FOR identifier IN author.identifiers %]
968
                                            [% PROCESS "authority-identifiers.inc" identifier => identifier %]
969
                                        [% END %]
970
                                        </ul>
971
                                    </div>
972
                                [% END %]
973
                            [% END # /tab_panel#author_identifiers_info %]
958
                            [% END # /tab_panel#author_identifiers_info %]
974
                        [% END %]
959
                        [% END %]
975
960
(-)a/opac/opac-authoritiesdetail.pl (-3 / +3 lines)
Lines 188-197 if ($show_marc) { Link Here
188
        $template->param(summary => $summary);
188
        $template->param(summary => $summary);
189
    }
189
    }
190
190
191
    if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
191
    if ( C4::Context->preference('OPACAuthorIdentifiersAndInformation') ) {
192
        my $authority = Koha::Authorities->find($authid);
192
        my $authority = Koha::Authorities->find($authid);
193
        my $identifiers = $authority->get_identifiers;
193
        my $information = $authority->get_identifiers_and_information;
194
        $template->param( author_identifiers => $identifiers );
194
        $template->param( author_information => $information );
195
    }
195
    }
196
}
196
}
197
197
(-)a/opac/opac-detail.pl (-21 / +3 lines)
Lines 1227-1264 $template->param( Link Here
1227
    'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1227
    'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'),
1228
);
1228
);
1229
1229
1230
if ( C4::Context->preference('OPACAuthorIdentifiers') ) {
1230
if ( C4::Context->preference('OPACAuthorIdentifiersAndInformation') ) {
1231
    my @author_identifiers;
1232
    for my $author ( @{ $biblio->get_marc_authors } ) {
1233
        my $authid    = $author->{authoritylink};
1234
        my $authority = Koha::Authorities->find($authid);
1235
        next unless $authority;
1236
        my $identifiers = $authority->get_identifiers;
1237
        next unless $identifiers && @$identifiers;
1238
        my ($name) =
1239
          map  { $_->{value} }
1240
          grep { $_->{code} eq 'a' ? $_ : () }
1241
          @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
1242
        push @author_identifiers,
1243
          { authid => $authid, name => $name, identifiers => $identifiers };
1244
    }
1245
    $template->param( author_identifiers => \@author_identifiers );
1246
}
1247
1248
if ( C4::Context->preference('OPACAuthorInformation') ) {
1249
    my @author_information;
1231
    my @author_information;
1250
    for my $author ( @{ $biblio->get_marc_authors } ) {
1232
    for my $author ( @{ $biblio->get_marc_authors } ) {
1251
        my $authid    = $author->{authoritylink};
1233
        my $authid    = $author->{authoritylink};
1252
        my $authority = Koha::Authorities->find($authid);
1234
        my $authority = Koha::Authorities->find($authid);
1253
        next unless $authority;
1235
        next unless $authority;
1254
        my $information = $authority->get_information;
1236
        my $information = $authority->get_identifiers_and_information;
1255
        next unless $information;
1237
        next unless $information;
1256
        my ($name) =
1238
        my ($name) =
1257
          map  { $_->{value} }
1239
          map  { $_->{value} }
1258
          grep { $_->{code} eq 'a' ? $_ : () }
1240
          grep { $_->{code} eq 'a' ? $_ : () }
1259
          @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
1241
          @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} };
1260
        push @author_information,
1242
        push @author_information,
1261
          { authid => $authid, name => $name, information => $information };
1243
          { authid => $authid, name => $name, information => $information};
1262
    }
1244
    }
1263
    $template->param( author_information => \@author_information );
1245
    $template->param( author_information => \@author_information );
1264
}
1246
}
(-)a/t/db_dependent/Koha/Authorities.t (-13 / +15 lines)
Lines 242-251 sub few_marc_records { Link Here
242
    return [ $marc ];
242
    return [ $marc ];
243
}
243
}
244
244
245
subtest 'get_identifiers' => sub {
245
subtest 'get_identifiers_and_information' => sub {
246
    plan tests => 1;
246
    plan tests => 1;
247
247
248
    t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
248
    t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
249
    t::lib::Mocks::mock_preference( 'OPACAuthorIdentifiersAndInformation', 'identifiers' );
249
    my $record = MARC::Record->new();
250
    my $record = MARC::Record->new();
250
    $record->add_fields(
251
    $record->add_fields(
251
        [
252
        [
Lines 271-287 subtest 'get_identifiers' => sub { Link Here
271
    my $authid = C4::AuthoritiesMarc::AddAuthority($record, undef, 'PERSO_NAME');
272
    my $authid = C4::AuthoritiesMarc::AddAuthority($record, undef, 'PERSO_NAME');
272
    my $authority = Koha::Authorities->find($authid);
273
    my $authority = Koha::Authorities->find($authid);
273
    is_deeply(
274
    is_deeply(
274
        $authority->get_identifiers,
275
        $authority->get_identifiers_and_information,
275
        [
276
        {
276
            {
277
            identifiers => [
277
                source  => 'orcid',
278
                {
278
                number  => '0000-0002-1234-5678',
279
                    source => 'orcid',
279
            },
280
                    number => '0000-0002-1234-5678',
280
            {
281
                },
281
                source => 'scopus',
282
                {
282
                number => '01234567890',
283
                    source => 'scopus',
283
            }
284
                    number => '01234567890',
284
        ]
285
                }
286
            ]
287
        }
285
    );
288
    );
286
};
289
};
287
290
288
- 

Return to bug 29948