/** * Constructor * * @return void */ public function __construct($db) { parent::__construct($db); $this->params['contact_register'] = 0; $this->register = 0; $this->action = "CONTACTTPL"; }
/** * Set parameters * * @param string $parameters * @throws CentreonClapiException */ public function setparam($parameters) { if (!isset($parameters)) { throw new CentreonClapiException(self::MISSINGPARAMETER); } $params = explode($this->delim, $parameters); if (count($params) < self::NB_UPDATE_PARAMS) { throw new CentreonClapiException(self::MISSINGPARAMETER); } $arId = $this->getLdapId($params[0]); if (is_null($arId)) { throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[0]); } if (in_array(strtolower($params[1]), array('name', 'description', 'enable'))) { if (strtolower($params[1]) == 'name') { if (!$this->isUnique($params[2], $arId)) { throw new CentreonClapiException(self::NAMEALREADYINUSE . ' (' . $name . ')'); } } $this->db->query("UPDATE auth_ressource SET ar_" . $params[1] . " = ? WHERE ar_id = ?", array($params[2], $arId)); } elseif (isset($this->baseParams[strtolower($params[1])])) { if (strtolower($params[1]) == 'ldap_contact_tmpl') { $contactObj = new CentreonContact($this->db); $params[2] = $contactObj->getContactID($params[2]); } $this->db->query("DELETE FROM auth_ressource_info WHERE ari_name = ? AND ar_id = ?", array($params[1], $arId)); $this->db->query("INSERT INTO auth_ressource_info (ari_value, ari_name, ar_id)\n VALUES (?, ?, ?)", array($params[2], $params[1], $arId)); } else { throw new CentreonClapiException(self::UNKNOWNPARAMETER); } }