fix InfoLog preferences shows wired looking categories --> fixed by using a select-cat

This commit is contained in:
ralf 2022-07-19 18:28:44 +02:00
parent 6ab34234f5
commit f79c57f048
2 changed files with 10 additions and 37 deletions

View File

@ -207,7 +207,7 @@ class infolog_hooks
*/ */
static function settings() static function settings()
{ {
/* Setup some values to fill the array of this app's settings below */ /* Setup some values to fill the array with this app's settings below */
$info = new infolog_bo(); // need some labels from $info = new infolog_bo(); // need some labels from
$filters = $show_home = array(); $filters = $show_home = array();
$show_home[] = lang("DON'T show InfoLog"); $show_home[] = lang("DON'T show InfoLog");
@ -217,7 +217,7 @@ class infolog_hooks
$show_home[$key] = $filters[$key] = lang($label); $show_home[$key] = $filters[$key] = lang($label);
} }
// migrage old filter-pref 1,2 to the filter one 'own-open-today' // migrate old filter-pref 1,2 to the filter one 'own-open-today'
if (isset($GLOBALS['type']) && in_array($GLOBALS['egw']->preferences->{$GLOBALS['type']}['homeShowEvents'],array('1','2'))) if (isset($GLOBALS['type']) && in_array($GLOBALS['egw']->preferences->{$GLOBALS['type']}['homeShowEvents'],array('1','2')))
{ {
$GLOBALS['egw']->preferences->add('infolog','homeShowEvents','own-open-today',$GLOBALS['type']); $GLOBALS['egw']->preferences->add('infolog','homeShowEvents','own-open-today',$GLOBALS['type']);
@ -281,10 +281,9 @@ class infolog_hooks
'default'=> 'date', 'default'=> 'date',
), ),
'cat_add_default' => array( 'cat_add_default' => array(
'type' => 'select', 'type' => 'select-cat',
'label' => 'Default category for new Infolog entries', 'label' => 'Default category for new Infolog entries',
'name' => 'cat_add_default', 'name' => 'cat_add_default',
'values' => self::all_cats(),
'help' => 'You can choose a categorie to be preselected, when you create a new Infolog entry', 'help' => 'You can choose a categorie to be preselected, when you create a new Infolog entry',
'xmlrpc' => True, 'xmlrpc' => True,
'admin' => False, 'admin' => False,
@ -377,7 +376,7 @@ class infolog_hooks
'default'=> '1', // Yes 'default'=> '1', // Yes
); );
// to add options for more then 3 days back or in advance, you need to update soinfolog::users_with_open_entries()! // to add options for more than 3 days back or in advance, you need to update infolog_so::users_with_open_entries()!
$options = array( $options = array(
'0' => lang('No'), '0' => lang('No'),
'-1d' => lang('one day after'), '-1d' => lang('one day after'),
@ -494,37 +493,6 @@ class infolog_hooks
return $settings; return $settings;
} }
/**
* Return InoLog Categories (used for setting )
*
* @return array
*/
private static function all_cats()
{
$categories = new Api\Categories('','infolog');
$accountId = $GLOBALS['egw_info']['user']['account_id'];
foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat)
{
$s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']);
if ($cat['app_name'] == 'phpgw' || $cat['owner'] == '-1')
{
$s .= ' ♦';
}
elseif ($cat['owner'] != $accountId)
{
$s .= '<' . $GLOBALS['egw']->accounts->id2name($cat['owner'], 'account_fullname') . '>';
}
elseif ($cat['access'] == 'private')
{
$s .= ' ♥';
}
$sel_options[$cat['id']] = $s; // 0.9.14 only
}
return $sel_options;
}
/** /**
* Verification hook called if settings / preferences get stored * Verification hook called if settings / preferences get stored
* *
@ -590,4 +558,4 @@ class infolog_hooks
'popup' => Link::get_registry('infolog', 'edit_popup') 'popup' => Link::get_registry('infolog', 'edit_popup')
); );
} }
} }

View File

@ -464,6 +464,11 @@ class preferences_settings
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'allowFreeEntries', true); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'allowFreeEntries', true);
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', $old_type === 'select-tabs'); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', $old_type === 'select-tabs');
break; break;
case 'select-cat': // using application=$appname and global=true
$setting['type'] = 'et2-select-cat';
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'application', $appname);
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'global_categories', true);
break;
case 'color': case 'color':
$setting['type'] = 'et2-colorpicker'; $setting['type'] = 'et2-colorpicker';
break; break;