mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
Some restructuring, add a change handler to update ACL options if ACL appname is changed
This commit is contained in:
parent
f5297f17a7
commit
857ed0e752
171
admin/js/app.js
171
admin/js/app.js
@ -35,6 +35,11 @@ app.classes.admin = AppJS.extend(
|
|||||||
*/
|
*/
|
||||||
nm: null,
|
nm: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to ACL edit dialog (not the list)
|
||||||
|
*/
|
||||||
|
acl_dialog: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -52,6 +57,8 @@ app.classes.admin = AppJS.extend(
|
|||||||
destroy: function()
|
destroy: function()
|
||||||
{
|
{
|
||||||
this.iframe = null;
|
this.iframe = null;
|
||||||
|
this.nm = null;
|
||||||
|
this.acl_dialog = null;
|
||||||
|
|
||||||
// call parent
|
// call parent
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
@ -324,30 +331,72 @@ app.classes.admin = AppJS.extend(
|
|||||||
{
|
{
|
||||||
ids.push(_senders[i].id.split('::').pop()); // remove "admin::" prefix
|
ids.push(_senders[i].id.split('::').pop()); // remove "admin::" prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For edit, set some data from the list since it's already there
|
||||||
|
var content = _senders[0].id ? jQuery.extend({}, egw.dataGetUIDdata(_senders[0].id).data) : {};
|
||||||
|
|
||||||
|
switch(_action.id)
|
||||||
|
{
|
||||||
|
case 'delete':
|
||||||
|
var app = egw.app_name(); // can be either admin or preferences!
|
||||||
|
if (app != 'admin') app = 'preferences';
|
||||||
|
var className = app+'_acl';
|
||||||
|
var request = egw.json(className+'::ajax_change_acl', [ids], this._acl_callback,this,false,this)
|
||||||
|
.sendRequest();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'add':
|
||||||
|
// No content, even if they clicked on a row
|
||||||
|
// Defaults set by _acl_content() based on nm values
|
||||||
|
content = {};
|
||||||
|
// Fall through
|
||||||
|
case 'edit':
|
||||||
|
this._acl_dialog(content);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the ACL edit dialog, including defaults & fetching what can be found
|
||||||
|
*
|
||||||
|
* @param content List of content for the dialog template
|
||||||
|
* @param sel_options optional select options
|
||||||
|
*/
|
||||||
|
_acl_dialog: function(content, sel_options)
|
||||||
|
{
|
||||||
|
if(typeof content == 'undefined') content = {};
|
||||||
|
|
||||||
|
// Determine which application we're running as
|
||||||
var app = egw.app_name(); // can be either admin or preferences!
|
var app = egw.app_name(); // can be either admin or preferences!
|
||||||
if (app != 'admin') app = 'preferences';
|
if (app != 'admin') app = 'preferences';
|
||||||
var className = app+'_acl';
|
var className = app+'_acl';
|
||||||
|
var acl_rights = {};
|
||||||
|
var readonlys = {acl: {}};
|
||||||
|
|
||||||
// Select options are already here, just pull them and pass along
|
// Select options are already here, just pull them and pass along
|
||||||
var sel_options = jQuery.extend({}, this.et2.getArrayMgr('sel_options').data||{}, {
|
sel_options = jQuery.extend({}, this.et2.getArrayMgr('sel_options').data||{}, {
|
||||||
'apps': this.et2.getArrayMgr('sel_options').getEntry('acl_appname')
|
'apps': this.et2.getArrayMgr('sel_options').getEntry('acl_appname')
|
||||||
});
|
},sel_options);
|
||||||
|
|
||||||
// For add and edit, set some data from the list since it's already there
|
// Some defaults
|
||||||
var acl_rights = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('acl_rights')||{};
|
if(this.et2 && this.et2.getWidgetById('nm'))
|
||||||
var content = _senders[0].id ? jQuery.extend({}, egw.dataGetUIDdata(_senders[0].id).data) : {};
|
|
||||||
if(!content.acl_appname)
|
|
||||||
{
|
{
|
||||||
// Pre-set appname to currently selected
|
// This is which checkboxes are available for each app
|
||||||
content.acl_appname = this.et2.getWidgetById('filter2').getValue();
|
var acl_rights = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('acl_rights')||{};
|
||||||
}
|
|
||||||
if(!content.acl_location)
|
if(!content.acl_appname)
|
||||||
{
|
{
|
||||||
content.acl_location = this.et2.getWidgetById('filter2').getValue() == 'run' ? 'run' : null;
|
// Pre-set appname to currently selected
|
||||||
}
|
content.acl_appname = this.et2.getWidgetById('filter2').getValue()||"";
|
||||||
if(!content.acl_account)
|
}
|
||||||
{
|
if(!content.acl_location)
|
||||||
content.acl_account = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id');
|
{
|
||||||
|
content.acl_location = this.et2.getWidgetById('filter2').getValue() == 'run' ? 'run' : null;
|
||||||
|
}
|
||||||
|
if(!content.acl_account)
|
||||||
|
{
|
||||||
|
content.acl_account = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(content.acl_appname)
|
if(content.acl_appname)
|
||||||
{
|
{
|
||||||
@ -356,56 +405,66 @@ app.classes.admin = AppJS.extend(
|
|||||||
jQuery.extend(content, {acl:[],right:[],label:[]});
|
jQuery.extend(content, {acl:[],right:[],label:[]});
|
||||||
for( var right in acl_rights[content.acl_appname])
|
for( var right in acl_rights[content.acl_appname])
|
||||||
{
|
{
|
||||||
|
if(right == '16' && content['acl_account'] != egw.user('account_id'))
|
||||||
|
{
|
||||||
|
// only user himself is allowed to grant private (16) rights
|
||||||
|
readonlys.acl[content.acl.length] = true;
|
||||||
|
}
|
||||||
content.acl.push(content.acl_rights & right);
|
content.acl.push(content.acl_rights & right);
|
||||||
content.right.push(right);
|
content.right.push(right);
|
||||||
content.label.push(egw.lang(acl_rights[content.acl_appname][right]));
|
content.label.push(egw.lang(acl_rights[content.acl_appname][right]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// These aren't actually there
|
|
||||||
if(content.acl_account)
|
|
||||||
{
|
|
||||||
sel_options.acl_account = {};
|
|
||||||
this.egw.link_title('home-accounts', content.acl_account, function(title) {sel_options.acl_account[content.acl_account] = title;});
|
|
||||||
}
|
|
||||||
if(content.acl_location)
|
|
||||||
{
|
|
||||||
sel_options.acl_location = {};
|
|
||||||
this.egw.link_title('home-accounts', content.acl_location, function(title) {sel_options.acl_location[content.acl_location] = title;});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(_action.id)
|
// Create the dialog
|
||||||
|
this.acl_dialog = et2_createWidget("dialog", {
|
||||||
|
callback: jQuery.proxy(function(_button_id, _value) {
|
||||||
|
this.acl_dialog = null;
|
||||||
|
if(_button_id != et2_dialog.OK_BUTTON) return;
|
||||||
|
|
||||||
|
// Only send the request if they entered everything
|
||||||
|
if(_value.acl_appname && _value.acl_account && _value.acl_location)
|
||||||
|
{
|
||||||
|
var id = _value.acl_appname+':'+_value.acl_account+':'+_value.acl_location;
|
||||||
|
var rights = 0;
|
||||||
|
for(var i in _value.acl)
|
||||||
|
{
|
||||||
|
rights += parseInt(_value.acl[i]);
|
||||||
|
}
|
||||||
|
this.egw.json(className+'::ajax_change_acl', [id, rights], this._acl_callback,this,false,this)
|
||||||
|
.sendRequest();
|
||||||
|
}
|
||||||
|
},this),
|
||||||
|
title: egw.lang('Access control'),
|
||||||
|
buttons: et2_dialog.BUTTONS_OK_CANCEL,
|
||||||
|
value: {
|
||||||
|
content: content,
|
||||||
|
sel_options: sel_options,
|
||||||
|
readonlys: readonlys
|
||||||
|
},
|
||||||
|
template: egw.webserverUrl+'/admin/templates/default/acl.edit.xet'
|
||||||
|
}, et2_dialog._create_parent(app));
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change handler for ACL edit dialog application selectbox.
|
||||||
|
* Re-creates the dialog with the current values
|
||||||
|
*/
|
||||||
|
acl_change_application: function(input, widget)
|
||||||
|
{
|
||||||
|
var content = {};
|
||||||
|
if(this.acl_dialog != null)
|
||||||
{
|
{
|
||||||
case 'delete':
|
content = this.acl_dialog.get_value() || {};
|
||||||
var request = egw.json(className+'::ajax_change_acl', [ids], this._acl_callback,this,false,this)
|
|
||||||
.sendRequest();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'edit':
|
// Destroy the dialog
|
||||||
case 'add':
|
this.acl_dialog.free();
|
||||||
return et2_createWidget("dialog", {
|
this.acl_dialog = null;
|
||||||
callback: jQuery.proxy(function(_button_id, _value) {
|
|
||||||
if(_button_id != et2_dialog.OK_BUTTON) return;
|
|
||||||
|
|
||||||
var id = _value.acl_appname+':'+_value.acl_account+':'+_value.acl_location;
|
|
||||||
var rights = 0;
|
|
||||||
for(var i in _value.acl)
|
|
||||||
{
|
|
||||||
rights += parseInt(_value.acl[i]);
|
|
||||||
}
|
|
||||||
this.egw.json(className+'::ajax_change_acl', [id, rights], this._acl_callback,this,false,this)
|
|
||||||
.sendRequest();
|
|
||||||
},this),
|
|
||||||
title: egw.lang('Access control'),
|
|
||||||
buttons: et2_dialog.BUTTONS_OK_CANCEL,
|
|
||||||
value: {
|
|
||||||
content: content,
|
|
||||||
sel_options: sel_options
|
|
||||||
},
|
|
||||||
template: egw.webserverUrl+'/admin/templates/default/acl.edit.xet'
|
|
||||||
}, et2_dialog._create_parent(app));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
// Re-open the dialog
|
||||||
|
this._acl_dialog(content);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<row disabled="@acl_location=run" part="header">
|
<row disabled="@acl_location=run" part="header">
|
||||||
<description value="Application"/>
|
<description value="Application"/>
|
||||||
<menulist>
|
<menulist>
|
||||||
<menupopup id="acl_appname" needed="1" onchange="1" options="Select one"/>
|
<menupopup id="acl_appname" needed="1" onchange="app.admin.acl_change_application" options="Select one"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
</row>
|
</row>
|
||||||
<row part="header">
|
<row part="header">
|
||||||
|
Loading…
Reference in New Issue
Block a user