Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber
[koha.git] / opac / sco / sco-patron-image.pl
1 #!/usr/bin/perl
2 #
3 # Copyright 2009 LibLime
4 #
5 # This file is part of Koha.
6 #
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
10 # version.
11 #
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.
15 #
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.
19
20 use strict;
21 use warnings;
22 use C4::Service;
23 use C4::Members;
24
25 my ($query, $response) = C4::Service->init(circulate => 'circulate_remaining_permissions');
26
27 unless (C4::Context->preference('WebBasedSelfCheck')) {
28     print $query->header(status => '403 Forbidden - web-based self-check not enabled');
29     exit;
30 }
31 unless (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) {
32     print $query->header(status => '403 Forbidden - displaying patron images in self-check not enabled');
33     exit;
34 }
35
36 my ($borrowernumber) = C4::Service->require_params('borrowernumber');
37
38 my ($imagedata, $dberror) = GetPatronImage($borrowernumber);
39
40 if ($dberror) {
41     print $query->header(status => '500 internal error');
42 }
43
44 if ($imagedata) {
45     print $query->header(-type => $imagedata->{'mimetype'}, 
46                          -Content_Length => length ($imagedata->{'imagefile'})), 
47           $imagedata->{'imagefile'};
48 } else {
49     print $query->header(status => '404 patron image not found');
50 }