[Koha-patches] [PATCH] Adding Authorities list

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Wed Aug 26 01:40:24 CEST 2009


---
 authorities/authorities-list.pl |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
 create mode 100644 authorities/authorities-list.pl

diff --git a/authorities/authorities-list.pl b/authorities/authorities-list.pl
new file mode 100644
index 0000000..4359489
--- /dev/null
+++ b/authorities/authorities-list.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use C4::Context;
+use C4::AuthoritiesMarc;
+use 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({});
+print "id;authtype;heading;count usage\n";
+foreach my $authority (@$dataauthorities){
+  my $marcauthority=GetAuthority($authority->{'authid'});
+  if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){
+    print qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";"),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";), CountUsage($authority->{authid}),"\n";
+  }
+}
-- 
1.6.0.4



More information about the Koha-patches mailing list