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

Commit

Permalink
fix(eventlogs): allow to filter on disabled objects (#8238)
Browse files Browse the repository at this point in the history
* fix(code): PSR2 compliance
* fix(acl): get only objects and not template
* fix(code): remove third parameter because never use
* fix(code): correct style
  • Loading branch information
lpinsivy committed Jan 16, 2020
1 parent 55be97e commit 5eb3db5
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions www/class/centreonACL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1455,42 +1455,46 @@ public function checkAction($action)
/**
* Function that returns the pair host/service by ID if $host_id is NULL
* Otherwise, it returns all the services of a specific host
*
* @param CentreonDB $pearDBMonitoring access to centreon_storage database
* @param Boolean $withServiceDescription to retrieve description of services
*
* @return array
*/
public function getHostsServices($pearDBMonitoring, $get_service_description = null)
public function getHostsServices($pearDBMonitoring, $withServiceDescription = false)
{
$tab = array();
$tab = [];
if ($this->admin) {
$req = (!is_null($get_service_description)) ? ", s.service_description " : "";
$req = $withServiceDescription ? ", s.service_description " : "";
$query = "SELECT h.host_id, s.service_id " . $req
. "FROM host h "
. "LEFT JOIN host_service_relation hsr on hsr.host_host_id = h.host_id "
. "LEFT JOIN service s on hsr.service_service_id = s.service_id "
. "WHERE h.host_activate = '1' "
. "AND (s.service_activate = '1' OR s.service_id is null) ";
$DBRESULT = \CentreonDBInstance::getConfInstance()->query($query);
while ($row = $DBRESULT->fetchRow()) {
if (!is_null($get_service_description)) {
. "WHERE h.host_register = '1' ";
$result = \CentreonDBInstance::getConfInstance()->query($query);
while ($row = $result->fetchRow()) {
if ($withServiceDescription) {
$tab[$row['host_id']][$row['service_id']] = $row['service_description'];
} else {
$tab[$row['host_id']][$row['service_id']] = 1;
}
}
$DBRESULT->closeCursor();
$result->closeCursor();
// Used By EventLogs page Only
if (!is_null($get_service_description)) {
if ($withServiceDescription) {
// Get Services attached to hostgroups
$query = "SELECT hgr.host_host_id, s.service_id, s.service_description "
. "FROM hostgroup_relation hgr, service s, host_service_relation hsr "
. "WHERE hsr.hostgroup_hg_id = hgr.hostgroup_hg_id "
. "AND s.service_id = hsr.service_service_id ";
$DBRESULT = \CentreonDBInstance::getConfInstance()->query($query);
while ($elem = $DBRESULT->fetchRow()) {
$result = \CentreonDBInstance::getConfInstance()->query($query);
while ($elem = $result->fetchRow()) {
$tab[$elem['host_host_id']][$elem["service_id"]] = $elem["service_description"];
}
$DBRESULT->closeCursor();
$result->closeCursor();
}
} else {
if (!is_null($get_service_description)) {
if ($withServiceDescription) {
$query = "SELECT acl.host_id, acl.service_id, s.description "
. "FROM centreon_acl acl "
. "LEFT JOIN services s on acl.service_id = s.service_id "
Expand All @@ -1503,21 +1507,21 @@ public function getHostsServices($pearDBMonitoring, $get_service_description = n
. "GROUP BY host_id, service_id ";
}

$DBRESULT = $pearDBMonitoring->query($query);
while ($row = $DBRESULT->fetchRow()) {
if (!is_null($get_service_description)) {
$result = $pearDBMonitoring->query($query);
while ($row = $result->fetchRow()) {
if ($withServiceDescription) {
$tab[$row['host_id']][$row['service_id']] = $row['description'];
} else {
$tab[$row['host_id']][$row['service_id']] = 1;
}
}
$DBRESULT->closeCursor();
$result->closeCursor();
}

return $tab;
}

public function getHostServices($pearDBMonitoring, $host_id, $get_service_description = null)
public function getHostServices($pearDBMonitoring, $host_id)
{
$tab = array();
if ($this->admin) {
Expand Down

0 comments on commit 5eb3db5

Please sign in to comment.