From ae6d2769cfd15e7ea37aef4b76a3ef735c82b935 Mon Sep 17 00:00:00 2001 From: leoncx <leoncx@gmail.com> Date: Tue, 17 Apr 2018 14:45:36 +0200 Subject: [PATCH] fix(clapi): Fix the apply template on a host by CLAPI (#6212) * Fix audit log for deploy services templates on a host by CLAPI --- www/class/centreon-clapi/centreonHost.class.php | 8 ++++---- www/class/centreon-clapi/centreonObject.class.php | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index 372b8fe41f..01e7b0314c 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -906,16 +906,16 @@ class CentreonHost extends CentreonObject $serviceDesc = array('service_description' => $params['service_alias'], 'service_activate' => '1', 'service_register' => '1', - 'service_template_model_stm_id' => $serviceTemplateId, - 'service_hPars' => $hostId); + 'service_template_model_stm_id' => $serviceTemplateId); $svcId = $svcObj->insert($serviceDesc); $hostSvcRel->insert($hostId, $svcId); - $this->params = array_merge($this->params, $serviceDesc); + $serviceDesc['service_hPars'] = $hostId; $this->addAuditLog( 'a', $svcId, $params['service_alias'], - $this->params + $serviceDesc, + 'SERVICE' ); $svcExtended->insert(array($svcExtended->getUniqueLabelField() => $svcId)); } diff --git a/www/class/centreon-clapi/centreonObject.class.php b/www/class/centreon-clapi/centreonObject.class.php index 47ccfad329..2cf2d845e0 100644 --- a/www/class/centreon-clapi/centreonObject.class.php +++ b/www/class/centreon-clapi/centreonObject.class.php @@ -443,10 +443,11 @@ abstract class CentreonObject * @param int $objId * @param string $objName * @param array $objValues + * @param string|null $objectType - The object type to log if is null use the object type of the class */ - public function addAuditLog($actionType, $objId, $objName, $objValues = array()) + public function addAuditLog($actionType, $objId, $objName, $objValues = array(), $objectType = null) { - $objType = strtoupper($this->action); + $objType = is_null($objectType) ? strtoupper($this->action) : $objectType; $objectTypes = array( 'HTPL' => 'host', 'STPL' => 'service', -- GitLab