[icinga-checkins] icinga.org: icinga-web/next: Removed NotificationCustomVariableExtender

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


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

Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Thu Apr 25 15:05:57 2013 +0200

Removed NotificationCustomVariableExtender

This is no longer required with the new CustomVariableExtender.

Migrated the credentials for the Notification View to the new logic.

refs #3715

---

 app/modules/Api/config/views/notifications.xml     |   10 +-
 ...tificationCustomVariableExtenderModel.class.php |   88 --------------------
 2 files changed, 5 insertions(+), 93 deletions(-)

diff --git a/app/modules/Api/config/views/notifications.xml b/app/modules/Api/config/views/notifications.xml
index ca62aef..dab05ed 100644
--- a/app/modules/Api/config/views/notifications.xml
+++ b/app/modules/Api/config/views/notifications.xml
@@ -97,16 +97,16 @@
                 </orwhere>
             </credential>
 
-            <credential name="IcingaHostCustomVariablePair" type="NotificationCustomVariable" affects="host">
+            <credential name="IcingaHostCustomVariablePair" type="CustomVariable" affects="host">
                 <parameter name="alias">o</parameter>
-
+                <parameter name="target">host</parameter>
             </credential>
-            <credential name="IcingaServiceCustomVariablePair" type="NotificationCustomVariable" affects="service">
+
+            <credential name="IcingaServiceCustomVariablePair" type="CustomVariable" affects="service">
                 <parameter name="alias">o</parameter>
+                <parameter name="target">service</parameter>
             </credential>
 
-
-
         </dql>
     </ae:configuration>
 </ae:configurations>
diff --git a/app/modules/Api/models/Views/Extender/NotificationCustomVariableExtenderModel.class.php b/app/modules/Api/models/Views/Extender/NotificationCustomVariableExtenderModel.class.php
deleted file mode 100644
index 506d6b0..0000000
--- a/app/modules/Api/models/Views/Extender/NotificationCustomVariableExtenderModel.class.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-// {{{ICINGA_LICENSE_CODE}}}
-// -----------------------------------------------------------------------------
-// This file is part of icinga-web.
-// 
-// Copyright (c) 2009-2013 Icinga Developer Team.
-// All rights reserved.
-// 
-// icinga-web is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-// 
-// icinga-web is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with icinga-web.  If not, see <http://www.gnu.org/licenses/>.
-// -----------------------------------------------------------------------------
-// {{{ICINGA_LICENSE_CODE}}}
-
-
-class Api_Views_Extender_NotificationCustomVariableExtenderModel extends IcingaBaseModel implements DQLViewExtender {
-    /**
-     *
-     * @var NsmUser
-     */
-    private $user;
-    private static $applied = false;
-    public function extend(IcingaDoctrine_Query $query,array $params) {
-        if(self::$applied)
-            return true;
-
-        $alias  = $params["alias"];
-        $this->user = $this->getContext()->getUser()->getNsmUser();
-       
-        $svc_targetVals = $this->user->
-                getTargetValues(IcingaIPrincipalConstants::TYPE_CUSTOMVAR_SERVICE, true)
-                ->toArray();
-
-        $host_targetVals = $this->user->
-                getTargetValues(IcingaIPrincipalConstants::TYPE_CUSTOMVAR_HOST, true)
-                ->toArray();
-        
-        if(empty($svc_targetVals) && empty($host_targetvals)) {
-            return true;
-        }
- 
-        $query->innerJoin("$alias.customvariables cv");
-        $cvPart_svc = $this->createWherePart(2,$svc_targetVals,$alias);
-        $cvPart_host = $this->createWherePart(1,$host_targetVals,$alias);
-
-
-        if($cvPart_svc != "" && $cvPart_host != "") {
-            $wherePart = "( $cvPart_svc OR $cvPart_host )";
-        }
-
-        $query->orWhere($wherePart);
-        self::$applied = true;
-    }
-
-    private function createWherePart($objecttype, array $targetVals,$alias) {
-
-        $keymap = array(
-            "cv_name" => "varname",
-            "cv_value" => "varvalue"
-        );
-
-        $chain = false;
-        $cvPart = "";
-        foreach($targetVals as $cvKeyValuePair) {
-            if(!$chain) {
-                $cvPart .= "( $alias.objecttype_id = $objecttype AND (";
-            } else {
-                $cvPart .= " AND ";
-            }
-            $cvPart .= "cv.".$keymap[$cvKeyValuePair["tv_key"]]." =
-                '".$cvKeyValuePair["tv_val"]."'";
-            $chain = true;
-        }
-        if(!empty($targetVals)) {
-            $cvPart .= "))";
-        }
-        return $cvPart;
-    }
-}





More information about the icinga-checkins mailing list