Bug 15381: Use Koha::Authority::Types in some other places

There are 3 place where the auth_types table were requested directly
from the script or a subroutine.  These 3 occurrences are easy to
replace with the new module.

Test plan:
1/ Search for authorities and use the "did you mean" feature for
authorities.
Focus on the authtypecode
2/ Edit authority and biblio frameworks.
The "Thesaurus" dropdown list should be correctly populated (UNIMARC
only).

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
This commit is contained in:
Jonathan Druart 2015-12-15 11:59:02 +00:00 committed by Brendan Gallagher
parent 5fc9a42c7c
commit e28d54f7d9
3 changed files with 14 additions and 25 deletions

View File

@ -291,11 +291,7 @@ sub SearchAuthorities {
my %newline;
$newline{authid} = $authid;
if ( !$skipmetadata ) {
my $query_auth_tag =
"SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?";
my $sth = $dbh->prepare($query_auth_tag);
$sth->execute($authtypecode);
my $auth_tag_to_report = $sth->fetchrow;
my $auth_tag_to_report = Koha::Authority::Types->find($authtypecode)->auth_tag_to_report;
my $reported_tag;
my $mainentry = $authrecord->field($auth_tag_to_report);
if ($mainentry) {
@ -848,10 +844,7 @@ sub FindDuplicateAuthority {
# warn "IN for ".$record->as_formatted;
my $dbh = C4::Context->dbh;
# warn "".$record->as_formatted;
my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
$sth->execute($authtypecode);
my ($auth_tag_to_report) = $sth->fetchrow;
$sth->finish;
my $auth_tag_to_report = Koha::Authority::Types->find($authtypecode)->auth_tag_to_report;
# warn "record :".$record->as_formatted." auth_tag_to_report :$auth_tag_to_report";
# build a request for SearchAuthorities
my $QParser;
@ -1456,12 +1449,9 @@ sub merge {
return "error MARCFROM not a marcrecord ".Data::Dumper::Dumper($MARCfrom) if scalar($MARCfrom->fields()) == 0;
return "error MARCTO not a marcrecord".Data::Dumper::Dumper($MARCto) if scalar($MARCto->fields()) == 0;
# search the tag to report
my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
$sth->execute($authtypecodefrom);
my ($auth_tag_to_report_from) = $sth->fetchrow;
$sth->execute($authtypecodeto);
my ($auth_tag_to_report_to) = $sth->fetchrow;
my $auth_tag_to_report_from = Koha::Authority::Types->find($authtypecodefrom)->auth_tag_to_report;
my $auth_tag_to_report_to = Koha::Authority::Types->find($authtypecodeto)->auth_tag_to_report;
my @record_to;
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $MARCto->field($auth_tag_to_report_to);
my @record_from;
@ -1499,7 +1489,7 @@ sub merge {
#warn scalar(@reccache)." biblios to update";
# Get All candidate Tags for the change
# (This will reduce the search scope in marc records).
$sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
$sth->execute($authtypecodefrom);
my @tags_using_authtype;
while (my ($tagfield) = $sth->fetchrow) {

View File

@ -25,6 +25,9 @@ use CGI qw ( -utf8 );
use C4::Context;
use C4::Koha;
use Koha::Authority::Types;
use List::MoreUtils qw( uniq );
sub string_search {
my ($searchstring,$authtypecode)=@_;
@ -99,7 +102,7 @@ if ($op eq 'add_form') {
push @$authorised_values, 'itemtypes';
# build thesaurus categories list
my @authtypes = (sort keys %{C4::Koha::getauthtypes()});
my @authtypes = uniq( "", map { $_->authtypecode } Koha::Authority::Types->search );
# build value_builder list
my @value_builder=('');

View File

@ -24,6 +24,9 @@ use C4::Auth;
use CGI qw ( -utf8 );
use C4::Context;
use Koha::Authority::Types;
use List::MoreUtils qw( uniq );
sub string_search {
my ( $searchstring, $frameworkcode ) = @_;
@ -138,14 +141,7 @@ if ( $op eq 'add_form' ) {
push( @authorised_values, "cn_source" );
# build thesaurus categories list
$sth2->finish;
$sth2 = $dbh->prepare("select authtypecode from auth_types");
$sth2->execute;
my @authtypes;
push @authtypes, "";
while ( ( my $authtypecode ) = $sth2->fetchrow_array ) {
push @authtypes, $authtypecode;
}
my @authtypes = uniq( "", map { $_->authtypecode } Koha::Authority::Types->search );
# build value_builder list
my @value_builder = ('');