/**
  * Set parameters
  *
  * @param string $parameters
  * @return void
  * @throws CentreonClapiException
  */
 public function setparam($parameters)
 {
     $params = explode($this->delim, $parameters);
     if (count($params) < self::NB_UPDATE_PARAMS) {
         throw new CentreonClapiException(self::MISSINGPARAMETER);
     }
     $params[self::ORDER_NAME] = str_replace(" ", "_", $params[self::ORDER_NAME]);
     if (($objectId = $this->getObjectId($params[self::ORDER_NAME])) != 0) {
         $regularParam = true;
         if ($params[1] == self::HOST_NOTIF_TP) {
             $params[1] = "timeperiod_tp_id";
             $params[2] = $this->tpObject->getTimeperiodId($params[2]);
         } elseif ($params[1] == self::SVC_NOTIF_TP) {
             $params[1] = "timeperiod_tp_id2";
             $params[2] = $this->tpObject->getTimeperiodId($params[2]);
         } elseif ($params[1] == self::HOST_NOTIF_CMD || $params[1] == self::SVC_NOTIF_CMD) {
             $this->setNotificationCmd($params[1], $objectId, $params[2]);
             $regularParam = false;
         } elseif (!preg_match("/^contact_/", $params[1])) {
             if ($params[1] == "access") {
                 $params[1] = "oreon";
             } elseif ($params[1] == "template") {
                 $params[1] = "template_id";
                 $contactId = $this->getContactID($params[2]);
                 if (!isset($contactId) || !$contactId) {
                     throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
                 }
                 $params[2] = $contactId;
             } elseif ($params[1] == "authtype") {
                 $params[1] = "auth_type";
             } elseif ($params[1] == "lang" || $params[1] == "language" || $params[1] == "locale") {
                 if ($this->checkLang($params[2]) == false) {
                     throw new CentreonClapiException(self::UNKNOWN_LOCALE);
                 }
                 $params[1] = "lang";
             } elseif ($params[1] == "password") {
                 $params[1] = "passwd";
                 $params[2] = md5(trim($params[2]));
             } elseif ($params[1] == "hostnotifopt") {
                 $params[1] = "host_notification_options";
             } elseif ($params[1] == "servicenotifopt") {
                 $params[1] = "service_notification_options";
             }
             $params[1] = "contact_" . $params[1];
         }
         if ($regularParam == true) {
             $updateParams = array($params[1] => $params[2]);
             parent::setparam($objectId, $updateParams);
         }
     } else {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]);
     }
 }
 /**
  * Set parameters
  *
  * @param string $parameters
  * @return void
  * @throws CentreonClapiException
  */
 public function setparam($parameters = null)
 {
     $params = explode($this->delim, $parameters);
     if (count($params) < self::NB_UPDATE_PARAMS) {
         throw new CentreonClapiException(self::MISSINGPARAMETER);
     }
     $serviceDesc = $params[0];
     $elements = $this->object->getList("service_id", -1, 0, null, null, array('service_description' => $serviceDesc, 'service_register' => 0), "AND");
     if (!count($elements)) {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $serviceDesc);
     }
     $objectId = $elements[0]['service_id'];
     $extended = false;
     $commandObject = new CentreonCommand();
     switch ($params[1]) {
         case "check_command":
             $params[1] = "command_command_id";
             $params[2] = $commandObject->getId($params[2]);
             break;
         case "check_command_arguments":
             $params[1] = "command_command_id_arg";
             break;
         case "event_handler":
             $params[1] = "command_command_id2";
             $params[2] = $commandObject->getId($params[2]);
             break;
         case "event_handler_arguments":
             $params[1] = "command_command_id_arg2";
             break;
         case "check_period":
             $params[1] = "timeperiod_tp_id";
             $tpObj = new CentreonTimePeriod();
             $params[2] = $tpObj->getTimeperiodId($params[2]);
             break;
         case "notification_period":
             $params[1] = "timeperiod_tp_id2";
             $tpObj = new CentreonTimePeriod();
             $params[2] = $tpObj->getTimeperiodId($params[2]);
             break;
         case "flap_detection_options":
             break;
         case "template":
             $params[1] = "service_template_model_stm_id";
             $tmp = $this->object->getList($this->object->getPrimaryKey(), -1, 0, null, null, array('service_description' => $params[2], 'service_register' => '0'), "AND");
             if (!count($tmp)) {
                 throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
             }
             $params[2] = $tmp[0][$this->object->getPrimaryKey()];
             break;
         case "graphtemplate":
             $extended = true;
             $graphObj = new Centreon_Object_Graph_Template();
             $tmp = $graphObj->getIdByParameter($graphObj->getUniqueLabelField(), $params[2]);
             if (!count($tmp)) {
                 throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
             }
             $params[1] = "graph_id";
             $params[2] = $tmp[0];
             break;
         case "contact_additive_inheritance":
             break;
         case "cg_additive_inheritance":
             break;
         case "notes":
             $extended = true;
             break;
         case "notes_url":
             $extended = true;
             break;
         case "action_url":
             $extended = true;
             break;
         case "icon_image":
             $extended = true;
             break;
         case "icon_image_alt":
             $extended = true;
             break;
         default:
             if (!preg_match("/^service_/", $params[1])) {
                 $params[1] = "service_" . $params[1];
             }
             break;
     }
     if ($extended == false) {
         $updateParams = array($params[1] => $params[2]);
         parent::setparam($objectId, $updateParams);
     } else {
         if ($params[1] != "graph_id") {
             $params[1] = "esi_" . $params[1];
             if ($params[1] == "esi_icon_image") {
                 if ($params[2]) {
                     $id = CentreonUtils::getImageId($params[2]);
                     if (is_null($id)) {
                         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
                     }
                     $params[2] = $id;
                 } else {
                     $params[2] = null;
                 }
             }
         }
         $extended = new Centreon_Object_Service_Extended();
         $extended->update($objectId, array($params[1] => $params[2]));
     }
 }
 /**
  * Set parameters
  *
  * @param string $parameters
  * @return void
  * @throws CentreonClapiException
  */
 public function setparam($parameters = null)
 {
     $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) {
         $extended = false;
         $commandObject = new CentreonCommand();
         switch ($params[1]) {
             case "check_command":
                 $params[1] = "command_command_id";
                 $params[2] = $commandObject->getId($params[2]);
                 break;
             case "check_command_arguments":
                 $params[1] = "command_command_id_arg1";
                 break;
             case "event_handler":
                 $params[1] = "command_command_id2";
                 $params[2] = $commandObject->getId($params[2]);
                 break;
             case "event_handler_arguments":
                 $params[1] = "command_command_id_arg2";
                 break;
             case "check_period":
                 $params[1] = "timeperiod_tp_id";
                 $tpObj = new CentreonTimePeriod();
                 $params[2] = $tpObj->getTimeperiodId($params[2]);
                 break;
             case "notification_period":
                 $params[1] = "timeperiod_tp_id2";
                 $tpObj = new CentreonTimePeriod();
                 $params[2] = $tpObj->getTimeperiodId($params[2]);
                 break;
             case "contact_additive_inheritance":
                 break;
             case "cg_additive_inheritance":
                 break;
             case "flap_detection_options":
                 break;
             case "notes":
                 $extended = true;
                 break;
             case "notes_url":
                 $extended = true;
                 break;
             case "action_url":
                 $extended = true;
                 break;
             case "icon_image":
                 $extended = true;
                 break;
             case "icon_image_alt":
                 $extended = true;
                 break;
             case "vrml_image":
                 $extended = true;
                 break;
             case "statusmap_image":
                 $extended = true;
                 break;
             case "2d_coords":
                 $extended = true;
                 break;
             case "3d_coords":
                 $extended = true;
                 break;
             default:
                 if (!preg_match("/^host_/", $params[1])) {
                     $params[1] = "host_" . $params[1];
                 }
                 break;
         }
         if ($extended == false) {
             $updateParams = array($params[1] => $params[2]);
             parent::setparam($objectId, $updateParams);
         } else {
             $params[1] = "ehi_" . $params[1];
             if ($params[1] == "ehi_icon_image" || $params[1] == "ehi_statusmap_image" || $params[1] == "ehi_vrml_image") {
                 if ($params[2]) {
                     $id = CentreonUtils::getImageId($params[2]);
                     if (is_null($id)) {
                         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
                     }
                     $params[2] = $id;
                 } else {
                     $params[2] = null;
                 }
             }
             $extended = new Centreon_Object_Host_Extended();
             $extended->update($objectId, array($params[1] => $params[2]));
         }
     } else {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]);
     }
 }
 /**
  * Set parameters
  *
  * @param string $parameters
  * @return void
  * @throws CentreonClapiException
  */
 public function setparam($parameters = null)
 {
     $params = explode($this->delim, $parameters);
     if (count($params) < self::NB_UPDATE_PARAMS) {
         throw new CentreonClapiException(self::MISSINGPARAMETER);
     }
     $hostName = $params[0];
     $serviceDesc = $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" => $serviceDesc), "AND");
     if (!count($elements)) {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $hostName . "/" . $serviceDesc);
     }
     $objectId = $elements[0]['service_id'];
     $extended = false;
     $commandObject = new CentreonCommand();
     switch ($params[2]) {
         case "check_command":
             $params[2] = "command_command_id";
             $params[3] = $commandObject->getId($params[3]);
             break;
         case "check_command_arguments":
             $params[2] = "command_command_id_arg";
             break;
         case "event_handler":
             $params[2] = "command_command_id2";
             $params[3] = $commandObject->getId($params[3]);
             break;
         case "event_handler_arguments":
             $params[2] = "command_command_id_arg2";
             break;
         case "check_period":
             $params[2] = "timeperiod_tp_id";
             $tpObj = new CentreonTimePeriod();
             $params[3] = $tpObj->getTimeperiodId($params[3]);
             break;
         case "notification_period":
             $params[2] = "timeperiod_tp_id2";
             $tpObj = new CentreonTimePeriod();
             $params[3] = $tpObj->getTimeperiodId($params[3]);
             break;
         case "flap_detection_options":
             break;
         case "template":
             $params[2] = "service_template_model_stm_id";
             $tmp = $this->object->getList($this->object->getPrimaryKey(), -1, 0, null, null, array('service_description' => $params[3], 'service_register' => '0'), "AND");
             if (!count($tmp)) {
                 throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[3]);
             }
             $params[3] = $tmp[0][$this->object->getPrimaryKey()];
             break;
         case "graphtemplate":
             $extended = true;
             $graphObj = new Centreon_Object_Graph_Template();
             $tmp = $graphObj->getIdByParameter($graphObj->getUniqueLabelField(), $params[3]);
             if (!count($tmp)) {
                 throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[3]);
             }
             $params[2] = "graph_id";
             $params[3] = $tmp[0];
             break;
         case "contact_additive_inheritance":
             break;
         case "cg_additive_inheritance":
             break;
         case "notes":
             $extended = true;
             break;
         case "notes_url":
             $extended = true;
             break;
         case "action_url":
             $extended = true;
             break;
         case "icon_image":
             $extended = true;
             break;
         case "icon_image_alt":
             $extended = true;
             break;
         case "service_notification_options":
             $aNotifs = explode(",", $params[3]);
             foreach ($aNotifs as $notif) {
                 if (!array_key_exists($notif, self::$aAuthorizedNotificationsOptions)) {
                     throw new CentreonClapiException(self::UNKNOWN_NOTIFICATION_OPTIONS);
                 }
             }
             break;
         default:
             if (!preg_match("/^service_/", $params[2])) {
                 $params[2] = "service_" . $params[2];
             }
             break;
     }
     if ($extended == false) {
         $updateParams = array($params[2] => $params[3]);
         if ($params[2] == 'service_description' && $this->serviceExists($hostName, $params[3])) {
             throw new CentreonClapiException(self::OBJECTALREADYEXISTS);
         }
         $this->object->update($objectId, $updateParams);
         $this->addAuditLog('c', $objectId, $hostName . ' - ' . $serviceDesc, $updateParams);
     } else {
         if ($params[2] != "graph_id") {
             $params[2] = "esi_" . $params[2];
             if ($params[2] == "esi_icon_image") {
                 if ($params[3]) {
                     $id = CentreonUtils::getImageId($params[3]);
                     if (is_null($id)) {
                         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[3]);
                     }
                     $params[3] = $id;
                 } else {
                     $params[3] = null;
                 }
             }
         }
         $extended = new Centreon_Object_Service_Extended();
         $extended->update($objectId, array($params[2] => $params[3]));
         $this->addAuditLog('c', $objectId, $hostName . ' - ' . $serviceDesc, array($params[2] => $params[3]));
     }
 }