/**
  * Display all service templates
  *
  * @param string $parameters
  * @return void
  */
 public function show($parameters = null)
 {
     $filters = array('service_register' => $this->register);
     if (isset($parameters)) {
         $filters["service_description"] = "%" . $parameters . "%";
     }
     $commandObject = new Centreon_Object_Command();
     $paramsSvc = array('service_id', 'service_description', 'service_alias', 'command_command_id', 'command_command_id_arg', 'service_normal_check_interval', 'service_retry_check_interval', 'service_max_check_attempts', 'service_active_checks_enabled', 'service_passive_checks_enabled');
     $elements = $this->object->getList($paramsSvc, -1, 0, null, null, $filters, "AND");
     $paramSvcString = str_replace("service_", "", implode($this->delim, $paramsSvc));
     $paramSvcString = str_replace("command_command_id", "check command", $paramSvcString);
     $paramSvcString = str_replace("command_command_id_arg", "check command arguments", $paramSvcString);
     $paramSvcString = str_replace("_", " ", $paramSvcString);
     echo $paramSvcString . "\n";
     foreach ($elements as $tab) {
         if (isset($tab['command_command_id']) && $tab['command_command_id']) {
             $tmp = $commandObject->getParameters($tab['command_command_id'], array($commandObject->getUniqueLabelField()));
             if (isset($tmp[$commandObject->getUniqueLabelField()])) {
                 $tab['command_command_id'] = $tmp[$commandObject->getUniqueLabelField()];
             }
         }
         echo implode($this->delim, $tab) . "\n";
     }
 }
 /**
  * Export notification commands
  *
  * @param string $objType
  * @param int $contactId
  * @param string $contactName
  * @return void
  */
 private function exportNotifCommands($objType, $contactId, $contactName)
 {
     $commandObj = new Centreon_Object_Command();
     if ($objType == self::HOST_NOTIF_CMD) {
         $obj = new Centreon_Object_Relation_Contact_Command_Host();
     } else {
         $obj = new Centreon_Object_Relation_Contact_Command_Service();
     }
     $cmds = $obj->getMergedParameters(array(), array($commandObj->getUniqueLabelField()), -1, 0, null, null, array($this->object->getPrimaryKey() => $contactId), "AND");
     $str = "";
     foreach ($cmds as $element) {
         if ($str != "") {
             $str .= "|";
         }
         $str .= $element[$commandObj->getUniqueLabelField()];
     }
     if ($str) {
         echo $this->action . $this->delim . "setparam" . $this->delim . $contactName . $this->delim . $objType . $this->delim . $str . "\n";
     }
 }
 /**
  * Set Parameters
  *
  * @param string $parameters
  * @return void
  * @throws Exception
  */
 public function setparam($parameters)
 {
     $params = explode($this->delim, $parameters);
     if (count($params) < self::NB_UPDATE_PARAMS) {
         throw new CentreonClapiException(self::MISSINGPARAMETER);
     }
     if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) {
         $commandColumns = array('global_host_event_handler', 'global_service_event_handler', 'host_perfdata_command', 'service_perfdata_command', 'host_perfdata_file_processing_command', 'service_perfdata_file_processing_command', 'ocsp_command', 'ochp_command');
         if ($params[1] == "instance" || $params[1] == "nagios_server_id") {
             $params[1] = "nagios_server_id";
             $params[2] = $this->instanceObj->getInstanceId($params[2]);
         } elseif ($params[1] == "broker_module") {
             $this->setBrokerModule($objectId, $params[2]);
         } elseif (preg_match('/(' . implode('|', $commandColumns) . ')/', $params[1], $matches)) {
             $commandName = $matches[1];
             if ($params[2]) {
                 $commandObj = new Centreon_Object_Command();
                 $res = $commandObj->getIdByParameter($commandObj->getUniqueLabelField(), $params[2]);
                 if (count($res)) {
                     $params[2] = $res[0];
                 } else {
                     throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
                 }
             } else {
                 $params[2] = NULL;
             }
         }
         if ($params[1] != "broker_module") {
             $p = strtolower($params[1]);
             if ($params[2] == "") {
                 if (isset($this->params[$p]) && $this->params[$p] == 2) {
                     $params[2] = $this->params[$p];
                 } else {
                     $params[2] = NULL;
                 }
             }
             $updateParams = array($params[1] => $params[2]);
             parent::setparam($objectId, $updateParams);
         }
     } else {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]);
     }
 }
 /**
  * Returns command id
  *
  * @param string $commandName
  * @return int
  * @throws CentreonClapiException
  */
 public function getId($commandName)
 {
     $obj = new Centreon_Object_Command();
     $tmp = $obj->getIdByParameter($obj->getUniqueLabelField(), $commandName);
     if (count($tmp)) {
         $id = $tmp[0];
     } else {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $commandName);
     }
     return $id;
 }