/** * Delete custom macro * * @param string $parameters * @return void * @throws CentreonClapiException */ public function delmacro($parameters) { $params = explode($this->delim, $parameters); if (count($params) < 2) { throw new CentreonClapiException(self::MISSINGPARAMETER); } $elements = $this->object->getList("service_id", -1, 0, null, null, array('service_description' => $params[0], 'service_register' => 0), "AND"); if (!count($elements)) { throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[0]); } $macroObj = new Centreon_Object_Service_Macro_Custom(); $macroList = $macroObj->getList($macroObj->getPrimaryKey(), -1, 0, null, null, array("svc_svc_id" => $elements[0]['service_id'], "svc_macro_name" => $this->wrapMacro($params[1])), "AND"); if (count($macroList)) { $macroObj->delete($macroList[0][$macroObj->getPrimaryKey()]); } }
/** * Delete custom macro * * @param string $parameters * @return void * @throws CentreonClapiException */ public function delmacro($parameters) { $params = explode($this->delim, $parameters); if (count($params) < 3) { throw new CentreonClapiException(self::MISSINGPARAMETER); } $hostName = $params[0]; $serviceDescription = $params[1]; $relObject = new Centreon_Object_Relation_Host_Service(); $elements = $relObject->getMergedParameters(array('host_id'), array('service_id'), -1, 0, null, null, array("host_name" => $hostName, "service_description" => $serviceDescription), "AND"); if (!count($elements)) { throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $hostName . "/" . $serviceDescription); } $macroObj = new Centreon_Object_Service_Macro_Custom(); $macroList = $macroObj->getList($macroObj->getPrimaryKey(), -1, 0, null, null, array("svc_svc_id" => $elements[0]['service_id'], "svc_macro_name" => $this->wrapMacro($params[2])), "AND"); if (count($macroList)) { $macroObj->delete($macroList[0][$macroObj->getPrimaryKey()]); } $this->addAuditLog('c', $elements[0]['service_id'], $hostName . ' - ' . $serviceDescription, array($params[2] => '')); }