Bug 7272 setting NULL to debarred field, to avoid having 0000-00-00
[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
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 #
21 #
22
23 use strict;
24 use warnings;
25
26 use CGI; #qw(:standard escapeHTML);
27 use C4::Context;
28 use C4::Members;
29
30 $|=1;
31
32 my $DEBUG = 0;
33 my $data = new CGI;
34 my $cardnumber;
35
36 =head1 NAME
37
38 patronimage.pl - Script for retrieving and formatting Koha patron images for display
39
40 =head1 SYNOPSIS
41
42 <img src="patronimage.pl?crdnum= />
43
44 =head1 DESCRIPTION
45
46 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.
47
48 =cut
49
50 if ($data->param('crdnum')) {
51     $cardnumber = $data->param('crdnum');
52 } else {
53     $cardnumber = shift;
54 }
55
56
57 warn "Cardnumber passed in: $cardnumber" if $DEBUG;
58
59 my ($imagedata, $dberror) = GetPatronImage($cardnumber);
60
61 if ($dberror) {
62     warn "Database Error!";
63     exit;
64 }
65
66 # NOTE: Never dump the contents of $imagedata->{'patronimage'} via a warn to a log or nasty
67 # things will result... you have been warned!
68
69 if ($imagedata) {
70     print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -Content_Length => length ($imagedata->{'imagefile'})), $imagedata->{'imagefile'};
71     exit;
72 } else {
73     warn "No image exists for $cardnumber";
74     exit;
75 }
76
77 exit;
78
79 =head1 AUTHOR
80
81 Chris Nighswonger cnighswonger <at> foundations <dot> edu
82
83 =cut