From d0932e7cc0bc81e3558f0cf4d2c74f78c3a3686d Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 10 Jul 2023 15:58:04 -0600 Subject: [PATCH] * Calendar: Added category filter for events without a category set --- calendar/inc/class.calendar_so.inc.php | 22 +++++++++++++++------- calendar/templates/default/sidebox.xet | 14 ++++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 349bb4b9aa..4f3b35e44b 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -623,19 +623,27 @@ class calendar_so function cat_filter($cat_id) { $sql = ''; - if ($cat_id) + // No category + if($cat_id === false || $cat_id && ($cat_id == ["0"] || !(int)$cat_id)) + { + $sql = 'cal_category=""'; + } + elseif($cat_id) { $cats = $GLOBALS['egw']->categories->return_all_children($cat_id); - array_walk($cats, function(&$val, $key) + array_walk($cats, function (&$val, $key) { - unset($key); // not used, but required by function signature - $val = (int) $val; + unset($key); // not used, but required by function signature + $val = (int)$val; }); - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; - $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); + if(is_array($cat_id) && count($cat_id) == 1) + { + $cat_id = $cat_id[0]; + } + $sql = '(cal_category' . (count($cats) > 1 ? " IN ('" . implode("','", $cats) . "')" : '=' . $this->db->quote((int)$cat_id)); foreach($cats as $cat) { - $sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%'); + $sql .= ' OR ' . $this->db->concat("','", 'cal_category', "','") . ' LIKE ' . $this->db->quote('%,' . $cat . ',%'); } $sql .= ') '; } diff --git a/calendar/templates/default/sidebox.xet b/calendar/templates/default/sidebox.xet index 2bf9330e46..10fbf073f9 100644 --- a/calendar/templates/default/sidebox.xet +++ b/calendar/templates/default/sidebox.xet @@ -13,15 +13,17 @@ Egroupware