Bug 21853: Fix PDF export of basketgroups
[koha.git] / svc / bib_framework
blob1b640101c24002331869835e7b5057b068c2e211
1 #!/usr/bin/perl
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>.
20 use Modern::Perl;
21 use CGI qw ( -utf8 );
22 use C4::Auth qw/check_api_auth/;
23 use C4::Biblio;
24 use C4::Items;
25 use XML::Simple;
27 binmode STDOUT, ':encoding(UTF-8)';
29 my $query = new CGI;
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);
34 exit 0;
37 # do initial validation
38 my $path_info = $query->path_info();
39 my $biblionumber = undef;
40 if ($path_info =~ m!^/(\d+)$!) {
41 $biblionumber = $1;
42 } else {
43 print $query->header(-type => 'text/xml', -status => '400 Bad Request');
45 if ($query->request_method eq 'GET') {
46 fetch_bib_framework($query, $biblionumber);
47 } else {
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);
50 exit 0;
52 exit 0;
54 sub fetch_bib_framework {
55 my $query = shift;
56 my $biblionumber = shift;
57 my $frameworkcode = GetFrameworkCode( $biblionumber );
58 my $result = {
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);