Lines 140-157
sub search_form {
Link Here
|
140 |
|
140 |
|
141 |
=head2 authorities |
141 |
=head2 authorities |
142 |
|
142 |
|
143 |
my $authorities = $heading->authorities([$skipmetadata]); |
143 |
my $authorities = $heading->authorities([$skipmetadata][$checkvalidity]); |
144 |
|
144 |
|
145 |
Return a list of authority records for this |
145 |
Return a list of authority records for this heading. |
146 |
heading. If passed a true value for $skipmetadata, |
146 |
If passed a true value for $skipmetadata, SearchAuthorities will return only authids. |
147 |
SearchAuthorities will return only authids. |
147 |
If passed a true value for $checkvalidity, SearchAuthorities will check authorities validity. |
148 |
|
148 |
|
149 |
=cut |
149 |
=cut |
150 |
|
150 |
|
151 |
sub authorities { |
151 |
sub authorities { |
152 |
my $self = shift; |
152 |
my $self = shift; |
153 |
my $skipmetadata = shift; |
153 |
my $skipmetadata = shift; |
154 |
my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata ); |
154 |
my $checkvalidity = shift; |
|
|
155 |
my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata, $checkvalidity ); |
155 |
return $results; |
156 |
return $results; |
156 |
} |
157 |
} |
157 |
|
158 |
|
Lines 181-186
sub _search {
Link Here
|
181 |
my $self = shift; |
182 |
my $self = shift; |
182 |
my $index = shift || undef; |
183 |
my $index = shift || undef; |
183 |
my $skipmetadata = shift || undef; |
184 |
my $skipmetadata = shift || undef; |
|
|
185 |
my $checkvalidity = shift || undef; |
184 |
my @marclist; |
186 |
my @marclist; |
185 |
my @and_or; |
187 |
my @and_or; |
186 |
my @excluding = []; |
188 |
my @excluding = []; |
Lines 202-212
sub _search {
Link Here
|
202 |
# push @value, $self->{'thesaurus'}; |
204 |
# push @value, $self->{'thesaurus'}; |
203 |
# } |
205 |
# } |
204 |
require C4::AuthoritiesMarc; |
206 |
require C4::AuthoritiesMarc; |
205 |
return C4::AuthoritiesMarc::SearchAuthorities( |
207 |
my ( $authorities, $nbresults ) = C4::AuthoritiesMarc::SearchAuthorities( |
206 |
\@marclist, \@and_or, \@excluding, \@operator, |
208 |
\@marclist, \@and_or, \@excluding, \@operator, |
207 |
\@value, 0, 20, $self->{'auth_type'}, |
209 |
\@value, 0, 20, $self->{'auth_type'}, |
208 |
'AuthidAsc', $skipmetadata |
210 |
'AuthidAsc', $skipmetadata |
209 |
); |
211 |
); |
|
|
212 |
|
213 |
if ($checkvalidity) { |
214 |
my @authorities_cheked; |
215 |
foreach (@$authorities) { |
216 |
# TODO should be merged with C4::Biblio->_check_valid_auth_link |
217 |
my $authorized_heading = C4::AuthoritiesMarc::GetAuthorizedHeading( |
218 |
{ authid => $_->{'authid'} } ); |
219 |
my $field_value = |
220 |
$self->{'field'}->as_string('abcdefghijklmnopqrstuvwxyz'); |
221 |
if ( $authorized_heading |
222 |
&& $field_value |
223 |
&& $field_value eq $authorized_heading ) |
224 |
{ |
225 |
push @authorities_cheked, $_; |
226 |
} |
227 |
} |
228 |
$authorities = \@authorities_cheked; |
229 |
} |
230 |
|
231 |
return $authorities; |
210 |
} |
232 |
} |
211 |
|
233 |
|
212 |
=head1 INTERNAL FUNCTIONS |
234 |
=head1 INTERNAL FUNCTIONS |