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' %] +
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 %] + +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 %] + +