Stage 1: Perl
authorThomas Berezansky <tsbere@mvlc.org>
Wed, 8 Aug 2012 00:15:24 +0000 (20:15 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 16 Aug 2012 02:25:59 +0000 (22:25 -0400)
Attempt to ensure that we always write to oils://remote when needed.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm

index f7220b1..5d536dd 100644 (file)
@@ -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))) {
 
index c11efe1..81edf81 100644 (file)
@@ -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')) {
index 481099f..445654d 100644 (file)
@@ -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}
     );
 
index cecf0f0..30de8e1 100644 (file)
@@ -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?
         );
index 2f0e49e..77a7eae 100644 (file)
@@ -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};
 }