* Calendar: Added category filter for events without a category set

This commit is contained in:
nathan 2023-07-10 15:58:04 -06:00
parent 2c98cdde04
commit d0932e7cc0
2 changed files with 23 additions and 13 deletions

View File

@ -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 .= ') ';
}

View File

@ -13,15 +13,17 @@ Egroupware
<overlay>
<template id="calendar.sidebox">
<et2-vbox parentId="calendar-et2_target">
<et2-vbox parentId="calendar-et2_target">
<calendar-date id="date"></calendar-date>
<et2-textbox type="hidden" id="first"></et2-textbox>
<et2-textbox type="hidden" id="last"></et2-textbox>
<et2-textbox type="hidden" id="first"></et2-textbox>
<et2-textbox type="hidden" id="last"></et2-textbox>
<hrule/>
<et2-select-cat id="cat_id" placeholder="All categories" onchange="app.calendar.update_state({cat_id: widget.getValue()});" emptyLabel="All categories" multiple="true"></et2-select-cat>
<et2-select id="status_filter" onchange="app.calendar.update_state({status_filter: widget.getValue()});" noLang="true"></et2-select>
<et2-select-cat id="cat_id" placeholder="All categories" onchange="app.calendar.update_state({cat_id: widget.getValue()});" emptyLabel="All categories" multiple="true">
<option value="0">None</option>
</et2-select-cat>
<et2-select id="status_filter" onchange="app.calendar.update_state({status_filter: widget.getValue()});" noLang="true"></et2-select>
<hrule/>
<et2-calendar-owner id="owner" onchange="app.calendar.update_state({owner: widget.getValue()}); return false;" multiple="true" allowFreeEntries="false" autocompleteParams="{&quot;checkgrants&quot;: true}"/>
<et2-calendar-owner id="owner" onchange="app.calendar.update_state({owner: widget.getValue()}); return false;" multiple="true" allowFreeEntries="false" autocompleteParams="{&quot;checkgrants&quot;: true}"/>
<hrule/>
<et2-box>
<grid id="integration" disabled="!@integration" width="100%">