[icinga-checkins] icinga.org: icinga-web/feature/datapermissions-wip: Updated views to allow a NULL value for certain split views

git at icinga.org git at icinga.org
Mon Feb 18 16:28:13 CET 2013


Module: icinga-web
Branch: feature/datapermissions-wip
Commit: 03e085489832fc48f3d1945253d69fc963f9795e
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=03e085489832fc48f3d1945253d69fc963f9795e

Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Mon Feb 18 16:14:50 2013 +0100

Updated views to allow a NULL value for certain split views

---

 app/modules/Api/config/views/host.xml              |   22 ++++++++-----------
 app/modules/Api/config/views/hostgroups.xml        |    2 +-
 app/modules/Api/config/views/misc.xml              |    4 +++
 app/modules/Api/config/views/notifications.xml     |    2 +
 .../Extender/MultiLikeExtenderModel.class.php      |    3 ++
 5 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/app/modules/Api/config/views/host.xml b/app/modules/Api/config/views/host.xml
index ff32542..94ecbdd 100644
--- a/app/modules/Api/config/views/host.xml
+++ b/app/modules/Api/config/views/host.xml
@@ -252,20 +252,16 @@
             ]]>
             </query>
 
-            <credential name="IcingaHost" type="dql">
-                <andwhere>
-                    <![CDATA[
-                        oh.name1 LIKE ${credential_value}
-                    ]]>
-                </andwhere>
+            <credential name="IcingaHost" type="MultiLike">
+                <parameter name="target">IcingaHost</parameter>
+                <parameter name="column">o.name1</parameter>
             </credential>
 
-            <credential name="IcingaService" type="dql">
-                <andwhere>
-                    <![CDATA[
-                        os.name2 LIKE ${credential_value}
-                    ]]>
-                </andwhere>
+            <credential name="IcingaService" type="MultiLike">
+                <parameter name="target">IcingaService</parameter>
+                <parameter name="column">o.name2</parameter>
+                <!-- In mixed views we allow the service to be null => its a host -->
+                <parameter name="ornull">true</parameter>
             </credential>
 
             <credential name="IcingaServiceGroup" type="dql">
@@ -280,7 +276,7 @@
                     ]]>
                 </andwhere>
             </credential>
--
+
             <credential name="IcingaHostgroup" type="dql">
                 <leftjoin>h.hostgroups hg</leftjoin>
                 
diff --git a/app/modules/Api/config/views/hostgroups.xml b/app/modules/Api/config/views/hostgroups.xml
index b9ff657..bc7331d 100644
--- a/app/modules/Api/config/views/hostgroups.xml
+++ b/app/modules/Api/config/views/hostgroups.xml
@@ -36,7 +36,7 @@
 
             <credential name="IcingaHost" type="MultiLike">
                 <parameter name="target">IcingaHost</parameter>
-                <parameter name="column">oh.name1</parameter>
+                <parameter name="column">h.display_name</parameter>
             </credential>
 
             <credential name="IcingaHostgroup" type="dql">
diff --git a/app/modules/Api/config/views/misc.xml b/app/modules/Api/config/views/misc.xml
index b447dd5..65d274d 100644
--- a/app/modules/Api/config/views/misc.xml
+++ b/app/modules/Api/config/views/misc.xml
@@ -78,6 +78,8 @@
             <credential name="IcingaService" type="MultiLike">
                 <parameter name="target">IcingaService</parameter>
                 <parameter name="column">o.name2</parameter>
+                <!-- In mixed views we allow the service to be null => its a host -->
+                <parameter name="ornull">true</parameter>
             </credential>
 
             <credential name="IcingaServiceGroup" type="dql">
@@ -207,6 +209,8 @@
             <credential name="IcingaService" type="MultiLike">
                 <parameter name="target">IcingaService</parameter>
                 <parameter name="column">o.name2</parameter>
+                <!-- In mixed views we allow the service to be null => its a host -->
+                <parameter name="ornull">true</parameter>
             </credential>
 
             <credential name="IcingaServiceGroup" type="dql">
diff --git a/app/modules/Api/config/views/notifications.xml b/app/modules/Api/config/views/notifications.xml
index 75bc0f1..9f95516 100644
--- a/app/modules/Api/config/views/notifications.xml
+++ b/app/modules/Api/config/views/notifications.xml
@@ -35,6 +35,8 @@
             <credential name="IcingaService" type="MultiLike">
                 <parameter name="target">IcingaService</parameter>
                 <parameter name="column">o.name2</parameter>
+                <!-- In mixed views we allow the service to be null => its a host -->
+                <parameter name="ornull">true</parameter>
             </credential>
 
             <credential name="IcingaContactgroup" type="dql">
diff --git a/app/modules/Api/models/Views/Extender/MultiLikeExtenderModel.class.php b/app/modules/Api/models/Views/Extender/MultiLikeExtenderModel.class.php
index 2ec6291..8a6355a 100644
--- a/app/modules/Api/models/Views/Extender/MultiLikeExtenderModel.class.php
+++ b/app/modules/Api/models/Views/Extender/MultiLikeExtenderModel.class.php
@@ -30,6 +30,7 @@ class Api_Views_Extender_MultiLikeExtenderModel extends IcingaBaseModel
     {
         $target = $params["target"]; 
         $column = $params["column"]; 
+        $ornull = ( (isset($params["ornull"]) && $params["ornull"] == true) ? true : false );
         $user = $this->getContext()->getUser()->getNsmUser();
         $targetVals = $user->getTargetValues($target,true)->toArray();
         if(empty($targetVals))
@@ -39,6 +40,8 @@ class Api_Views_Extender_MultiLikeExtenderModel extends IcingaBaseModel
         foreach($targetVals as $currentTarget) {
             $dqlParts[] = "$column LIKE '".$currentTarget["tv_val"]."'";
         }
+        if ($ornull == true)
+            $dqlParts[] = "$column IS NULL";
         $dql = "(".implode(" OR ", $dqlParts).")";
         $query->andWhere($dql);
     }





More information about the icinga-checkins mailing list