diff --git a/www/class/centreonACL.class.php b/www/class/centreonACL.class.php index 0a73c747997..d739294f842 100644 --- a/www/class/centreonACL.class.php +++ b/www/class/centreonACL.class.php @@ -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(); @@ -2058,24 +2064,27 @@ 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 = ['default' => 0]; + $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' " - . "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 ";