diff --git a/admin/inc/class.admin_acl.inc.php b/admin/inc/class.admin_acl.inc.php index 8cd3e68618..e80d5f474c 100644 --- a/admin/inc/class.admin_acl.inc.php +++ b/admin/inc/class.admin_acl.inc.php @@ -356,9 +356,6 @@ class admin_acl //error_log(__METHOD__."() $n: ".array2string($row)); } //error_log(__METHOD__."(".array2string($query).") returning ".$total); - - // Get updated apps permission - $rows['acl_apps'] = $GLOBALS['egw']->acl->get_app_list_for_id('run', acl::READ, $query['account_id']); return $total; } @@ -391,6 +388,23 @@ class admin_acl return true; } + /** + * Get the list of applications allowed for the given user + * + * The list of applications is added to the json response + * + * @param int $account_id + */ + public static function ajax_get_app_list($account_id) + { + $list = array(); + if(self::check_access((int)$account_id,'run',false)) + { + $list = array_keys($GLOBALS['egw']->acl->get_user_applications((int)$account_id,false,false)); + } + egw_json_response::get()->data($list); + } + /** * Change (add, modify, delete) an ACL entry * @@ -453,7 +467,6 @@ class admin_acl $content = array(); $account_id = isset($_GET['account_id']) && (int)$_GET['account_id'] ? (int)$_GET['account_id'] : $GLOBALS['egw_info']['user']['account_id']; - $acl_apps = $GLOBALS['egw']->acl->get_app_list_for_id('run', acl::READ, $account_id); $content['nm'] = array( 'get_rows' => 'admin_acl::get_rows', 'no_cat' => true, @@ -472,8 +485,6 @@ class admin_acl 'location' => 'acl_rights', 'owner' => $account_id, ), array(), true), - // Client side is much easier if we send an array - 'acl_apps' => $acl_apps ? $acl_apps : array() ); $user = common::grab_owner_name($content['nm']['account_id']); $sel_options = array( diff --git a/admin/js/app.js b/admin/js/app.js index 881ca87f9a..3e052a04f1 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -389,6 +389,10 @@ app.classes.admin = AppJS.extend( // Pre-set appname to currently selected content.acl_appname = this.et2.getWidgetById('filter2').getValue()||""; } + if(!content.acl_account) + { + content.acl_account = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id'); + } if(!content.acl_location) { content.acl_location = this.et2.getWidgetById('filter').getValue() == 'run' ? 'run' : null; @@ -396,7 +400,9 @@ app.classes.admin = AppJS.extend( if(content.acl_location == 'run') { // These are the apps the account has access to - content.apps = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('acl_apps')||[]; + // Fetch current values from server + this.egw.json(className+'::ajax_get_app_list', [content.acl_account], function(data) {content.apps = data},this,false,this) + .sendRequest(); } else { @@ -407,10 +413,7 @@ app.classes.admin = AppJS.extend( sel_options.acl_appname[app] = this.egw.lang(app); } } - if(!content.acl_account) - { - content.acl_account = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id'); - } + } if(content.acl_appname) { @@ -436,6 +439,12 @@ app.classes.admin = AppJS.extend( sel_options.acl_account = jQuery.extend({},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_account != this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id')) + { + var account = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id'); + sel_options.acl_account[account] = 'loading'; + this.egw.link_title('home-accounts', account, function(title) {sel_options.acl_account[account] = title;}); + } if(content.acl_location) { sel_options.acl_location = jQuery.extend({},sel_options.acl_location); @@ -448,6 +457,9 @@ app.classes.admin = AppJS.extend( this.acl_dialog = null; if(_button_id != et2_dialog.OK_BUTTON) return; + // Restore account if it's readonly in dialog + if(!_value.acl_account) _value.acl_account = content.acl_account; + // Only send the request if they entered everything if(_value.acl_account && (_value.acl_appname && _value.acl_location || _value.apps)) { @@ -477,14 +489,6 @@ app.classes.admin = AppJS.extend( } } - // Update value in list - var list = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('acl_apps',true); - list.length = 0; - for(var app in _value.apps) - { - list.push(_value.apps[app]); - } - // Remove any removed if(removed.length > 0) { @@ -511,7 +515,7 @@ app.classes.admin = AppJS.extend( * Change handler for ACL edit dialog application selectbox. * Re-creates the dialog with the current values */ - acl_change_application: function(input, widget) + acl_reopen_dialog: function(input, widget) { var content = {}; if(this.acl_dialog != null) diff --git a/admin/templates/default/acl.edit.xet b/admin/templates/default/acl.edit.xet index a24f0c8cb7..276898dff0 100644 --- a/admin/templates/default/acl.edit.xet +++ b/admin/templates/default/acl.edit.xet @@ -11,13 +11,13 @@ - + - +