[icinga-checkins] icinga.org: icinga-web/mhein/default: * Category -> Cronk match fix

git at icinga.org git at icinga.org
Thu Jan 20 10:24:43 CET 2011


Module: icinga-web
Branch: mhein/default
Commit: 7edc7208bd4a765332b79eea6a6e9edb2ec7288a
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=7edc7208bd4a765332b79eea6a6e9edb2ec7288a

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Jan 20 10:23:58 2011 +0100

* Category -> Cronk match fix

---

 .../models/Provider/CronksDataModel.class.php      |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/modules/Cronks/models/Provider/CronksDataModel.class.php b/app/modules/Cronks/models/Provider/CronksDataModel.class.php
index f9e7c0b..bb9a097 100755
--- a/app/modules/Cronks/models/Provider/CronksDataModel.class.php
+++ b/app/modules/Cronks/models/Provider/CronksDataModel.class.php
@@ -151,7 +151,7 @@ class Cronks_Provider_CronksDataModel extends CronksBaseModel {
 		foreach ($categories as $cid=>$category) {
 			$count = 0;
 			foreach ($cronks as $cronk) {
-				if (isset($cronk['categories']) && $cid && strpos(strtolower($cronk['categories']), strtolower($cid)) !== false) {
+				if (isset($cronk['categories']) && $this->matchCategoryString($cronk['categories'], $cid)) {
 					$count++;
 				}
 			}
@@ -560,7 +560,7 @@ class Cronks_Provider_CronksDataModel extends CronksBaseModel {
 			$tmp = array ();
 			
 			foreach ($cronks as $cronk) {
-				if (strpos(strtolower($cronk['categories']), strtolower($category_name)) !== false) {
+				if ($this->matchCategoryString($cronk['categories'], $category_name)) {
 					$tmp[] = $cronk;
 				}
 				
@@ -583,6 +583,11 @@ class Cronks_Provider_CronksDataModel extends CronksBaseModel {
 		
 		return $data;
 	}
+	
+	private function matchCategoryString($categories, $match) {
+		$match=preg_quote($match);
+		return preg_match('/(^|,)'. $match. '(,|$)/i', $categories);
+	}
 }
 
 ?>
\ No newline at end of file





More information about the icinga-checkins mailing list