From 97a245785cf4b9b0a4201c0d86d780609f74eb95 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Mar 2024 16:07:47 +0100 Subject: [PATCH] Bug 29948: Display authors information along with the identifiers Sponsored-by: Orex Digital --- Koha/Authority.pm | 108 +++++++++++++++++- .../data/mysql/atomicupdate/bug_29948.pl | 16 +++ .../en/modules/admin/preferences/opac.pref | 12 ++ .../en/includes/authority-information.inc | 74 ++++++++++++ .../bootstrap/en/modules/opac-detail.tt | 29 ++++- opac/opac-detail.pl | 18 +++ 6 files changed, 250 insertions(+), 7 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29948.pl create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc diff --git a/Koha/Authority.pm b/Koha/Authority.pm index 509d2f9ae71..52f0b9127db 100644 --- a/Koha/Authority.pm +++ b/Koha/Authority.pm @@ -122,7 +122,7 @@ Return a list of identifiers of the authors which are in 024$2$a =cut sub get_identifiers { - my ( $self, $params ) = @_; + my ( $self ) = @_; my $record = $self->record; @@ -137,6 +137,112 @@ sub get_identifiers { return \@identifiers; } +=head3 get_information + + my $information = $author->get_information; + +Return a list of information of the authors (syspref OPACAuthorInformation) + +=cut + +sub get_information { + my ($self) = @_; + + my $record = $self->record; + + # FIXME UNIMARC not supported yet. + return if C4::Context->preference('marcflavour') eq 'UNIMARC'; + + my $information; + for my $info ( split ',', C4::Context->preference('OPACAuthorInformation') ) { + if ( $info eq 'activity' ) { + + # activity: Activity (372$a$s$t) + for my $field ( $record->field('372') ) { + my $sf_a = $field->subfield('a'); + my $sf_s = $field->subfield('s'); + my $sf_t = $field->subfield('t'); + push @{ $information->{activity} }, + { field_of_activity => $sf_a, start_period => $sf_s, end_period => $sf_t, }; + } + } elsif ( $info eq 'address' ) { + + # address: Address (371$a$b$d$e) + for my $field ( $record->field('371') ) { + my $sf_a = $field->subfield('a'); + my $sf_b = $field->subfield('b'); + my $sf_d = $field->subfield('d'); + my $sf_e = $field->subfield('e'); + push @{ $information->{address} }, + { address => $sf_a, city => $sf_b, country => $sf_d, postal_code => $sf_e, }; + } + } elsif ( $info eq 'associated_group' ) { + + # associated_group: Associated group (373$a$s$t$u$v$0) + for my $field ( $record->field('373') ) { + my $sf_a = $field->subfield('a'); + my $sf_s = $field->subfield('s'); + my $sf_t = $field->subfield('t'); + my $sf_u = $field->subfield('u'); + my $sf_v = $field->subfield('v'); + my $sf_0 = $field->subfield('0'); + push @{ $information->{associated_group} }, + { + associated_group => $sf_a, start_period => $sf_s, end_period => $sf_t, uri => $sf_u, + source_of_information => $sf_v, authority_record_number => $sf_0, + }; + } + } elsif ( $info eq 'email_address' ) { + + # email_address: Electronic mail address (371$m) + for my $field ( $record->field('371') ) { + my $sf_m = $field->subfield('m'); + push @{ $information->{email_address} }, { email_address => $sf_m, }; + } + } elsif ( $info eq 'occupation' ) { + + # occupation: Occupation (374$a$s$t$u$v$0) + for my $field ( $record->field('374') ) { + my $sf_a = $field->subfield('a'); + my $sf_s = $field->subfield('s'); + my $sf_t = $field->subfield('t'); + my $sf_u = $field->subfield('u'); + my $sf_v = $field->subfield('v'); + my $sf_0 = $field->subfield('0'); + push @{ $information->{occupation} }, + { + occupation => $sf_a, start_period => $sf_s, end_period => $sf_t, uri => $sf_u, + source_of_information => $sf_v, authority_record_number => $sf_0, + }; + } + } elsif ( $info eq 'place_of_birth' ) { + + # place_of_birth: Place of birth (370$a) + for my $field ( $record->field('370') ) { + my $sf_a = $field->subfield('a'); + push @{ $information->{place_of_birth} }, { place_of_birth => $sf_a, }; + } + } elsif ( $info eq 'place_of_death' ) { + + # place_of_death: Place of death (370$b) + for my $field ( $record->field('370') ) { + my $sf_a = $field->subfield('b'); + push @{ $information->{place_of_death} }, { place_of_death => $sf_b, }; + } + } elsif ( $info eq 'uri' ) { + + # uri: URI (371$u) + for my $field ( $record->field('371') ) { + my $sf_u = $field->subfield('u'); + push @{ $information->{uri} }, { uri => $sf_u, }; + } + } + } + + return $information; +} + + =head3 record my $record = $authority->record() diff --git a/installer/data/mysql/atomicupdate/bug_29948.pl b/installer/data/mysql/atomicupdate/bug_29948.pl new file mode 100755 index 00000000000..3b8f0a682b3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29948.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "29948", + description => "Display author information for researchers", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OPACAuthorInformation','0','','Display author information on the OPAC detail page','multiple_sortable') + }); + + say $out "Added new system preference 'OPACAuthorInformation'"; + }, +}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 1056c79a155..e45f637a82f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -533,6 +533,18 @@ OPAC: - "identifiers for authors and contributors to the detail pages in the OPAC." - "This feature requires authorities with 024$2 and 024$a." - "Valid source codes in $2 are currently: orcid, scopus, loop, rid and viaf." + - + - "Display the following information for authors and contributors to the detail pages in the OPAC." + - pref: OPACAuthorInformation + multiple: + activity: Activity (372$a$s$t) + address: Address (371$a$b$d$e) + associated_group: Associated group (373$a$s$t$u$v$0) + email_address: Electronic mail address (371$m) + occupation: Occupation (374$a$s$t$u$v$0) + place_of_birth: Place of birth (370$a) + place_of_death: Place of death (370$b) + uri: URI (371$u) - - "Calculate the amount a patron has 'saved' by using the library based on replacement prices, and display:" - pref: OPACShowSavings diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc new file mode 100644 index 00000000000..9f1f5c6d71e --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/authority-information.inc @@ -0,0 +1,74 @@ +[% FOREACH info IN information %] + [% SWITCH info_type %] + [% CASE 'activity' %] +
  • + + Field of activity: [% info.field_of_activity | html %] + [% IF info.start_period || info.end_period %] + ( + [%~ IF info.start_period %]from: [% info.start_period | html %][% END %] + [% IF info.end_period %]until: [% info.end_period | html %][% END ~%] + ) + [% END %] + +
  • + [% CASE 'address' %] +
  • + Address: [% info.address | html %] [% info.postal_code | html %] [% info.city | html %] [% info.country | html %] +
  • + [% CASE 'associated_group' %] +
  • + + Associated group: [% info.associated_group | html %] + [% IF info.start_period || info.end_period %] + ( + [%~ IF info.start_period %]from: [% info.start_period | html %][% END %] + [% IF info.end_period %]until: [% info.end_period | html %][% END ~%] + ) + [% END %] + [% IF info.uri %]

    URI: [% info.uri | html %]

    [% END %] + [% IF info.source_of_information %]

    Source of information: [% info.source_of_information | html %]

    [% END %] + [% IF info.authority_record_number %]

    Authority record control number or standard number: [% info.authority_record_number | html %]

    [% END %] +
    +
  • + [% CASE 'email_address' %] +
  • + + Email address: [% info.email_address | html %] + +
  • + [% CASE 'occupation' %] +
  • + + Occupation: [% info.occupation | html %] + [% IF info.start_period || info.end_period %] + ( + [%~ IF info.start_period %]from: [% info.start_period | html %][% END %] + [% IF info.end_period %]until: [% info.end_period | html %][% END ~%] + ) + [% END %] + [% IF info.uri %]

    URI: [% info.uri | html %]

    [% END %] + [% IF info.source_of_information %]

    Source of information: [% info.source_of_information | html %]

    [% END %] + [% IF info.authority_record_number %]

    Authority record control number or standard number: [% info.authority_record_number | html %]

    [% END %] +
    +
  • + [% CASE 'place_of_birth' %] +
  • + + Place of birth: [% info.place_of_birth | html %] + +
  • + [% CASE 'place_of_death' %] +
  • + + Place of death: [% info.place_of_death | html %] + +
  • + [% CASE 'uri' %] +
  • + + URI: [% info.uri | $raw | html %] + +
  • + [% END %] +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 603710f1b4c..ad67e42d999 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -493,9 +493,15 @@ [% END %] [% END %] - [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %] - [% WRAPPER tab_item tabname= "author_identifiers" %] - Author identifiers + [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size || Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %] + [% WRAPPER tab_item tabname= "author_identifiers_info" %] + [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size && Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %] + Author identifiers/information + [% ELSIF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %] + Author identifiers + [% ELSIF Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %] + Author information + [% END %] [% END %] [% END %] @@ -941,8 +947,19 @@ [% END # /tab_panel#images %] [% END # / IF OPACLocalCoverImages && localimages.size %] - [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size %] - [% WRAPPER tab_panel tabname="author_identifiers" %] + [% IF Koha.Preference( 'OPACAuthorIdentifiers' ) && author_identifiers.size || Koha.Preference( 'OPACAuthorInformation' ) && author_information.size %] + [% WRAPPER tab_panel tabname="author_identifiers_info" %] + [% FOR author IN author_information %] +
    + [% author.name | html %] + +
    + [% END %] + [% FOR author IN author_identifiers %]
    [% author.name | html %] @@ -953,7 +970,7 @@
    [% END %] - [% END # /tab_panel#author_identifiers %] + [% END # /tab_panel#author_identifiers_info %] [% END %] [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index b9c644e38d7..f8f7c3666de 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1245,4 +1245,22 @@ if ( C4::Context->preference('OPACAuthorIdentifiers') ) { $template->param( author_identifiers => \@author_identifiers ); } +if ( C4::Context->preference('OPACAuthorInformation') ) { + my @author_information; + for my $author ( @{ $biblio->get_marc_authors } ) { + my $authid = $author->{authoritylink}; + my $authority = Koha::Authorities->find($authid); + next unless $authority; + my $information = $authority->get_information; + next unless $information; + my ($name) = + map { $_->{value} } + grep { $_->{code} eq 'a' ? $_ : () } + @{ $author->{MARCAUTHOR_SUBFIELDS_LOOP} }; + push @author_information, + { authid => $authid, name => $name, information => $information }; + } + $template->param( author_information => \@author_information ); +} + output_html_with_http_headers $query, $cookie, $template->output; -- 2.34.1