Bug 16268: Add confirm message for deleting circ and fines rules
[koha.git] / members / patronimage.pl
blobb833978a139a31ea3073b39d5e219fa47a03aaef
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 Modern::Perl;
25 use CGI qw ( -utf8 );
26 use C4::Auth qw( check_api_auth );
27 use C4::Context;
28 use C4::Members;
29 use Koha::Patron::Images;
31 $|=1;
33 my $DEBUG = 0;
34 my $query = new CGI;
35 my $borrowernumber;
37 =head1 NAME
39 patronimage.pl - Script for retrieving and formatting Koha patron images for display
41 =head1 SYNOPSIS
43 <img src="patronimage.pl?borrowernumber= />
45 =head1 DESCRIPTION
47 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.
49 =cut
51 my ($status, $cookie, $sessionID) = check_api_auth($query, { borrowers => 1} );
53 unless ( $status eq 'ok' ) {
54 print $query->header(-type => 'text/plain', -status => '403 Forbidden');
55 exit 0;
60 if ($query->param('borrowernumber')) {
61 $borrowernumber = $query->param('borrowernumber');
62 } else {
63 $borrowernumber = shift;
67 warn "Borrowernumber passed in: $borrowernumber" if $DEBUG;
69 my $patron_image = Koha::Patron::Images->find($borrowernumber);
71 # NOTE: Never dump the contents of $imagedata->{'patronimage'} via a warn to a log or nasty
72 # things will result... you have been warned!
74 if ($patron_image) {
75 print $query->header (-type => $patron_image->mimetype, -'Cache-Control' => 'no-store', -Content_Length => length ($patron_image->imagefile)), $patron_image->imagefile;
76 exit;
77 } else {
78 warn "No image exists for $borrowernumber";
79 exit;
82 exit;
84 =head1 AUTHOR
86 Chris Nighswonger cnighswonger <at> foundations <dot> edu
88 =cut