From 77fdad1194178d217b46c4c49d9930a2c31cd5be Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Thu, 12 Apr 2012 10:23:12 -0400 Subject: [PATCH] Operator Change Fun Allow for temporary, staff, and permanent operator changes. Temporary uses a temp authtoken for a few minute timeout. Staff uses a normal staff login authtoken for a multi-hour timeout. Permanent is a staff change that disregards the previous login instead of allowing it to be recovered by using the menu item again. I also fixed things up so later timeouts can re-use the previous duration and fixed up some title bar issues: 1 - Login screen shows version again (needed a document in the title set) 2 - Menu windows don't forget the server name 3 - Menu windows keep the same number for their lifetime Signed-off-by: Thomas Berezansky Signed-off-by: Bill Erickson --- Open-ILS/web/opac/locale/en-US/lang.dtd | 6 ++++ .../xul/staff_client/chrome/content/main/main.js | 2 +- .../xul/staff_client/chrome/content/main/menu.js | 17 +++++++---- .../chrome/content/main/menu_frame.xul | 3 +- .../staff_client/chrome/content/util/network.js | 23 ++++++++------- .../xul/staff_client/server/main/simple_auth.xul | 34 +++++++++++++++++++--- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 4ad7f61a01..c67c1b6b9e 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -255,6 +255,12 @@ + + + + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index 44d7f72245..c131bbe594 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -586,7 +586,7 @@ function main_init() { } } - window.title = authStrings.getFormattedString('staff.auth.titlebar.label', version); + window.document.title = authStrings.getFormattedString('staff.auth.titlebar.label', CLIENT_VERSION); var x = document.getElementById('about_btn'); x.addEventListener( 'command', diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 8d130f459e..1ef0da6fde 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -1284,13 +1284,18 @@ main.menu.prototype = { } else { if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) { obj.data.stash_retrieve(); - obj.data.list.au[1] = JSON2js( temp_au ); - obj.data.stash('list'); - obj.data.previous_session = JSON2js( temp_ses ); - obj.data.previous_menu_perms = obj.data.menu_perms; + if (obj.data.session.is_perm === false) { + obj.data.list.au[1] = JSON2js( temp_au ); + obj.data.stash('list'); + obj.data.previous_session = JSON2js( temp_ses ); + obj.data.previous_menu_perms = obj.data.menu_perms; + obj.data.stash('previous_session'); + obj.data.stash('previous_menu_perms'); + } else { + var temp_session_object = JSON2js( temp_ses ); + network.simple_request('AUTH_DELETE', [ temp_session_object.key ] ); + } obj.data.menu_perms = false; - obj.data.stash('previous_session'); - obj.data.stash('previous_menu_perms'); obj.data.stash('menu_perms'); } } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame.xul index e2f4ed98af..664366c1be 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame.xul @@ -94,7 +94,8 @@ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'}); XML_HTTP_SERVER = g.data.server_unadorned; - document.title = g.window.appshell_name_increment() + ': ' + g.data.list.au[0].usrname() + '@' + g.data.ws_name + '.' + g.data.server_unadorned; + window.egwinid = g.window.appshell_name_increment(); + document.title = window.egwinid + ': ' + g.data.list.au[0].usrname() + '@' + g.data.ws_name + '.' + g.data.server_unadorned; var delay = g.data.hash.aous["ui.general.idle_timeout"]; if (delay) setup_idle_observer(delay); diff --git a/Open-ILS/xul/staff_client/chrome/content/util/network.js b/Open-ILS/xul/staff_client/chrome/content/util/network.js index e999028322..395e50d0b2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/network.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/network.js @@ -296,17 +296,15 @@ util.network.prototype = { JSAN.use('util.window'); var win = new util.window(); var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(); var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); - var enumerator = windowManagerInterface.getEnumerator(null); + var enumerator = windowManagerInterface.getEnumerator('eg_menu'); var w; // set title on all appshell windows while ( w = enumerator.getNext() ) { - if (w.document.title.match(/^\d/)) { - w.document.title = - win.appshell_name_increment() - + ': ' + data.list.au[0].usrname() - + '@' + data.ws_name; - + '.' + data.server_unadorned - } + w.document.title = + w.egwinid + + ': ' + data.list.au[0].usrname() + + '@' + data.ws_name + + '.' + data.server_unadorned; } } catch(E) { obj.error.standard_unexpected_error_alert(offlineStrings.getString('network.window_title.error'),E); @@ -350,6 +348,8 @@ util.network.prototype = { var url = urls.XUL_AUTH_SIMPLE; if (typeof xulG != 'undefined' && typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url ); JSAN.use('util.window'); var win = new util.window(); + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.init({'via':'stash'}); var my_xulG = win.open( url, //+ '?login_type=staff' @@ -359,17 +359,18 @@ util.network.prototype = { offlineStrings.getString('network.new_session.authorize'), 'chrome,resizable,modal,width=700,height=500', { - 'login_type' : 'staff', + 'login_type' : text ? (data.session.login_type ? data.session.login_type : 'staff') : 'ochange', 'desc_brief' : text ? offlineStrings.getString('network.new_session.expired') : offlineStrings.getString('network.new_session.operator_change'), 'desc_full' : text ? offlineStrings.getString('network.new_session.expired.prompt') : offlineStrings.getString('network.new_session.operator_change.prompt') //'simple_auth' : (new Date()).toString(), } ); - JSAN.use('OpenILS.data'); - var data = new OpenILS.data(); data.init({'via':'stash'}); + data.stash_retrieve(); if (typeof data.temporary_session != 'undefined' && data.temporary_session != '') { data.session.key = data.temporary_session.key; data.session.authtime = data.temporary_session.authtime; + data.session.is_perm = data.temporary_session.is_perm; // For operator change, otherwise ignorable. + data.session.login_type = data.temporary_session.login_type; // For timeouts *after* operator change. data.stash('session'); try { var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); diff --git a/Open-ILS/xul/staff_client/server/main/simple_auth.xul b/Open-ILS/xul/staff_client/server/main/simple_auth.xul index e311333661..7e7a7d3b1d 100644 --- a/Open-ILS/xul/staff_client/server/main/simple_auth.xul +++ b/Open-ILS/xul/staff_client/server/main/simple_auth.xul @@ -37,6 +37,7 @@ - + +