From ecb8f84afaab2a6f10b99a4c60ac79a4addc1f03 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 22 May 2018 14:39:15 +0200 Subject: [PATCH] Add complementary option for app-select widget in order to be able to exclude specific apps from the list --- api/src/Etemplate/Widget/Select.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/src/Etemplate/Widget/Select.php b/api/src/Etemplate/Widget/Select.php index e05079423c..b4e258bdcb 100644 --- a/api/src/Etemplate/Widget/Select.php +++ b/api/src/Etemplate/Widget/Select.php @@ -770,19 +770,28 @@ class Select extends Etemplate\Widget /** * Get available apps as options * - * @param string $type2 ='installed' 'user'=apps of current user, 'enabled', 'installed' (default), 'all' = not installed ones too + * @param string $type2 ='installed[:home;groupdav; ...]' 'user'=apps of current user, + * 'enabled', 'installed' (default), 'all' = not installed ones too. In order to + * exclude apps explicitly we can list them (app name separator is ';') in front of the type. + * * @return array app => label pairs sorted by label */ public static function app_options($type2) { $apps = array(); + $parts = explode(":", $type2); + if (is_array($parts)) + { + $exceptions = explode(";", $parts[1]); + $type2 = $parts[0]; + } foreach ($GLOBALS['egw_info']['apps'] as $app => $data) { - if ($type2 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3)) + if ($type2 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3 || in_array($app, $exceptions))) { continue; // app not enabled (user can not have run rights for these apps) } - if ($type2 != 'user' || $GLOBALS['egw_info']['user']['apps'][$app]) + if (($type2 != 'user' || $GLOBALS['egw_info']['user']['apps'][$app]) && !in_array($app, $exceptions)) { $apps[$app] = lang($app); }