From b42b0a9e2122f06549e81b31a0b88f34f557bf7e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 28 Aug 2013 10:07:24 +0000 Subject: [PATCH] new option to to show only enabled apps (ones which users can get run-rights for) in select-apps --- .../class.etemplate_widget_menupopup.inc.php | 22 ++++++++----------- etemplate/inc/class.select_widget.inc.php | 22 ++++++++----------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_menupopup.inc.php b/etemplate/inc/class.etemplate_widget_menupopup.inc.php index df3ec64815..372935fba5 100644 --- a/etemplate/inc/class.etemplate_widget_menupopup.inc.php +++ b/etemplate/inc/class.etemplate_widget_menupopup.inc.php @@ -540,13 +540,17 @@ class etemplate_widget_menupopup extends etemplate_widget $no_lang = True; break; - case 'select-app': // type2: ''=users enabled apps, 'installed', 'all' = not installed ones too + case 'select-app': // type2: 'user'=apps of current user, 'enabled', 'installed' (default), 'all' = not installed ones too $apps = array(); foreach ($GLOBALS['egw_info']['apps'] as $app => $data) { - if (!$type2 || $GLOBALS['egw_info']['user']['apps'][$app]) + if ($type2 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3)) { - $apps[$app] = $data['title'] ? $data['title'] : lang($app); + continue; // app not enabled (user can not have run rights for these apps) + } + if ($type2 != 'user' || $GLOBALS['egw_info']['user']['apps'][$app]) + { + $apps[$app] = lang($app); } } if ($type2 == 'all') @@ -562,16 +566,8 @@ class etemplate_widget_menupopup extends etemplate_widget } closedir($dir); } - $apps_lower = $apps; // case-in-sensitve sort - foreach ($apps_lower as $app => $title) - { - $apps_lower[$app] = strtolower($title); - } - asort($apps_lower); - foreach ($apps_lower as $app => $title) - { - $options[$app] = $apps[$app]; - } + natcasesort($apps); + $options = is_array($options) ? $options+$apps : $apps; break; case 'select-lang': diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php index 02d4cde5fb..dac8478280 100644 --- a/etemplate/inc/class.select_widget.inc.php +++ b/etemplate/inc/class.select_widget.inc.php @@ -434,13 +434,17 @@ class select_widget $cell['enhance'] = false; break; - case 'select-app': // type2: ''=users enabled apps, 'installed', 'all' = not installed ones too + case 'select-app': // type2: 'user'=apps of current user, 'enabled', 'installed' (default), 'all' = not installed ones too $apps = array(); foreach ($GLOBALS['egw_info']['apps'] as $app => $data) { - if (!$type2 || $GLOBALS['egw_info']['user']['apps'][$app]) + if ($type2 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3)) { - $apps[$app] = $data['title'] ? $data['title'] : lang($app); + continue; // app not enabled (user can not have run rights for these apps) + } + if ($type2 != 'user' || $GLOBALS['egw_info']['user']['apps'][$app]) + { + $apps[$app] = lang($app); } } if ($type2 == 'all') @@ -456,16 +460,8 @@ class select_widget } closedir($dir); } - $apps_lower = $apps; // case-in-sensitve sort - foreach ($apps_lower as $app => $title) - { - $apps_lower[$app] = strtolower($title); - } - asort($apps_lower); - foreach ($apps_lower as $app => $title) - { - $cell['sel_options'][$app] = $apps[$app]; - } + natcasesort($apps); + $cell['sel_options'] = is_array($cell['sel_options']) ? $cell['sel_options']+$apps : $apps; break; case 'select-lang':