honor forceLoginSSL for place holds login in OPAC
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Nov 2010 20:24:47 +0000 (20:24 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Nov 2010 20:24:47 +0000 (20:24 +0000)
When forceLoginSSL is enabled and the user clicks on place-hold in
results page or record details page, reload the page as SSL (if it's not
already using SSL) and show the login dialog (if the user is not already
logged in).

git-svn-id: svn://svn.open-ils.org/ILS/trunk@18862 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/xml/page_rdetail.xml

index 7b250d3..977bf6e 100644 (file)
@@ -7,6 +7,16 @@ attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
 attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
 attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
 
+G.evt.rdetail.recordDrawn.push(
+    function(){
+        if(new CGI().param('place_hold')) {
+            // This will force the login dialog to display if the user is not logged in
+            holdsDrawEditor({record:record.doc_id(), type: 'T'});
+        }
+    }
+);
+
+
 /* Per-skin configuration settings */
 var rdetailLocalOnly = true;
 var rdetailShowLocal = true;
@@ -461,8 +471,24 @@ function _rdetailDraw(r) {
        }
        buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
 
-       $('rdetail_place_hold').setAttribute(
-                       'href','javascript:holdsDrawEditor({record:"'+record.doc_id()+'",type:"T"});');
+       $('rdetail_place_hold').onclick = function() {
+        var src = location.href;
+
+        if(forceLoginSSL && src.match(/^http:/)) {
+
+            src = src.replace(/^http:/, 'https:');
+
+            if(!src.match(/&place_hold=1/)) {
+                src += '&place_hold=1';
+            }
+
+            location.href = src;
+
+        } else {
+            holdsDrawEditor({record:record.doc_id(), type:'T'});
+        }
+    }
+
 
        var RW = $('rdetail_exp_refworks');
        if (RW && rdetailEnableRefWorks) {
index 409a1ca..a19cb26 100644 (file)
@@ -16,6 +16,17 @@ if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
        G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
        G.evt.result.allRecordsReceived.push( function(){unHideMe($('result_info_2'))}, fetchGoogleBooksLink, fetchChiliFreshReviews);
 
+    G.evt.result.allRecordsReceived.push( 
+        function(){
+            var cgi = new CGI();
+            var hold_target = cgi.param('hold_target');
+            if(hold_target) {
+                // This will force the login dialog to display if the user is not logged in
+                holdsDrawEditor({record:hold_target, type: (findCurrentPage() == MRESULT) ? 'M' : 'T'});
+            }
+        }
+    );
+
        attachEvt('result','lowHits',resultLowHits);
        attachEvt('result','zeroHits',resultZeroHits);
        attachEvt( "common", "locationUpdated", resultSBSubmit );
@@ -525,8 +536,8 @@ function resultDisplayRecord(rec, pos, is_mr) {
                }
 
                unHideMe($n(r,'place_hold_span'));
-               $n(r,'place_hold_link').setAttribute(
-                       'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"M"});');
+               $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'M'); }
+            
 
        } else {
                onlyrec = rec.doc_id();
@@ -540,9 +551,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
                pic.parentNode.setAttribute("href", buildOPACLink(args));
 
                unHideMe($n(r,'place_hold_span'));
-               $n(r,'place_hold_link').setAttribute(
-                       'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
-
+               $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'T'); }
        }
 
        buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
@@ -605,6 +614,29 @@ function resultDisplayRecord(rec, pos, is_mr) {
        */
 }
 
+function resultDrawHoldsWindow(hold_target, hold_type) {
+    var src = location.href;
+
+    if(forceLoginSSL && src.match(/^http:/)) {
+
+        src = src.replace(/^http:/, 'https:');
+
+        if(src.match(/&hold_target=/)) {
+            src.replace(/&hold_target=(\d+)/, hold_target);
+
+        } else {
+            src += '&hold_target=' + hold_target;
+        }
+
+        location.href = src;
+
+    } else {
+        holdsDrawEditor({record:hold_target, type:hold_type});
+    }
+}
+
+
+
 function _resultFindRec(id) {
        for( var i = 0; i != recordsCache.length; i++ ) {
                var rec = recordsCache[i];
index cfd2e69..c816b6d 100644 (file)
@@ -54,7 +54,7 @@
                                                <a id='rdetail_exp_refworks'>&opac.holds.exportRefWorks;</a>
                                        </span>
                                        <span style='padding-right: 7px;'>
-                                               <a id='rdetail_place_hold' class='classic_link'>&opac.holds.placeHold;</a>
+                                               <a id='rdetail_place_hold' class='classic_link' href='javascript:;'>&opac.holds.placeHold;</a>
                                        </span>
                                        <span style='padding-right: 7px;' class='hide_me' id='rdetail_more_actions'>
                                                <select id='rdetail_more_actions_selector' style='max-width: 11em;'>