mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
static method to get app-names as options, as from the widget itself
This commit is contained in:
parent
ed0abde9ae
commit
baaaf5b877
@ -541,32 +541,7 @@ class etemplate_widget_menupopup extends etemplate_widget
|
||||
break;
|
||||
|
||||
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 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3))
|
||||
{
|
||||
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')
|
||||
{
|
||||
$dir = opendir(EGW_SERVER_ROOT);
|
||||
while ($file = readdir($dir))
|
||||
{
|
||||
if (@is_dir(EGW_SERVER_ROOT."/$file/setup") && $file[0] != '.' &&
|
||||
!isset($apps[$app = basename($file)]))
|
||||
{
|
||||
$apps[$app] = $app . ' (*)';
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
natcasesort($apps);
|
||||
$apps = self::app_options($type2);
|
||||
$options = is_array($options) ? $options+$apps : $apps;
|
||||
break;
|
||||
|
||||
@ -599,6 +574,43 @@ class etemplate_widget_menupopup extends etemplate_widget
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available apps as options
|
||||
*
|
||||
* @param string $type2='installed' 'user'=apps of current user, 'enabled', 'installed' (default), 'all' = not installed ones too
|
||||
* @return array app => label pairs sorted by label
|
||||
*/
|
||||
public static function app_options($type2)
|
||||
{
|
||||
$apps = array();
|
||||
foreach ($GLOBALS['egw_info']['apps'] as $app => $data)
|
||||
{
|
||||
if ($type2 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3))
|
||||
{
|
||||
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')
|
||||
{
|
||||
$dir = opendir(EGW_SERVER_ROOT);
|
||||
while ($file = readdir($dir))
|
||||
{
|
||||
if (@is_dir(EGW_SERVER_ROOT."/$file/setup") && $file[0] != '.' &&
|
||||
!isset($apps[$app = basename($file)]))
|
||||
{
|
||||
$apps[$app] = $app . ' (*)';
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
natcasesort($apps);
|
||||
return $apps;
|
||||
}
|
||||
|
||||
/**
|
||||
* internal function to format account-data
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user