Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
* new clapi query set param img
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclau committed Jul 25, 2017
1 parent 44059e8 commit 4b645e7
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions www/class/centreon-clapi/centreonHostGroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,57 @@ public function del($objectName)
/**
* Set params
*
* @param string $parameters
* @return void
* @throws CenrtreonClapiException
* @param null $parameters
* @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) {
if (($params[1] == "icon_image" || $params[1] == "map_icon_image")) {
$params[2] = $this->getIdIcon($params[2]);
}
if (!preg_match("/^hg_/", $params[1]) && $params[1] != "geo_coords") {
$params[1] = "hg_" . $params[1];
}

$updateParams = array($params[1] => $params[2]);
parent::setparam($objectId, $updateParams);
} else {
throw new CentreonClapiException(self::OBJECT_NOT_FOUND.":".$params[self::ORDER_UNIQUENAME]);
}
}

/**
* @param $path
* @return mixed
*/
public function getIdIcon($path)
{
$iconData = explode('/', $path);
$query = 'SELECT dir_id FROM view_img_dir WHERE dir_name = "' . $iconData[0] . '"';
$res = $this->db->query($query);
$row = $res->fetch();
$dirId = $row['dir_id'];

$query = 'SELECT img_id FROM view_img WHERE img_path = "' . $iconData[1] .'"';
$res = $this->db->query($query);
$row = $res->fetch();
$iconId = $row['img_id'];

$query = 'SELECT vidr_id FROM view_img_dir_relation ' .
'WHERE dir_dir_parent_id = ' . $dirId . ' AND img_img_id = ' . $iconId;
$res = $this->db->query($query);
$row = $res->fetch();
return $row['vidr_id'];
}


/**
* Magic method
*
Expand Down

0 comments on commit 4b645e7

Please sign in to comment.