1 package Koha
::Authority
;
3 # Copyright 2012 C & P Bibliography Services
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 Koha::Authority - class to encapsulate authority records in Koha
26 Object-oriented class that encapsulates authority records in Koha.
41 use base
qw(Class::Accessor);
43 __PACKAGE__
->mk_accessors(qw( authid authtype record marcflavour ));
47 my $auth = Koha::Authority->new($record);
49 Create a new Koha::Authority object based on the provided record.
56 my $self = $class->SUPER::new
( { record
=> $record });
62 =head2 get_from_authid
64 my $auth = Koha::Authority->get_from_authid($authid);
66 Create the Koha::Authority object associated with the provided authid.
72 my $marcflavour = C4
::Context
->preference("marcflavour");
74 my $dbh=C4
::Context
->dbh;
75 my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?");
76 $sth->execute($authid);
77 my ($authtypecode, $marcxml) = $sth->fetchrow;
78 my $record=eval {MARC
::Record
->new_from_xml(StripNonXmlChars
($marcxml),'UTF-8',
79 (C4
::Context
->preference("marcflavour") eq "UNIMARC"?
"UNIMARCAUTH":C4
::Context
->preference("marcflavour")))};
81 $record->encoding('UTF-8');
83 my $self = $class->SUPER::new
( { authid
=> $authid,
84 marcflavour
=> $marcflavour,
85 authtype
=> $authtypecode,