From 4f4cc9001f5d92f9b7c5388f0291bd79404c316d Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 7 Aug 2012 20:15:24 -0400 Subject: [PATCH] Stage 1: Perl Attempt to ensure that we always write to oils://remote when needed. Signed-off-by: Thomas Berezansky Signed-off-by: Dan Scott --- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 14 ++++++++------ .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 4 ++-- .../lib/OpenILS/WWW/EGCatLoader/Container.pm | 4 ++-- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 10 +++++----- .../src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index f7220b10fb..5d536dd2d2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -146,8 +146,9 @@ sub load { # when they're already logged in. return $self->generic_redirect( sprintf( - "https://%s%s/myopac/main", - $self->apache->hostname, $self->ctx->{opac_root} + "%s://%s%s/myopac/main", + $self->ctx->{proto}, + $self->ctx->{hostname}, $self->ctx->{opac_root} ) ); } @@ -202,7 +203,7 @@ sub load { # ----------------------------------------------------------------------------- sub redirect_ssl { my $self = shift; - my $new_page = sprintf('https://%s%s', $self->apache->hostname, $self->apache->unparsed_uri); + my $new_page = sprintf('%s://%s%s', ($self->ctx->{is_staff} ? 'oils' : 'https'), $self->ctx->{hostname}, $self->apache->unparsed_uri); return $self->generic_redirect($new_page); } @@ -212,7 +213,7 @@ sub redirect_ssl { # ----------------------------------------------------------------------------- sub redirect_auth { my $self = shift; - my $login_page = sprintf('https://%s%s/login', $self->apache->hostname, $self->ctx->{opac_root}); + my $login_page = sprintf('%s://%s%s/login',($self->ctx->{is_staff} ? 'oils' : 'https'), $self->ctx->{hostname}, $self->ctx->{opac_root}); my $redirect_to = uri_escape($self->apache->unparsed_uri); return $self->generic_redirect("$login_page?redirect_to=$redirect_to"); } @@ -250,11 +251,12 @@ sub load_common { my $oils_wrapper = $self->apache->headers_in->get('OILS-Wrapper') || ''; $ctx->{is_staff} = ($oils_wrapper =~ /true/); $ctx->{proto} = 'oils' if $ctx->{is_staff}; + $ctx->{hostname} = 'remote' if $ctx->{is_staff}; $ctx->{physical_loc} = $self->get_physical_loc; # capture some commonly accessed pages - $ctx->{home_page} = 'http://' . $self->apache->hostname . $self->ctx->{opac_root} . "/home"; - $ctx->{logout_page} = 'https://' . $self->apache->hostname . $self->ctx->{opac_root} . "/logout"; + $ctx->{home_page} = $ctx->{proto} . '://' . $ctx->{hostname} . $self->ctx->{opac_root} . "/home"; + $ctx->{logout_page} = ($ctx->{proto} eq 'http' ? 'https' : $ctx->{proto} ) . '://' . $ctx->{hostname} . $self->ctx->{opac_root} . "/logout"; if($e->authtoken($self->cgi->cookie(COOKIE_SES))) { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index c11efe1dbd..81edf810e7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -592,7 +592,7 @@ sub handle_hold_update { 'open-ils.circ.hold.update.batch.atomic', $e->authtoken, undef, \@vals )->gather(1); # LFW XXX test for failure - $url = 'https://' . $self->apache->hostname . $self->ctx->{opac_root} . '/myopac/holds'; + $url = $self->ctx->{proto} . '://' . $self->ctx->{hostname} . $self->ctx->{opac_root} . '/myopac/holds'; foreach my $param (('loc', 'qtype', 'query')) { if ($self->cgi->param($param)) { $url .= ";$param=" . uri_escape($self->cgi->param($param)); @@ -1806,7 +1806,7 @@ sub load_myopac_bookbag_update { # This url intentionally leaves off the edit_notes parameter, but # may need to add some back in for paging. - my $url = "https://" . $self->apache->hostname . + my $url = $self->ctx->{proto} . "://" . $self->ctx->{hostname} . $self->ctx->{opac_root} . "/myopac/lists?"; foreach my $param (('loc', 'qtype', 'query', 'sort')) { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm index 481099fe4e..445654dbea 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm @@ -170,8 +170,8 @@ sub mylist_warning_redirect { my $base_url = sprintf( "%s://%s%s/temp_warn", - $self->cgi->https ? 'https' : 'http', - $self->apache->hostname, + $self->ctx->{proto}, + $self->ctx->{hostname}, $self->ctx->{opac_root} ); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index cecf0f0636..30de8e1a5b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -514,8 +514,8 @@ sub check_1hit_redirect { my $base_url = sprintf( '%s://%s%s/record/%s', - ($ctx->{is_staff} ? 'oils' : $ctx->{proto}), - ($ctx->{is_staff} ? 'remote' : $self->apache->hostname), + $self->ctx->{proto}, + $self->ctx->{hostname}, $self->ctx->{opac_root}, $$rec_ids[0], ); @@ -683,9 +683,9 @@ sub call_number_browse_standalone { if (my $cnfrag = $self->cgi->param("query")) { my $url = sprintf( - 'http%s://%s%s/cnbrowse?cn=%s', - $self->cgi->https ? "s" : "", - $self->apache->hostname, + '%s://%s%s/cnbrowse?cn=%s', + $self->ctx->{proto}, + $self->ctx->{hostname}, $self->ctx->{opac_root}, $cnfrag # XXX some kind of escaping needed here? ); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index 2f0e49eb82..77a7eae6a1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -241,7 +241,7 @@ sub load_kpac_config { $ctx->{kpac_layout} = $layout; $ctx->{kpac_config} = $kpac_config; $ctx->{kpac_root} = $ctx->{base_path} . "/kpac"; - $ctx->{home_page} = 'http://' . $self->apache->hostname . $ctx->{kpac_root} . "/home"; + $ctx->{home_page} = $ctx->{proto} . '://' . $ctx->{hostname} . $ctx->{kpac_root} . "/home"; $ctx->{global_search_filter} = $kpac_config->{global_filter}; } -- 2.43.2