From be8b2f0bc949862cc8cb54e095ed3b1e69f285fb Mon Sep 17 00:00:00 2001
From: loiclau <loic.lau@gmail.com>
Date: Mon, 5 Mar 2018 11:30:05 +0100
Subject: [PATCH] fix(clapi) export selected service, add host before service
 (#6100)

---
 .../centreon-clapi/centreonService.class.php  | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/www/class/centreon-clapi/centreonService.class.php b/www/class/centreon-clapi/centreonService.class.php
index a9ea9fa2a4..534e531bd6 100644
--- a/www/class/centreon-clapi/centreonService.class.php
+++ b/www/class/centreon-clapi/centreonService.class.php
@@ -1099,6 +1099,10 @@ class CentreonService extends CentreonObject
                 }
                 $addStr .= $element[$param];
             }
+
+            # Host Filter
+            $this->api->export_filter('HOST', $element['host_id'], $element['host_name']);
+
             $addStr .= "\n";
             echo $addStr;
             foreach ($element as $parameter => $value) {
@@ -1121,8 +1125,7 @@ class CentreonService extends CentreonObject
                         unset($tmpObj);
                     }
                     $value = CentreonUtils::convertLineBreak($value);
-                    # Host Filter
-                    $this->api->export_filter('HOST', $element['host_id'], $element['host_name']);
+
                     if ($this->getClapiActionName($parameter) != "host_id") {
                         echo $this->action . $this->delim . "setparam" . $this->delim
                             . $element['host_name'] . $this->delim
@@ -1237,14 +1240,13 @@ class CentreonService extends CentreonObject
         }
     }
 
-
     /**
-     *
-     * @param type $pearDB
-     * @param integer $service_id
-     * @param string $macroInput
-     * @param string $macroValue
-     * @param boolean $cmdId
+     * @param $pearDB
+     * @param $service_id
+     * @param $macroInput
+     * @param $macroValue
+     * @param bool $cmdId
+     * @return bool
      */
     public function hasMacroFromServiceChanged($pearDB, $service_id, &$macroInput, &$macroValue, $cmdId = false)
     {
-- 
GitLab