From: erickson Date: Mon, 29 Nov 2010 20:24:47 +0000 (+0000) Subject: honor forceLoginSSL for place holds login in OPAC X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d6a614f31e49a704cfab4f635020f0540787011b;p=evergreen%2Fbjwebb.git honor forceLoginSSL for place holds login in OPAC 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 --- diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index 7b250d3b3..977bf6eab 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -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) { diff --git a/Open-ILS/web/opac/skin/default/js/result_common.js b/Open-ILS/web/opac/skin/default/js/result_common.js index 409a1ca49..a19cb269b 100644 --- a/Open-ILS/web/opac/skin/default/js/result_common.js +++ b/Open-ILS/web/opac/skin/default/js/result_common.js @@ -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]; diff --git a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml index cfd2e69e6..c816b6d82 100644 --- a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml +++ b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml @@ -54,7 +54,7 @@ &opac.holds.exportRefWorks; - &opac.holds.placeHold; + &opac.holds.placeHold;