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

Cp7 m510 centreon awie (fixes) #6313

Merged
merged 3 commits into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Centreon/Cache/Manager/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function factory($instanceName = "cache", $lifetime = 60, $cacheDi
* @param array $sqlParams
* @return string
*/
public function getCacheFileName($sqlQuery, $sqlParams = array())
public static function getCacheFileName($sqlQuery, $sqlParams = array())
{
$paramString = implode(",", $sqlParams);
return md5($sqlQuery.$paramString);
Expand Down
4 changes: 2 additions & 2 deletions lib/Zend/Cache/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Zend_Cache_Backend
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
}
Expand All @@ -78,7 +78,7 @@ public function __construct(array $options = array())
public function setDirectives($directives)
{
if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
while (list($name, $value) = each($directives)) {
foreach ($directives as $name => $value) {
if (!is_string($name)) {
Zend_Cache::throwException("Incorrect option name : $name");
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Zend/Cache/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function __construct($options = array())
Zend_Cache::throwException("Options passed were not an array"
. " or Zend_Config instance.");
}
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
$this->_loggerSanity();
Expand All @@ -158,7 +158,7 @@ public function __construct($options = array())
public function setConfig(Zend_Config $config)
{
$options = $config->toArray();
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
return $this;
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Cache/Frontend/Class.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
if ($this->_specificOptions['cached_entity'] === null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Cache/Frontend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
if (!isset($this->_specificOptions['master_files'])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Cache/Frontend/Function.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
$this->setOption('automatic_serialization', true);
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Cache/Frontend/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$name = strtolower($name);
switch ($name) {
case 'regexps':
Expand Down
4 changes: 4 additions & 0 deletions www/class/centreon-clapi/centreonAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ public function export()
}
foreach ($selected as $select) {
$splits = explode(';', $select);

$splits[0] = isset($splits[0]) ? $splits[0] : null;
$splits[1] = isset($splits[1]) ? $splits[1] : null;

if (!isset($this->objectTable[$splits[0]])) {
print "Unknown object : $splits[0]\n";
$this->setReturnCode(1);
Expand Down
2 changes: 1 addition & 1 deletion www/class/centreon-clapi/centreonExported.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function is_exported($object, $id, $name)
return 1;
}

if (!is_array($this->exported[$object])) {
if (!isset($this->exported[$object]) || !is_array($this->exported[$object])) {
$this->exported[$object] = array();
}
$this->exported[$object][$id] = 1;
Expand Down
11 changes: 8 additions & 3 deletions www/class/centreon-clapi/centreonHost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ protected function getHostListByParent(&$elements)
public function export($filters = null)
{
$filters["host_register"] = $this->register;
$filters['host_id'] = isset($filters['host_id']) ? $filters['host_id'] : null;
$elements = $this->object->getList("*", -1, 0, null, null, $filters, "AND");
$extendedObj = new \Centreon_Object_Host_Extended($this->dependencyInjector);
$commandObj = new \Centreon_Object_Command($this->dependencyInjector);
Expand Down Expand Up @@ -1153,7 +1154,7 @@ public function export($filters = null)
}
}
}
if ($param != "hostgroup" && $param != "template") {
if (isset($element[$param]) && $param != "hostgroup" && $param != "template") {
$addStr .= $element[$param];
}
}
Expand Down Expand Up @@ -1200,7 +1201,7 @@ public function export($filters = null)
echo $this->action . $this->delim
. "addparent" . $this->delim
. $element[$this->object->getUniqueLabelField()] . $this->delim
. $elements[$parentId][$this->object->getUniqueLabelField()] . "\n";
. isset($elements[$parentId]) && isset($elements[$parentId][$this->object->getUniqueLabelField()]) ? $elements[$parentId][$this->object->getUniqueLabelField()] : '' . "\n";
}
}

Expand Down Expand Up @@ -1286,7 +1287,11 @@ public function export($filters = null)
"AND"
);
foreach ($elements as $element) {
$this->api->export_filter('CONTACT', $element['contact_id'], $element['contact_name']);
$exportContactId = isset($element['contact_id']) ? $element['contact_id'] : null;
$exportContactName = isset($element['contact_name']) ? $element['contact_name'] : null;

$this->api->export_filter('CONTACT', $exportContactId, $exportContactName);

echo $this->action . $this->delim
. "addcontact" . $this->delim
. $element[$this->object->getUniqueLabelField()] . $this->delim
Expand Down
6 changes: 4 additions & 2 deletions www/class/centreon-clapi/centreonObject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,10 @@ protected function checkParameters()
/**
* Add Action
*
* @param mixed $parameters
* @return int
*/
public function add()
public function add($parameters = NULL)
{
$id = $this->object->insert($this->params);
$this->addAuditLog(
Expand Down Expand Up @@ -347,9 +348,10 @@ public function setparam($objectId, $params = array())
* Shows list
*
* @param array $params
* @param array $filters
* @return void
*/
public function show($params = array(), $filters = array())
public function show(array $params = null, array $filters = null)
{
echo str_replace("_", " ", implode($this->delim, $params)) . "\n";
$elements = $this->object->getList($params, -1, 0, null, null, $filters);
Expand Down
17 changes: 13 additions & 4 deletions www/class/centreon-clapi/centreonServiceTemplate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ public function setmacro($parameters)
if (count($params) < 3) {
throw new CentreonClapiException(self::MISSINGPARAMETER);
}

$params[3] = isset($params[3]) ? $params[3] : null;

$elements = $this->object->getList(
"service_id",
-1,
Expand Down Expand Up @@ -907,7 +910,7 @@ protected function parseTemplateTree($tree, $filter_id = null)
. $this->stripMacro($macro['svc_macro_name']) . $this->delim
. $macro['svc_macro_value'] . "\n";
}
if (count($element['children'])) {
if (isset($element['children']) && count($element['children'])) {
$this->parseTemplateTree($element['children'], $extendedObj);
}
}
Expand All @@ -921,6 +924,8 @@ protected function parseTemplateTree($tree, $filter_id = null)
public function export($filters = null)
{
$filters["service_register"] = $this->register;
$filters['service_id'] = isset($filters['service_id']) ? $filters['service_id'] : null;

$elements = $this->object->getList(
"*",
-1,
Expand Down Expand Up @@ -967,7 +972,7 @@ public function export($filters = null)
// contacts
$contactRel = new \Centreon_Object_Relation_Contact_Service($this->dependencyInjector);
$filters_contactRel = array("service_register" => $this->register);
if (!is_null($filters['service_id'])) {
if (isset($filters['service_id']) && !is_null($filters['service_id'])) {
$filters_contactRel['service_id'] = $filters['service_id'];
}
$elements = $contactRel->getMergedParameters(
Expand All @@ -981,7 +986,11 @@ public function export($filters = null)
"AND"
);
foreach ($elements as $element) {
$this->api->export_filter('CONTACT', $element['contact_id'], $element['contact_name']);
$exportContactId = isset($element['contact_id']) ? $element['contact_id'] : null;
$exportContactName = isset($element['contact_name']) ? $element['contact_name'] : null;

$this->api->export_filter('CONTACT', $exportContactId, $exportContactName);

echo $this->action . $this->delim
. "addcontact" . $this->delim
. $element['service_description'] . $this->delim
Expand All @@ -996,7 +1005,7 @@ public function export($filters = null)
0,
null,
null,
array('svc_svc_id' => $element[$this->object->getPrimaryKey()]),
array('svc_svc_id' => isset($element[$this->object->getPrimaryKey()]) ? $element[$this->object->getPrimaryKey()] : null),
"AND"
);
foreach ($macros as $macro) {
Expand Down