From 070f720aaeda27ff0d863fe20a3cd60743558167 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 Signed-off-by: Signed-off-by: Hugo Agud Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer --- 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 cc29c80207..0bee57b135 100644 --- a/Koha/Authority.pm +++ b/Koha/Authority.pm @@ -150,7 +150,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; @@ -165,6 +165,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_b = $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 0000000000..3b8f0a682b --- /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 f424a4d702..613c1b110b 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 0000000000..9f1f5c6d71 --- /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 170f14f1a0..449e4b19f2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -494,9 +494,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 %] @@ -942,8 +948,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 %] +
      + [% FOR info IN author.information.keys %] + [% PROCESS "authority-information.inc" information => author.information.$info, info_type => info %] + [% END %] +
    +
    + [% END %] + [% FOR author IN author_identifiers %]
    [% author.name | html %] @@ -954,7 +971,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 e9f05dcb71..89108c1a93 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1251,4 +1251,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.39.5