mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-27 00:09:13 +01:00
Add 'None' category option to context menu for all apps using nextmatch::category_action()
This commit is contained in:
parent
6996efe50b
commit
fc8a139f23
@ -437,13 +437,15 @@ class addressbook_ui extends addressbook_bo
|
|||||||
'group' => $group,
|
'group' => $group,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'cat_add' => nextmatch_widget::category_action(
|
'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(
|
)+array(
|
||||||
'icon' => 'foldertree_nolines_plus',
|
'icon' => 'foldertree_nolines_plus',
|
||||||
'disableClass' => 'rowNoEdit',
|
'disableClass' => 'rowNoEdit',
|
||||||
),
|
),
|
||||||
'cat_del' => nextmatch_widget::category_action(
|
'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(
|
)+array(
|
||||||
'icon' => 'foldertree_nolines_minus',
|
'icon' => 'foldertree_nolines_minus',
|
||||||
'disableClass' => 'rowNoEdit',
|
'disableClass' => 'rowNoEdit',
|
||||||
|
@ -776,14 +776,23 @@ class nextmatch_widget
|
|||||||
* @param boolean $globals=true application global categories too
|
* @param boolean $globals=true application global categories too
|
||||||
* @param int $parent_id=0 only returns cats of a certain parent
|
* @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 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
|
* @return array like self::egw_actions
|
||||||
*/
|
*/
|
||||||
public static function category_action($app, $group=0, $caption='Change category',
|
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);
|
$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);
|
$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 more than max_length cats, switch automatically to hierarchical display
|
||||||
if (count($cats) > $max_cats_flat)
|
if (count($cats) > $max_cats_flat)
|
||||||
{
|
{
|
||||||
|
@ -1377,8 +1377,15 @@ else
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cat':
|
case 'cat':
|
||||||
$cat_name = categories::id2name($settings);
|
if($settings)
|
||||||
$action_msg = lang('changed category to %1', $cat_name);
|
{
|
||||||
|
$cat_name = categories::id2name($settings);
|
||||||
|
$action_msg = lang('changed category to %1', $cat_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$action_msg = lang('removed category');
|
||||||
|
}
|
||||||
$entry['info_cat'] = $settings;
|
$entry['info_cat'] = $settings;
|
||||||
if($this->bo->write($entry, true,true,true,$skip_notifications))
|
if($this->bo->write($entry, true,true,true,$skip_notifications))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user