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

fix(centreonACL): return all services linked to a servicegroup #8406

Merged
merged 5 commits into from
Mar 12, 2020
Merged
Changes from 4 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
45 changes: 28 additions & 17 deletions www/class/centreonACL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2022,9 +2022,15 @@ public function getServiceGroupAclConf($search = null, $broker = null, $options
}

/**
* Get Services in servicesgroups from ACL and configuration DB
* Get all services linked to a servicegroup regarding ACL
*
* @param int $sgId servicegroup id
* @param mixed $broker
* @param mixed $options
* @access public
* @return array
*/
public function getServiceServiceGroupAclConf($sg_id, $broker = null, $options = null)
public function getServiceServiceGroupAclConf($sgId, $broker = null, $options = null)
{
$services = array();

Expand Down Expand Up @@ -2058,24 +2064,29 @@ public function getServiceServiceGroupAclConf($sg_id, $broker = null, $options =
. "AND $db_name_acl.centreon_acl.host_id = host.host_id "
. "AND $db_name_acl.centreon_acl.service_id = service.service_id ";
}

// Making sure that the id provided is a real int
$option = array (
'default' => 0
);
adr-mo marked this conversation as resolved.
Show resolved Hide resolved
$sgId = filter_var($sgId, FILTER_VALIDATE_INT, $option);

/*
* Using the centreon_storage database to get the information
* where the services_servicegroups table provides "resolved" dependencies
* for possible components of the servicegroup which can be:
* - simple services
* - service templates
* - hostgroup services
*/
$query = $request['select'] . $request['simpleFields'] . " "
. "FROM ( "
. "SELECT " . $request['fields'] . " "
. "FROM servicegroup, servicegroup_relation, service, host " . $from_acl . " "
. "WHERE servicegroup.sg_id = '" . CentreonDB::escape($sg_id) . "' "
. "AND service.service_activate='1' AND host.host_activate='1' "
adr-mo marked this conversation as resolved.
Show resolved Hide resolved
. "AND servicegroup.sg_id = servicegroup_relation.servicegroup_sg_id "
. "AND servicegroup_relation.service_service_id = service.service_id "
. "AND servicegroup_relation.host_host_id = host.host_id "
. $where_acl . " "
. "UNION "
. "SELECT " . $request['fields'] . " "
. "FROM servicegroup, servicegroup_relation, hostgroup_relation, service, host " . $from_acl . " "
. "WHERE servicegroup.sg_id = '" . CentreonDB::escape($sg_id) . "' "
. "AND servicegroup.sg_id = servicegroup_relation.servicegroup_sg_id "
. "AND servicegroup_relation.hostgroup_hg_id = hostgroup_relation.hostgroup_hg_id "
. "AND hostgroup_relation.host_host_id = host.host_id "
. "AND servicegroup_relation.service_service_id = service.service_id "
. "FROM " . $db_name_acl . ".services_servicegroups, service, host" . $from_acl . " "
. "WHERE servicegroup_id = " . $sgId . " "
. "AND host.host_id = services_servicegroups.host_id "
. "AND service.service_id = services_servicegroups.service_id "
. "AND service.service_activate = '1' AND host.host_activate = '1'"
. $where_acl . " "
. ") as t ";

Expand Down