From 91750f46c936c3ca00d91e331e661b722791c72a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 15 Sep 2015 23:59:31 +0000 Subject: [PATCH] Access dialog - If current app has no special support, show general dialog instead of message - Sort apps in add dialog - Filter app list (filter2) to all apps for run rights, or only supporting apps otherwise --- admin/inc/class.admin_acl.inc.php | 35 ++++++++++++++++++++++++---- admin/js/app.js | 10 ++++++-- phpgwapi/js/jsapi/egw_preferences.js | 4 ++-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/admin/inc/class.admin_acl.inc.php b/admin/inc/class.admin_acl.inc.php index 5eb27d0253..f59745f52e 100644 --- a/admin/inc/class.admin_acl.inc.php +++ b/admin/inc/class.admin_acl.inc.php @@ -248,6 +248,34 @@ class admin_acl } //error_log(__METHOD__."(".array2string($query).") returning ".$total); + // Get supporting or all apps for filter2 depending on filter + if($query['filter'] == 'run') + { + $rows['sel_options']['filter2'] = array( + '' => lang('All applications'), + )+etemplate_widget_menupopup::app_options('enabled'); + } + else + { + $rows['sel_options']['filter2'] = array( + array('value' => '', 'label' => lang('All applications')) + ); + $apps = $GLOBALS['egw']->hooks->process(array( + 'location' => 'acl_rights', + 'owner' => $query['account_id'], + ), array(), true); + foreach($apps as $appname => $rights) + { + $rows['sel_options']['filter2'][] = array( + 'value' => $appname, + 'label' => lang($appname) + ); + } + usort($rows['sel_options']['filter2'], function($a,$b) { + return strcasecmp($a['label'], $b['label']); + }); + } + return $total; } @@ -388,12 +416,9 @@ class admin_acl 'other' => lang('Access to %1 data by others', $user), 'own' => lang('%1 access to other data', $user), 'run' => lang('%1 run rights for applications', $user), - ), - 'filter2' => array( - '' => lang('All applications'), - )+etemplate_widget_menupopup::app_options('enabled'), + ) ); - + $tpl->exec('admin.admin_acl.index', $content, $sel_options); } diff --git a/admin/js/app.js b/admin/js/app.js index 5709a92f4e..6f3ebab143 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -447,11 +447,17 @@ app.classes.admin = AppJS.extend( else { // Restrict application selectbox to only apps that support ACL - sel_options.acl_appname = {}; + sel_options.acl_appname = []; for(var app in acl_rights) { - sel_options.acl_appname[app] = this.egw.lang(app); + sel_options.acl_appname.push({value: app, label: this.egw.lang(app)}); } + // Sort list + sel_options.acl_appname.sort(function(a,b) { + if(a.label > b.label) return 1; + if(a.label < b.label) return -1; + return 0; + }); } } diff --git a/phpgwapi/js/jsapi/egw_preferences.js b/phpgwapi/js/jsapi/egw_preferences.js index f3d16e1251..36c2332c3b 100644 --- a/phpgwapi/js/jsapi/egw_preferences.js +++ b/phpgwapi/js/jsapi/egw_preferences.js @@ -116,7 +116,7 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() { var current_app = this.app_name(); var query = {current_app: current_app}; // give warning, if app does not support given type, but all apps link to common prefs, if they dont support prefs themselfs - if ($j.isArray(apps) && $j.inArray(current_app, apps) == -1 && name != 'prefs' || + if ($j.isArray(apps) && $j.inArray(current_app, apps) == -1 && (name != 'prefs' && name != 'acl') || !$j.isArray(apps) && (typeof apps[current_app] == 'undefined' || !apps[current_app])) { egw_message(egw.lang('Not supported by current application!'), 'warning'); @@ -134,7 +134,7 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() { case 'acl': query.menuaction='preferences.preferences_acl.index'; - query.acl_app=current_app; + if ($j.inArray(current_app, apps) != -1) query.acl_app=current_app; egw.open_link(egw.link(url, query), '_blank', '900x450'); break;