@@ -, +, @@ as auth type --- C4/AuthoritiesMarc.pm | 31 +++++++++++++++++++++- authorities/detail.pl | 12 +++++++-- .../prog/en/modules/authorities/detail.tt | 7 ++++- 3 files changed, 46 insertions(+), 4 deletions(-) --- a/C4/AuthoritiesMarc.pm +++ a/C4/AuthoritiesMarc.pm @@ -63,6 +63,7 @@ BEGIN { &FindDuplicateAuthority &GuessAuthTypeCode + &RetrieveAuthTypeFromAuthority008 &GuessAuthId ); } @@ -331,7 +332,7 @@ Get the record and tries to guess the adequate authtypecode from its content. sub GuessAuthTypeCode { my ($record, $heading_fields) = @_; return unless defined $record; - return '' if C4::Preferences('UseAuthority008AsAuthType'); + return '' if C4::Context->preference('UseAuthority008AsAuthType'); $heading_fields //= { "MARC21"=>{ '100'=>{authtypecode=>'PERSO_NAME'}, @@ -396,6 +397,34 @@ sub GuessAuthTypeCode { return; } +=head2 RetrieveAuthTypeFromAuthority008 + + my $type = RetrieveAuthTypeFromAuthority008 + +If the UseAuthority008AsAuthType syspref is enabled then retrieve the multiple authority types from the authority 008 positions 14-16 + +=cut + +sub RetrieveAuthTypeFromAuthority008 { + + my ($record) = @_; + return unless ($record && $record->field('008')); + + my $name = 0; + my $subject= 0; + my $series = 0; + my $pos14 = substr($record->field('008')->data, 14, 1); + my $pos15 = substr($record->field('008')->data, 15, 1); + my $pos16 = substr($record->field('008')->data, 16, 1); + + $name = 1 if $pos14 eq 'a'; + $subject= 1 if $pos15 eq 'a'; + $series = 1 if $pos16 eq 'a'; + + my %authtypes = ( 'name' => $name, 'subject' => $subject, 'series' => $series); + return \%authtypes; +} + =head2 GuessAuthId my $authtid = GuessAuthId($record); --- a/authorities/detail.pl +++ a/authorities/detail.pl @@ -45,6 +45,7 @@ use C4::Output; use CGI qw ( -utf8 ); use MARC::Record; use C4::Koha; +use C4::AuthoritiesMarc; use Koha::Authorities; use Koha::Authority::Types; @@ -225,12 +226,19 @@ my $servers = Koha::Z3950Servers->search( }, ); -my $type = $authority_types->find($authtypecode); +my $type; +if (C4::Context->preference('UseAuthority008AsAuthType')) { + $type = RetrieveAuthTypeFromAuthority008($record) if $record; + $template->param(authtypetext => $type); +} else { + $type = $authority_types->find($authtypecode); + $template->param(authtypetext => $type ? $type->authtypetext: ""); +} + $template->param( authid => $authid, count => $count, biblio_fields => $biblio_fields, - authtypetext => $type ? $type->authtypetext: "", authtypecode => $authtypecode, authority_types => $authority_types, csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $query->cookie('CGISESSID') }), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt @@ -1,4 +1,5 @@ [% USE raw %] +[% USE Koha %] [% USE Asset %] [% SET footerjs = 1 %] [% PROCESS 'authorities.inc' %] @@ -40,7 +41,11 @@ [% IF ( unknownauthid ) %]
The authority record you requested does not exist ([% errauthid | html %]).
[% ELSE %] -

Authority #[% authid | html %] ([% authtypetext | html %])

+[% IF Koha.Preference('UseAuthority008AsAuthType') %] +

Authority #[% authid | html %] (Available for use as a [% type.name | html %] [% type.subject | html %] [% type.series | html %])

+[% ELSE %] +

Authority #[% authid | html %] ([% authtypetext | html %])

+[% END %]
[% IF count %] --