Skip to content

Commit

Permalink
centreon#5297 [CLAPI] Several bugs on HG / CG when export is filtered
Browse files Browse the repository at this point in the history
Fix Hostgroup members filtered export
  • Loading branch information
Simon Bomm authored Jun 7, 2017
1 parent 1c8b3e9 commit 25d5154
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions www/class/centreon-clapi/centreonHostGroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,34 +248,29 @@ public function __call($name, $arg)
*
* @return void
*/
public function export($filter_id=null, $filter_name=null)
{
public function export($filter_id=null, $filter_name=null) {
$filters = null;
if (!is_null($filter_id)) {
$filters = array('hg_id' => $filter_id);
}
parent::export($filters);

$relObj = new \Centreon_Object_Relation_Host_Group_Host();
$hostObj = new \Centreon_Object_Host();


$relObj = new Centreon_Object_Relation_Host_Group_Host();
$hostObj = new Centreon_Object_Host();
$hgFieldName = $this->object->getUniqueLabelField();
$hFieldName = $hostObj->getUniqueLabelField();
$elements = $relObj->getMergedParameters(
array($hgFieldName),
array($hFieldName, 'host_id'),
-1,
0,
$hgFieldName,
null
);
null,
"ASC",
array('hg_name' => $filter_name),
"AND");
foreach ($elements as $element) {
$this->api->export_filter('HOST', $element['host_id'], $element[$hFieldName]);
echo $this->action . $this->delim
. "addhost" . $this->delim
. $element[$hgFieldName] . $this->delim
. $element[$hFieldName] . "\n";
echo $this->action . $this->delim . "addhost" . $this->delim . $element[$hgFieldName] . $this->delim.$element[$hFieldName] . "\n";
}
}

}

0 comments on commit 25d5154

Please sign in to comment.