From da7db2180642d29d4ec5ba940280594ef0dc6ae6 Mon Sep 17 00:00:00 2001 From: Christian Binder Date: Mon, 16 Nov 2009 06:54:03 +0000 Subject: [PATCH] also match against trimmed database entries when categories should be searched by $filter --- phpgwapi/inc/class.categories.inc.php | 30 ++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php index 8cd0a44456..7b6dcbcbd4 100644 --- a/phpgwapi/inc/class.categories.inc.php +++ b/phpgwapi/inc/class.categories.inc.php @@ -156,15 +156,39 @@ class categories { if (!is_array($val) && $val[0] === '!') { - if ($cat[$col] == substr($val,1)) continue 2; // 2 for BOTH foreach! + // also match against trimmed database entry on name and description fields + if (($col == 'name' || $col == 'description') && is_string($cat[$col])) + { + if ($cat[$col] == substr($val,1) || trim($cat[$col]) == substr($val,1)) continue 2; + } + else + { + if ($cat[$col] == substr($val,1)) continue 2; + } } elseif (is_array($val)) { - if (!in_array($cat[$col],$val)) continue 2; + // also match against trimmed database entry on name and description fields + if (($col == 'name' || $col == 'description') && is_string($cat[$col])) + { + if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) continue 2; + } + else + { + if (!in_array($cat[$col],$val)) continue 2; + } } else { - if ($cat[$col] != $val) continue 2; + // also match against trimmed database entry on name and description fields + if (($col == 'name' || $col == 'description') && is_string($cat[$col])) + { + if ($cat[$col] != $val && trim($cat[$col]) != $val) continue 2; + } + else + { + if ($cat[$col] != $val) continue 2; + } } } // check if certain parent required