if(this.cancelled) return;
-
-
/* determine the xmlhttp server dynamically */
var url = location.protocol + "//" + location.host + "/" + XML_HTTP_GATEWAY;
var data = null;
if( this.type == 'GET' ) url += "?" + this.param_string;
- if(isXUL() && this.secure ) dump('SECURE = true\n');
-
this.url = url;
try {
try {
var auth;
try { auth = cookieManager.read(COOKIE_SES) } catch(ee) {}
- if( !auth && isXUL() ) auth = ses();
+ if( isXUL() ) auth = fetchXULStash().session.key;
if( auth )
this.xmlhttp.setRequestHeader('X-OILS-Authtoken', auth);
var status = null;
this.event(null);
- /* DEBUG
+ /*
try {
dump(this.url + '?' + this.param_string + '\n' +
'Returned with \n\tstatus = ' + this.xmlhttp.status +
var text = this.xmlhttp.responseText;
+ //try{if(getDebug()) _debug('response: ' + text + '\n')}catch(e){}
+
if(text == "" || text == " " || text == null) {
try { dump('dbg: Request returned no text!\n'); } catch(E) {}
if(isXUL())
this.param_string += "¶m=" + string;
}
+function fetchXULStash() {
+ if( isXUL() ) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var __OILS = new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
+ var data_cache = new __OILS( );
+ return data_cache.wrappedJSObject.OpenILS.prototype.data;
+
+ } catch(E) {
+ _debug('Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
+ }
+ }
+ return {};
+}
+
+
linknode.setAttribute("href", buildOPACLink(args));
}
+function setSessionCookie(ses) {
+ cookieManager.write(COOKIE_SES, ses, -1);
+}
+
+
/* ----------------------------------------------------------------------- */
/* user session handling */
if ses != G.user.session, we also force a grab */
function grabUser(ses, force) {
- if(!ses && isXUL()) ses = xulG['authtoken'];
+ if(!ses && isXUL()) {
+ stash = fetchXULStash();
+ ses = stash.session.key
+ _debug("stash auth token = " + ses);
+ }
if(!ses) {
ses = cookieManager.read(COOKIE_SES);
G.user = user;
G.user.fleshed = false;
G.user.session = ses;
- cookieManager.write(COOKIE_SES, ses, -1);
+ setSessionCookie(ses);
grabUserPrefs();
if(G.user.prefs['opac.hits_per_page'])
G.user.session = ses;
G.user.fleshed = true;
- cookieManager.write(COOKIE_SES, ses, '+1y'); /* update the cookie */
+ setSessionCookie(ses);
return G.user;
}