diff --git a/Koha/Plack/Util.pm b/Koha/Plack/Util.pm index 61f6412adb..9cc7de92a9 100644 --- a/Koha/Plack/Util.pm +++ b/Koha/Plack/Util.pm @@ -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; diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index 15929b6b3c..c63db1cb94 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -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;