2 # Copyright 2007 LibLime
3 # Copyright 2012 software.coop and MJ Ray
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use C4
::Auth qw
/check_api_auth/;
27 binmode STDOUT
, ':encoding(UTF-8)';
30 my ($status, $cookie, $sessionID) = check_api_auth
($query, { editcatalogue
=> 'edit_catalogue'} );
31 unless ($status eq 'ok') {
32 print $query->header(-type
=> 'text/xml', -status
=> '403 Forbidden');
33 print XMLout
({ auth_status
=> $status }, NoAttr
=> 1, RootName
=> 'response', XMLDecl
=> 1);
37 # do initial validation
38 my $path_info = $query->path_info();
39 my $biblionumber = undef;
40 if ($path_info =~ m!^/(\d+)$!) {
43 print $query->header(-type
=> 'text/xml', -status
=> '400 Bad Request');
45 if ($query->request_method eq 'GET') {
46 fetch_bib_framework
($query, $biblionumber);
48 print $query->header(-type
=> 'text/xml', -status
=> '405 Method not allowed');
49 print XMLout
({ error
=> 'Method not allowed' }, NoAttr
=> 1, RootName
=> 'response', XMLDecl
=> 1);
54 sub fetch_bib_framework
{
56 my $biblionumber = shift;
57 my $frameworkcode = GetFrameworkCode
( $biblionumber );
59 'frameworkcode' => $frameworkcode
61 print $query->header(-type
=> 'text/xml',-charset
=> 'utf-8',);
62 print XMLout
($result, NoAttr
=> 1, RootName
=> 'response', XMLDecl
=> 1, NoEscape
=> 0);