[icinga-checkins] icinga.org: icinga-web/next: Redesign CustomVariableExtender for new credential system

git at icinga.org git at icinga.org
Fri Apr 26 11:58:04 CEST 2013


Module: icinga-web
Branch: next
Commit: 4e7c0f7bf48eb5a2a42e669bc7054ee558a458b1
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=4e7c0f7bf48eb5a2a42e669bc7054ee558a458b1

Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Fri Apr 26 11:54:15 2013 +0200

Redesign CustomVariableExtender for new credential system

The WHERE statements are now aggregated correctly to match
the key/values exactly.

fixes #3578
refs #3715

---

 ...DataHostCustomVariablePrincipalTarget.class.php |   18 +++++++++++++++++-
 ...aServiceCustomVariablePrincipalTarget.class.php |   17 ++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/app/modules/Web/lib/principal/IcingaDataHostCustomVariablePrincipalTarget.class.php b/app/modules/Web/lib/principal/IcingaDataHostCustomVariablePrincipalTarget.class.php
index e969cf5..7cd6aa4 100644
--- a/app/modules/Web/lib/principal/IcingaDataHostCustomVariablePrincipalTarget.class.php
+++ b/app/modules/Web/lib/principal/IcingaDataHostCustomVariablePrincipalTarget.class.php
@@ -45,6 +45,22 @@ class IcingaDataHostCustomVariablePrincipalTarget extends IcingaDataPrincipalTar
         $this->setDescription('Limit data access to customvariables');
     }
 
+    public function getMapArray(array $arr) {
+        $p = array();
+        foreach($arr as $set) {
+            if(isset($set["cv_name"]) and isset($set["cv_value"])) {
+                $p[] = "(".
+                    sprintf('${%s} LIKE \'%s\'', $this->getApiMappingField("cv_name"), $set["cv_name"]).
+                    " AND ".
+                    sprintf('${%s} LIKE \'%s\'', $this->getApiMappingField("cv_value"), $set["cv_value"]).
+                ")";
+            }
+        }
+
+        return '('. join(' OR ', $p). ')';
+    }
+
+
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/app/modules/Web/lib/principal/IcingaDataServiceCustomVariablePrincipalTarget.class.php b/app/modules/Web/lib/principal/IcingaDataServiceCustomVariablePrincipalTarget.class.php
index b1d8a80..8032eff 100644
--- a/app/modules/Web/lib/principal/IcingaDataServiceCustomVariablePrincipalTarget.class.php
+++ b/app/modules/Web/lib/principal/IcingaDataServiceCustomVariablePrincipalTarget.class.php
@@ -45,6 +45,21 @@ class IcingaDataServiceCustomVariablePrincipalTarget extends IcingaDataPrincipal
         $this->setDescription('Limit data access to customvariables');
     }
 
+    public function getMapArray(array $arr) {
+        $p = array();
+        foreach($arr as $set) {
+            if(isset($set["cv_name"]) and isset($set["cv_value"])) {
+                $p[] = "(".
+                    sprintf('${%s} LIKE \'%s\'', $this->getApiMappingField("cv_name"), $set["cv_name"]).
+                    " AND ".
+                    sprintf('${%s} LIKE \'%s\'', $this->getApiMappingField("cv_value"), $set["cv_value"]).
+                ")";
+            }
+        }
+
+        return '('. join(' OR ', $p). ')';
+    }
+
 }
 
-?>
\ No newline at end of file
+?>





More information about the icinga-checkins mailing list