new option to to show only enabled apps (ones which users can get run-rights for) in select-apps

This commit is contained in:
Ralf Becker 2013-08-28 10:07:24 +00:00
parent c12c53bcb8
commit b42b0a9e21
2 changed files with 18 additions and 26 deletions

View File

@ -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':

View File

@ -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':