Skip to content

Commit

Permalink
Merge pull request #228 from hgq/18_03_pt18913469_4_08
Browse files Browse the repository at this point in the history
18 03 pt18913469 4 08
  • Loading branch information
ctfliblime committed Nov 1, 2011
2 parents 9b3d273 + 39f7fdb commit 668c43a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
16 changes: 16 additions & 0 deletions Koha/Plack/Util.pm
Expand Up @@ -17,4 +17,20 @@ sub GetCanonicalHostname {
return $hostname; 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; 1;
22 changes: 11 additions & 11 deletions tools/picture-upload.pl
Expand Up @@ -46,8 +46,8 @@
use C4::Output; use C4::Output;
use C4::Members; use C4::Members;


my $input = new CGI; our $input = new CGI;
my ($template, $loggedinuser, $cookie) = get_template_and_user({ our($template, $loggedinuser, $cookie) = get_template_and_user({
template_name => 'tools/picture-upload.tmpl', template_name => 'tools/picture-upload.tmpl',
query => $input, query => $input,
type => 'intranet', type => 'intranet',
Expand All @@ -56,14 +56,14 @@
debug => 0, debug => 0,
}); });


my $filetype = $input->param('filetype'); our $filetype = $input->param('filetype');
my $cardnumber = $input->param('cardnumber'); our $cardnumber = $input->param('cardnumber');
my $uploadfilename = $input->param('uploadfile'); our $uploadfilename = $input->param('uploadfile');
my $uploadfile = $input->upload('uploadfile'); our $uploadfile = $input->upload('uploadfile');
my $borrowernumber = $input->param('borrowernumber'); our $borrowernumber = $input->param('borrowernumber');
my $op = $input->param('op'); our $op = $input->param('op');
our(%errors,@counts,%filerrors,@filerrors,$filename);


my(%errors,@counts,%filerrors,@filerrors,$filename);
if ($op eq 'FindBorrower') { if ($op eq 'FindBorrower') {
my $borrowers = C4::Members::SearchMember($cardnumber) // []; my $borrowers = C4::Members::SearchMember($cardnumber) // [];
$template->param( $template->param(
Expand All @@ -73,7 +73,7 @@
elsif (($op eq 'Upload') && $uploadfile) { elsif (($op eq 'Upload') && $uploadfile) {
# Case is important in these operational values as the # Case is important in these operational values as the
# template must use case to be visually pleasing! # template must use case to be visually pleasing!
_process_upload(); _process_upload_patron_image();
} }
elsif (($op eq 'Upload') && !$uploadfile) { elsif (($op eq 'Upload') && !$uploadfile) {
$template->param( $template->param(
Expand Down Expand Up @@ -103,7 +103,7 @@
exit; exit;


########################################################################## ##########################################################################
sub _process_upload sub _process_upload_patron_image
{ {
my $dirname = File::Temp::tempdir( CLEANUP => 1); my $dirname = File::Temp::tempdir( CLEANUP => 1);
my $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i; my $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i;
Expand Down

0 comments on commit 668c43a

Please sign in to comment.