Koha/authorities/authorities-list.pl
Colin Campbell d8b362e0f9 Bug 5415 Let calls of SimpleSearch utilize considtent interface
Remove some unnecessary checks when check of error is
sufficient. Make the order in some cases more logical
Should remove some possibilities of runtime warning noise.
Although some calls belong to the 'Nothing could
ever go wrong' school have added some warnings

Signed-off-by: Christophe Croullebois <christophe.croullebois@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2011-04-08 13:52:57 +12:00

34 lines
1.2 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use C4::Context;
use C4::AuthoritiesMarc;
use utf8;
use open qw( :std :utf8 );
my $dbh=C4::Context->dbh;
my $datatypes_query = $dbh->prepare(<<ENDSQL);
SELECT authtypecode,authtypetext,auth_tag_to_report from auth_types;
ENDSQL
$datatypes_query->execute;
my $datatypes=$datatypes_query->fetchall_arrayref({});
my %authtypes;
map { $authtypes{$_->{'authtypecode'}}={"tag"=> $_->{'auth_tag_to_report'}, "lib"=> $_->{'authtypetext'}};} @$datatypes;
my $data_query = $dbh->prepare(<<ENDSQL);
SELECT authid, authtypecode from auth_header
ENDSQL
$data_query->execute;
my $dataauthorities=$data_query->fetchall_arrayref({});
foreach my $authority (@$dataauthorities){
my $marcauthority=GetAuthority($authority->{'authid'});
my $query;
$query= "an=".$authority->{'authid'};
# search for biblios mapped
my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
if (defined $err) {
$used = 0;
}
if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){
print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n);
}
}