bug 2521: distinguish types of hold requests
[koha.git] / members / patronimage.pl
1 #!/usr/bin/perl
2 #
3 # Copyright 2008 Foundations Bible College & Seminary Inc.
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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19 #
20 #
21 #
22
23 use strict;
24 use CGI; #qw(:standard escapeHTML);
25 use C4::Context;
26 use C4::Members;
27
28 $|=1;
29
30 my $DEBUG = 0;
31 my $data = new CGI;
32 my $cardnumber;
33
34 =head1 NAME
35
36 patronimage.pl - Script for retrieving and formating Koha patron images for display
37
38 =head1 SYNOPSIS
39
40 <img src="patronimage.pl?crdnum= />
41
42 =head1 DESCRIPTION
43
44 This script, when called from within HTML and passed a valid patron cardnumber, will retrieve the image data associated with that cardnumber if one exists, format it in proper HTML format and pass it back to be displayed.
45
46 =cut
47
48 if ($data->param('crdnum')) {
49     $cardnumber = $data->param('crdnum');
50 } else {
51     $cardnumber = shift;
52 }
53
54
55 warn "Cardnumber passed in: $cardnumber" if $DEBUG;
56
57 my ($imagedata, $dberror) = GetPatronImage($cardnumber);
58
59 if ($dberror) {
60     warn "Database Error!";
61     exit;
62 }
63
64 # NOTE: Never dump the contents of $imagedata->{'patronimage'} via a warn to a log or nasty
65 # things will result... you have been warned!
66
67 if ($imagedata) {
68     print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -Content_Length => length ($imagedata->{'imagefile'})), $imagedata->{'imagefile'};
69     exit;
70 } else {
71     warn "No image exists for $cardnumber";
72     exit;
73 }
74
75 exit;
76
77 =back
78
79 =head1 AUTHOR
80
81 Chris Nighswonger cnighswonger <at> foundations <dot> edu
82
83 =cut