diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index dc7b2ff977..0d17e0034c 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -72,7 +72,21 @@ { $extra = ''; $extra .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':''); - $extra .= ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":''); + //$extra .= ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":''); + if ($this->cat_id) + { + if (!is_object($GLOBALS['phpgw']->categories)) + { + $GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories'); + } + $cats = $GLOBALS['phpgw']->categories->return_all_children($this->cat_id); + $extra .= "AND (phpgw_cal.category".(count($cats) > 1 ? ' IN ('.implode(',',$cats).')' : '='.(int)$this->cat_id); + foreach($cats as $cat) + { + $extra .= " OR phpgw_cal.category LIKE '$cat,%' OR phpgw_cal.category LIKE '%,$cat,%' OR phpgw_cal.category LIKE '%,$cat'"; + } + $extra .= ') '; + } if($owner_id) { return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$GLOBALS['phpgw']->datetime->tz_offset,$owner_id); diff --git a/infolog/inc/class.soinfolog.inc.php b/infolog/inc/class.soinfolog.inc.php index dddd95123a..6f94c07579 100644 --- a/infolog/inc/class.soinfolog.inc.php +++ b/infolog/inc/class.soinfolog.inc.php @@ -518,9 +518,15 @@ } //echo "

filtermethod='$filtermethod'

"; - if (intval($query['cat_id'])) + if ((int)$query['cat_id']) { - $filtermethod .= ' AND info_cat='.intval($query['cat_id']).' '; + //$filtermethod .= ' AND info_cat='.intval($query['cat_id']).' '; + if (!is_object($GLOBALS['phpgw']->categories)) + { + $GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories'); + } + $cats = $GLOBALS['phpgw']->categories->return_all_children((int)$query['cat_id']); + $filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']); } $join = ''; if ($query['query']) $query['search'] = $query['query']; // allow both names diff --git a/phpgwapi/inc/class.contacts_sql.inc.php b/phpgwapi/inc/class.contacts_sql.inc.php index 868891dca8..2b9b804d70 100644 --- a/phpgwapi/inc/class.contacts_sql.inc.php +++ b/phpgwapi/inc/class.contacts_sql.inc.php @@ -348,7 +348,21 @@ { if($name == 'cat_id') { - $filterlist[] = "(" . $name . " LIKE '%," . (int)$value . ",%' OR " . $name."='".(int)$value."')"; + if (!(int)$value) continue; // nothing to filter + + //$filterlist[] = "(" . $name . " LIKE '%," . (int)$value . ",%' OR " . $name."='".(int)$value."')"; + if (!is_object($GLOBALS['phpgw']->categories)) + { + $GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories'); + } + $cats = $GLOBALS['phpgw']->categories->return_all_children((int)$value); + $cat_filter = '(cat_id IN ('.implode(',',$cats).')'; + foreach($cats as $cat) + { + $cat_filter .= " OR cat_id LIKE '%,$cat,%'"; + } + $cat_filter .= ')'; + $filterlist[] = $cat_filter; } elseif(@is_int($value)) {