From f79c57f048cbb1b7ed215ba3a1f7920a9bf9d676 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 19 Jul 2022 18:28:44 +0200 Subject: [PATCH] fix InfoLog preferences shows wired looking categories --> fixed by using a select-cat --- infolog/inc/class.infolog_hooks.inc.php | 42 +++---------------- .../inc/class.preferences_settings.inc.php | 5 +++ 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/infolog/inc/class.infolog_hooks.inc.php b/infolog/inc/class.infolog_hooks.inc.php index dc81b81267..9eff742c42 100644 --- a/infolog/inc/class.infolog_hooks.inc.php +++ b/infolog/inc/class.infolog_hooks.inc.php @@ -207,7 +207,7 @@ class infolog_hooks */ 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 $filters = $show_home = array(); $show_home[] = lang("DON'T show InfoLog"); @@ -217,7 +217,7 @@ class infolog_hooks $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'))) { $GLOBALS['egw']->preferences->add('infolog','homeShowEvents','own-open-today',$GLOBALS['type']); @@ -281,10 +281,9 @@ class infolog_hooks 'default'=> 'date', ), 'cat_add_default' => array( - 'type' => 'select', + 'type' => 'select-cat', 'label' => 'Default category for new Infolog entries', 'name' => 'cat_add_default', - 'values' => self::all_cats(), 'help' => 'You can choose a categorie to be preselected, when you create a new Infolog entry', 'xmlrpc' => True, 'admin' => False, @@ -377,7 +376,7 @@ class infolog_hooks '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( '0' => lang('No'), '-1d' => lang('one day after'), @@ -494,37 +493,6 @@ class infolog_hooks 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 * @@ -590,4 +558,4 @@ class infolog_hooks 'popup' => Link::get_registry('infolog', 'edit_popup') ); } -} +} \ No newline at end of file diff --git a/preferences/inc/class.preferences_settings.inc.php b/preferences/inc/class.preferences_settings.inc.php index e377773fa8..7db1c292c4 100644 --- a/preferences/inc/class.preferences_settings.inc.php +++ b/preferences/inc/class.preferences_settings.inc.php @@ -464,6 +464,11 @@ class preferences_settings $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'allowFreeEntries', true); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', $old_type === 'select-tabs'); 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': $setting['type'] = 'et2-colorpicker'; break;