diff --git a/lib/Centreon/Object/Media/Media.php b/lib/Centreon/Object/Media/Media.php new file mode 100644 index 00000000000..1d02e82576a --- /dev/null +++ b/lib/Centreon/Object/Media/Media.php @@ -0,0 +1,48 @@ +. + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this program give CENTREON + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of CENTREON choice, provided that + * CENTREON also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this + * exception to your version of the program, but you are not obliged to do so. If you + * do not wish to do so, delete this exception statement from your version. + * + * For more information : contact@centreon.com + * + */ + +require_once "Centreon/Object/Object.php"; + +/** + * Used for interacting with media + * + * @author Mathieu Parent + */ +class Centreon_Object_Media extends Centreon_Object +{ + protected $table = "view_img"; + protected $primaryKey = "img_id"; + protected $uniqueLabelField = "img_path"; +} diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index 98ea47bf8b3..c23822370a0 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -63,6 +63,7 @@ require_once "Centreon/Object/Relation/Contact/Group/Host.php"; require_once "Centreon/Object/Relation/Host/Service.php"; require_once "Centreon/Object/Timezone/Timezone.php"; +require_once "Centreon/Object/Media/Media.php"; /** * Centreon Host objects @@ -334,6 +335,97 @@ public function setinstance($parameters) $relationObj->insert($instanceId, $hostId); } + /** + * Get a parameter + * + * @param string $parameters + * @return void + * @throws CentreonClapiException + */ + public function getparam($parameters = null) + { + $params = explode($this->delim, $parameters); + if (count($params) < 2) { + throw new CentreonClapiException(self::MISSINGPARAMETER); + } + if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) { + $extended = false; + $field = $params[1]; + switch ($params[1]) { + case "check_command": + $field = "command_command_id"; + break; + case "check_command_arguments": + $field = "command_command_id_arg1"; + break; + case "event_handler": + $field = "command_command_id2"; + break; + case "event_handler_arguments": + $field = "command_command_id_arg2"; + break; + case "check_period": + $field = "timeperiod_tp_id"; + break; + case "notification_period": + $field = "timeperiod_tp_id2"; + break; + case "notes": + case "notes_url": + case "action_url": + case "icon_image": + case "icon_image_alt": + case "vrml_image": + case "statusmap_image": + case "2d_coords": + case "3d_coords": + $extended = true; + break; + case self::HOST_LOCATION: + $field = 'host_location'; + break; + default: + if (!preg_match("/^host_/", $params[1])) { + $field = "host_" . $params[1]; + } + break; + } + if ($extended == false) { + $ret = $this->object->getParameters($objectId, $field); + $ret = $ret[$field]; + } else { + $field = "ehi_" . $field; + $extended = new \Centreon_Object_Host_Extended(); + $ret = $extended->getParameters($objectId, $field); + $ret = $ret[$field]; + } + switch ($params[1]) { + case "check_command": + case "event_handler": + $commandObject = new CentreonCommand(); + $field = $commandObject->object->getUniqueLabelField(); + $ret = $commandObject->object->getParameters($ret, $field); + $ret = $ret[$field]; + break; + case "check_period": + case "notification_period": + $tpObj = new CentreonTimePeriod(); + $field = $tpObj->object->getUniqueLabelField(); + $ret = $tpObj->object->getParameters($ret, $field); + $ret = $ret[$field]; + break; + case self::HOST_LOCATION: + $field = $this->timezoneObject->getUniqueLabelField(); + $ret = $this->timezoneObject->getParameters($ret, $field); + $ret = $ret[$field]; + break; + } + echo $ret . "\n"; + } else { + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]); + } + } + /** * Set parameters * diff --git a/www/class/centreon-clapi/centreonObject.class.php b/www/class/centreon-clapi/centreonObject.class.php index fd511a15dd2..03e1420aecd 100644 --- a/www/class/centreon-clapi/centreonObject.class.php +++ b/www/class/centreon-clapi/centreonObject.class.php @@ -282,6 +282,23 @@ public function del($objectName) } } + /** + * Get a parameter + * + * @param string $parameters + * @return void + * @throws CentreonClapiException + */ + public function getparam($parameters = null) + { + $params = explode($this->delim, $parameters); + if (count($params) < 2) { + throw new CentreonClapiException(self::MISSINGPARAMETER); + } + $p = $this->object->getParameters($params[0], $params[1]); + print $p[$params[1]] . "\n"; + } + /** * Set Param *