}
}
+// Returns false if we can't get an actual perm list
+// Returns an array of perms with boolean has/hasn't flag
+function get_menu_perms(indocument) {
+ // If we don't have our static perm list, and we have a remote window, go looking.
+ // We never need to look twice unless a dev is manually editing their files.
+ // Shame on them, they can restart the entire client ;)
+ if(typeof(get_menu_perms.perm_list) == 'undefined' && indocument != null)
+ {
+ get_menu_perms.perm_list = [ ];
+ var commands = indocument.getElementById('universal_cmds').getElementsByTagName('command');
+ for (var i = 0; i < commands.length; i++) {
+ if (commands[i].hasAttribute('perm')) {
+ get_menu_perms.perm_list = get_menu_perms.perm_list.concat(commands[i].getAttribute('perm').split(' '));
+ }
+ }
+ }
+ //
+ if(typeof(get_menu_perms.perm_list) == 'object') {
+ G.data.stash_retrieve();
+ if(!G.data.menu_perms) {
+ JSAN.use('util.network');
+ var network = new util.network();
+ var r = network.simple_request('BATCH_PERM_RETRIEVE_WORK_OU', [ G.data.session.key, get_menu_perms.perm_list ]);
+ for(p in r)
+ r[p] = (typeof(r[p][0]) == 'number');
+ G.data.menu_perms = r;
+ G.data.stash('menu_perms');
+ }
+ return G.data.menu_perms;
+ }
+ return false;
+}
+
function main_init() {
dump('entering main_init()\n');
try {
if (y) y.setAttribute('hidden','true');
}
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
+ getService(Components.interfaces.nsIWindowMediator);
+ wm.getMostRecentWindow('eg_main').get_menu_perms(document);
+ JSAN.use('util.network');
+ var network = new util.network();
+ network.set_user_status();
+
function open_conify_page(path, labelKey, event) {
// tab label
try {
obj.data.stash_retrieve();
JSAN.use('util.network'); var network = new util.network();
- var x = document.getElementById('oc_menuitem');
- var x_label = x.getAttribute('label_orig');
var temp_au = js2JSON( obj.data.list.au[0] );
var temp_ses = js2JSON( obj.data.session );
if (obj.data.list.au.length > 1) {
obj.data.list.au = [ obj.data.list.au[1] ];
obj.data.stash('list');
network.reset_titlebars( obj.data );
- x.setAttribute('label', x_label );
network.simple_request('AUTH_DELETE', [ obj.data.session.key ] );
obj.data.session = obj.data.previous_session;
+ obj.data.menu_perms = obj.data.previous_menu_perms;
obj.data.stash('session');
+ obj.data.stash('menu_perms');
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
}
- removeCSSClass(document.getElementById('main_tabbox'),'operator_change');
} 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;
+ obj.data.menu_perms = false;
obj.data.stash('previous_session');
- x.setAttribute('label', offlineStrings.getFormattedString('menu.cmd_chg_session.operator.label', [obj.data.list.au[1].usrname()]) );
- addCSSClass(document.getElementById('main_tabbox'),'operator_change');
+ obj.data.stash('previous_menu_perms');
+ obj.data.stash('menu_perms');
}
}
+ network.set_user_status();
} catch(E) {
obj.error.standard_unexpected_error_alert('cmd_change_session',E);
}
}
},
+ 'set_menu_access' : function(perms) {
+ if(perms === false) return;
+ var commands = document.getElementById('universal_cmds').getElementsByTagName('command');
+ var commandperms;
+commands:
+ for (var i = 0; i < commands.length; i++) {
+ if (commands[i].hasAttribute('perm')) {
+ commandperms = commands[i].getAttribute('perm').split(' ');
+ for (var j = 0; j < commandperms.length; j++) {
+ if (perms[commandperms[j]]) {
+ commands[i].setAttribute('disabled','false');
+ continue commands;
+ }
+ }
+ commands[i].setAttribute('disabled','true');
+ }
+ }
+
+ },
+
'page_meter' : {
'node' : document.getElementById('page_progress'),
'on' : function() {
}
},
+ 'set_user_status' : function() {
+ data.stash_retrieve();
+ try {
+ var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
+ var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
+ var permlist = windowManagerInterface.getMostRecentWindow('eg_main').get_menu_perms(null);
+ var offlinestrings;
+ var enumerator = windowManagerInterface.getEnumerator('eg_menu');
+
+ var w;
+ var x;
+ while ( w = enumerator.getNext() ) {
+ x = w.document.getElementById('oc_menuitem');
+
+ if(!offlinestrings) w.document.getElementById('offlineStrings');
+ if(permlist) w.g.menu.set_menu_access(permlist);
+ if(data.list.au.length > 1) {
+ addCSSClass(w.document.getElementById('main_tabbox'),'operator_change');
+ x.setAttribute('label', offlineStrings.getFormattedString('menu.cmd_chg_session.operator.label', [data.list.au[1].usrname()]) );
+ }
+ else {
+ removeCSSClass(w.document.getElementById('main_tabbox'),'operator_change');
+ x.setAttribute('label', x.getAttribute('label_orig'));
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(offlineStrings.getString('network.window_title.error'),E);
+ }
+ },
+
'get_new_session' : function(name,xulG,text) {
var obj = this;
try {