Permalink
Browse files

LLK #18913469 make patron image upload work under Plack

  • Loading branch information...
1 parent 760332c commit 39f7fdb79654f3039443a769d979aeed214cac87 @hgq hgq committed Sep 29, 2011
Showing with 27 additions and 11 deletions.
  1. +16 −0 Koha/Plack/Util.pm
  2. +11 −11 tools/picture-upload.pl
View
@@ -17,4 +17,20 @@ sub GetCanonicalHostname {
return $hostname;
}
+sub IsStaff {
+ my $hostname = GetCanonicalHostname(shift);
+ return 1 if $ENV{KOHA_STAFF};
+ return $hostname =~ /-staff/;
+}
+
+sub RedirectRootAndOpac {
+ my $env = shift;
+ my $is_staff = shift // \&IsStaff;
+
+ return 302 if ($is_staff->($env) && s{^/$}{/cgi-bin/koha/mainpage.pl});
+ return 302 if (!$is_staff->($env) && s{^/$}{/cgi-bin/koha/opac-main.pl});
+ if (!$is_staff->($env)) { s{^/cgi-bin/koha/}{/cgi-bin/koha/opac/}}
+ return;
+}
+
1;
@@ -46,8 +46,8 @@
use C4::Output;
use C4::Members;
-my $input = new CGI;
-my ($template, $loggedinuser, $cookie) = get_template_and_user({
+our $input = new CGI;
+our($template, $loggedinuser, $cookie) = get_template_and_user({
template_name => 'tools/picture-upload.tmpl',
query => $input,
type => 'intranet',
@@ -56,14 +56,14 @@
debug => 0,
});
-my $filetype = $input->param('filetype');
-my $cardnumber = $input->param('cardnumber');
-my $uploadfilename = $input->param('uploadfile');
-my $uploadfile = $input->upload('uploadfile');
-my $borrowernumber = $input->param('borrowernumber');
-my $op = $input->param('op');
+our $filetype = $input->param('filetype');
+our $cardnumber = $input->param('cardnumber');
+our $uploadfilename = $input->param('uploadfile');
+our $uploadfile = $input->upload('uploadfile');
+our $borrowernumber = $input->param('borrowernumber');
+our $op = $input->param('op');
+our(%errors,@counts,%filerrors,@filerrors,$filename);
-my(%errors,@counts,%filerrors,@filerrors,$filename);
if ($op eq 'FindBorrower') {
my $borrowers = C4::Members::SearchMember($cardnumber) // [];
$template->param(
@@ -73,7 +73,7 @@
elsif (($op eq 'Upload') && $uploadfile) {
# Case is important in these operational values as the
# template must use case to be visually pleasing!
- _process_upload();
+ _process_upload_patron_image();
}
elsif (($op eq 'Upload') && !$uploadfile) {
$template->param(
@@ -103,7 +103,7 @@
exit;
##########################################################################
-sub _process_upload
+sub _process_upload_patron_image
{
my $dirname = File::Temp::tempdir( CLEANUP => 1);
my $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i;

0 comments on commit 39f7fdb

Please sign in to comment.