Patch from Joe Atzberger to remove $Id$ and $Log$ from scripts
[koha.git] / members / member-picupload.pl
1 #!/usr/bin/perl
2
3
4 # script to upload a picture to a borrowerimages directory.
5 # checks to see if its either displaying the upload form
6 # or doing the actual upload.
7 # written by Waylon Robertson (genjimoto@sourceforge) 2005/08/22
8
9
10 # Copyright 2000-2002 Katipo Communications
11 #
12 # This file is part of Koha.
13 #
14 # Koha is free software; you can redistribute it and/or modify it under the
15 # terms of the GNU General Public License as published by the Free Software
16 # Foundation; either version 2 of the License, or (at your option) any later
17 # version.
18 #
19 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License along with
24 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
25 # Suite 330, Boston, MA  02111-1307 USA
26
27 use strict;
28 use C4::Auth;
29 use C4::Context;
30 use C4::Output;
31 use CGI;
32
33
34 my $input = new CGI;
35 my $name = $input->param('name');
36 my $borrowernumber = $input->param('borrowernumber');
37 my $photo = $input->param('photo');
38
39 my $template_name;
40 my $upload_dir= 
41 my $htdocs = C4::Context->config('intrahtdocs');
42 my $upload_dir = $htdocs."/borrowerimages";
43 if($photo eq  ""){
44         $template_name = "members/member-picupload.tmpl";
45 } else {
46         $template_name = "members/moremember.tmpl";
47 }
48
49 my ($template, $loggedinuser, $cookie)
50     = get_template_and_user({template_name => $template_name,
51                              query => $input,
52                              type => "intranet",
53                              authnotrequired => 0,
54                              flagsrequired => {borrowers => 1},
55                              debug => 1,
56                              });
57 if ($photo){
58
59         my $filename=$borrowernumber.'.jpg';
60         my $upload_filehandle = $input->upload("photo");
61         open UPLOADFILE, ">$upload_dir/$filename";
62         binmode UPLOADFILE;
63         while ( <$upload_filehandle> )
64         {
65                 print UPLOADFILE;
66         }
67         close UPLOADFILE;
68 }
69 else {
70         $template->param(
71                  borrowernumber => $borrowernumber,
72                  name => $name
73                  );
74         output_html_with_http_headers $input, $cookie, $template->output;
75 }
76 print $input->redirect("http://intranet/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");