Bug 14252: Move OPAC lang switcher to masthead navbar
[koha.git] / members / patronimage.pl
blob1218ae463ea6d59c4751d7629994f7ea43dd0064
1 #!/usr/bin/perl
3 # Copyright 2008 Foundations Bible College & Seminary Inc.
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>.
23 use strict;
24 use warnings;
26 use CGI qw ( -utf8 ); #qw(:standard escapeHTML);
27 use C4::Context;
28 use C4::Members;
30 $|=1;
32 my $DEBUG = 0;
33 my $data = new CGI;
34 my $borrowernumber;
36 =head1 NAME
38 patronimage.pl - Script for retrieving and formatting Koha patron images for display
40 =head1 SYNOPSIS
42 <img src="patronimage.pl?borrowernumber= />
44 =head1 DESCRIPTION
46 This script, when called from within HTML and passed a valid patron borrowernumber, will retrieve the image data associated with that borrowernumber if one exists, format it in proper HTML format and pass it back to be displayed.
48 =cut
50 if ($data->param('borrowernumber')) {
51 $borrowernumber = $data->param('borrowernumber');
52 } else {
53 $borrowernumber = shift;
57 warn "Borrowernumber passed in: $borrowernumber" if $DEBUG;
59 my ($imagedata, $dberror) = GetPatronImage($borrowernumber);
61 if ($dberror) {
62 warn "Database Error!";
63 exit;
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!
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 $borrowernumber";
74 exit;
77 exit;
79 =head1 AUTHOR
81 Chris Nighswonger cnighswonger <at> foundations <dot> edu
83 =cut