Fix some bugs in ACL:

- Allow to remove access to all application, previously could not remove the final app
This commit is contained in:
Nathan Gray 2015-01-07 17:59:34 +00:00
parent 7134da86b3
commit 2c01aa23d4

View File

@ -511,23 +511,32 @@ app.classes.admin = AppJS.extend(
// Restore account if it's readonly in dialog // Restore account if it's readonly in dialog
if(!_value.acl_account) _value.acl_account = content.acl_account; if(!_value.acl_account) _value.acl_account = content.acl_account;
// Only send the request if they entered everything // Handle no applications selected
if(_value.acl_account && (_value.acl_appname && _value.acl_location || _value.apps)) if(typeof _value.apps == 'undefined' && content.acl_location == 'run')
{ {
var id = _value.acl_appname+':'+_value.acl_account+':'+_value.acl_location; _value.apps = [];
if(content && content.id && id != content.id) }
// Only send the request if they entered everything (or selected no apps)
if(_value.acl_account && (_value.acl_appname && _value.acl_location || typeof _value.apps != 'undefined'))
{
if(_value.acl_appname && _value.acl_account && _value.acl_location)
{ {
// Changed the account or location, remove previous or we var id = _value.acl_appname+':'+_value.acl_account+':'+_value.acl_location;
// get a new line instead of an edit if(content && content.id && id != content.id)
this.egw.json(className+'::ajax_change_acl', [content.id, 0], null,this,false,this) {
.sendRequest(); // Changed the account or location, remove previous or we
// get a new line instead of an edit
this.egw.json(className+'::ajax_change_acl', [content.id, 0], null,this,false,this)
.sendRequest();
}
} }
var rights = 0; var rights = 0;
for(var i in _value.acl) for(var i in _value.acl)
{ {
rights += parseInt(_value.acl[i]); rights += parseInt(_value.acl[i]);
} }
if(_value.apps && !_value.acl_appname) if(typeof _value.apps != 'undefined' && !_value.acl_appname)
{ {
id = []; id = [];
rights = 1; rights = 1;
@ -537,7 +546,7 @@ app.classes.admin = AppJS.extend(
for(var app in sel_options.apps) for(var app in sel_options.apps)
{ {
var run_id = app+":"+_value.acl_account+":run"; var run_id = app+":"+_value.acl_account+":run";
if(_value.apps.indexOf(app) < 0 && content.apps.indexOf(app) >= 0) if(_value.apps.indexOf(app) < 0 && (content.apps.indexOf(app) >= 0 || content.apps.length == 0))
{ {
removed.push(run_id); removed.push(run_id);
} }