Bugzilla – Attachment 13481 Details for
Bug 9072
Add CheckValidity option to Linker
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch (main)
0001-Bug-9072-Add-CheckValidity-option-to-Linker.patch (text/plain), 5.66 KB, created by
Fridolin Somers
on 2012-11-16 08:44:05 UTC
(
hide
)
Description:
Proposed patch (main)
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2012-11-16 08:44:05 UTC
Size:
5.66 KB
patch
obsolete
>From cb546cbfaa57fb937f86062abf2254c30abad141 Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Thu, 15 Nov 2012 12:27:20 +0100 >Subject: [PATCH 1/2] Bug 9072: Add CheckValidity option to Linker > >--- > C4/AuthoritiesMarc.pm | 3 +- > C4/Biblio.pm | 8 ++--- > C4/Heading.pm | 34 ++++++++++++++++---- > C4/Linker/Default.pm | 3 +- > .../en/modules/admin/preferences/authorities.pref | 2 +- > 5 files changed, 37 insertions(+), 13 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index db340ba..f0345ea 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -1180,12 +1180,13 @@ sub GetAuthorizedHeading { > unless ($record = $args->{record}) { > return unless $args->{authid}; > $record = GetAuthority($args->{authid}); >+ return unless $record; > } > if (C4::Context->preference('marcflavour') eq 'UNIMARC') { > # construct UNIMARC summary, that is quite different from MARC21 one > # accepted form > foreach my $field ($record->field('2..')) { >- return $field->as_string('abcdefghijlmnopqrstuvwxyz'); >+ return $field->as_string('abcdefghijklmnopqrstuvwxyz'); > } > } else { > foreach my $field ($record->field('1..')) { >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index eb213d5..3e6bcf1 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -662,13 +662,13 @@ safest place. > > sub _check_valid_auth_link { > my ( $authid, $field ) = @_; >- > require C4::AuthoritiesMarc; >- > my $authorized_heading = > C4::AuthoritiesMarc::GetAuthorizedHeading( { 'authid' => $authid } ); >- >- return ($field->as_string('abcdefghijklmnopqrstuvwxyz') eq $authorized_heading); >+ my $field_value = $field->as_string('abcdefghijklmnopqrstuvwxyz'); >+ return ( $authorized_heading >+ && $field_value >+ && $field_value eq $authorized_heading ); > } > > =head2 GetRecordValue >diff --git a/C4/Heading.pm b/C4/Heading.pm >index dca4d1b..9adb75c 100644 >--- a/C4/Heading.pm >+++ b/C4/Heading.pm >@@ -140,18 +140,19 @@ sub search_form { > > =head2 authorities > >- my $authorities = $heading->authorities([$skipmetadata]); >+ my $authorities = $heading->authorities([$skipmetadata][$checkvalidity]); > >-Return a list of authority records for this >-heading. If passed a true value for $skipmetadata, >-SearchAuthorities will return only authids. >+Return a list of authority records for this heading. >+If passed a true value for $skipmetadata, SearchAuthorities will return only authids. >+If passed a true value for $checkvalidity, SearchAuthorities will check authorities validity. > > =cut > > sub authorities { > my $self = shift; > my $skipmetadata = shift; >- my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata ); >+ my $checkvalidity = shift; >+ my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata, $checkvalidity ); > return $results; > } > >@@ -181,6 +182,7 @@ sub _search { > my $self = shift; > my $index = shift || undef; > my $skipmetadata = shift || undef; >+ my $checkvalidity = shift || undef; > my @marclist; > my @and_or; > my @excluding = []; >@@ -202,11 +204,31 @@ sub _search { > # push @value, $self->{'thesaurus'}; > # } > require C4::AuthoritiesMarc; >- return C4::AuthoritiesMarc::SearchAuthorities( >+ my ( $authorities, $nbresults ) = C4::AuthoritiesMarc::SearchAuthorities( > \@marclist, \@and_or, \@excluding, \@operator, > \@value, 0, 20, $self->{'auth_type'}, > 'AuthidAsc', $skipmetadata > ); >+ >+ if ($checkvalidity) { >+ my @authorities_cheked; >+ foreach (@$authorities) { >+ # TODO should be merged with C4::Biblio->_check_valid_auth_link >+ my $authorized_heading = C4::AuthoritiesMarc::GetAuthorizedHeading( >+ { authid => $_->{'authid'} } ); >+ my $field_value = >+ $self->{'field'}->as_string('abcdefghijklmnopqrstuvwxyz'); >+ if ( $authorized_heading >+ && $field_value >+ && $field_value eq $authorized_heading ) >+ { >+ push @authorities_cheked, $_; >+ } >+ } >+ $authorities = \@authorities_cheked; >+ } >+ >+ return $authorities; > } > > =head1 INTERNAL FUNCTIONS >diff --git a/C4/Linker/Default.pm b/C4/Linker/Default.pm >index 445b408..ac49187 100644 >--- a/C4/Linker/Default.pm >+++ b/C4/Linker/Default.pm >@@ -40,7 +40,8 @@ sub get_link { > else { > > # look for matching authorities >- my $authorities = $heading->authorities(1); # $skipmetadata = true >+ # Skip meta datas and use CheckValidity from LinkerOptions >+ my $authorities = $heading->authorities(1, $self->{'CheckValidity'}); > > if ( $behavior eq 'default' && $#{$authorities} == 0 ) { > $authid = $authorities->[0]->{'authid'}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >index f4cc9e3..35d2a4c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >@@ -57,7 +57,7 @@ Authorities: > - Set the following options for the authority linker > - pref: LinkerOptions > class: multi >- - (separate options with |) >+ - (separate options with |). Use : CheckValidity. > - > - pref: LinkerRelink > default: yes >-- >1.7.9.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9072
:
13442
|
13481
|
13482
|
13483
|
13487
|
13488
|
13489
|
13490