From fc8a139f239a76ec56100db85810c98518331423 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 15 Oct 2012 17:57:58 +0000 Subject: [PATCH] Add 'None' category option to context menu for all apps using nextmatch::category_action() --- addressbook/inc/class.addressbook_ui.inc.php | 6 ++++-- etemplate/inc/class.nextmatch_widget.inc.php | 11 ++++++++++- infolog/inc/class.infolog_ui.inc.php | 11 +++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 374d41a267..136ddfcaa5 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -437,13 +437,15 @@ class addressbook_ui extends addressbook_bo 'group' => $group, 'children' => array( 'cat_add' => nextmatch_widget::category_action( - 'addressbook',$group,'Add category', 'cat_add_' + 'addressbook',$group,'Add category', 'cat_add_', + true, 0,nextmatch_widget::DEFAULT_MAX_MENU_LENGTH,false )+array( 'icon' => 'foldertree_nolines_plus', 'disableClass' => 'rowNoEdit', ), 'cat_del' => nextmatch_widget::category_action( - 'addressbook',$group,'Delete category', 'cat_del_' + 'addressbook',$group,'Delete category', 'cat_del_', + true, 0,nextmatch_widget::DEFAULT_MAX_MENU_LENGTH,false )+array( 'icon' => 'foldertree_nolines_minus', 'disableClass' => 'rowNoEdit', diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index de25762445..a51cf732f1 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -776,14 +776,23 @@ class nextmatch_widget * @param boolean $globals=true application global categories too * @param int $parent_id=0 only returns cats of a certain parent * @param int $max_cats_flat=self::DEFAULT_MAX_MENU_LENGTH use hierarchical display if more cats + * @param boolean $none_option = true Include an option 'None' to clear category * @return array like self::egw_actions */ public static function category_action($app, $group=0, $caption='Change category', - $prefix='cat_', $globals=true, $parent_id=0, $max_cats_flat=self::DEFAULT_MAX_MENU_LENGTH) + $prefix='cat_', $globals=true, $parent_id=0, $max_cats_flat=self::DEFAULT_MAX_MENU_LENGTH, $none_option = true) { $cat = new categories(null,$app); $cats = $cat->return_sorted_array($start=0, $limit=false, $query='', $sort='ASC', $order='cat_name', $globals, $parent_id, $unserialize_data=true); + if($none_option) + { + array_unshift($cats, array( + 'id' => '', + 'name' => 'None' + )); + } + // if more than max_length cats, switch automatically to hierarchical display if (count($cats) > $max_cats_flat) { diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 596ef23c85..a438aceef6 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1377,8 +1377,15 @@ else break; case 'cat': - $cat_name = categories::id2name($settings); - $action_msg = lang('changed category to %1', $cat_name); + if($settings) + { + $cat_name = categories::id2name($settings); + $action_msg = lang('changed category to %1', $cat_name); + } + else + { + $action_msg = lang('removed category'); + } $entry['info_cat'] = $settings; if($this->bo->write($entry, true,true,true,$skip_notifications)) {