diff --git a/www/class/centreon-clapi/centreonDowntime.class.php b/www/class/centreon-clapi/centreonDowntime.class.php index 0c04fc6a063..6277b3e7917 100644 --- a/www/class/centreon-clapi/centreonDowntime.class.php +++ b/www/class/centreon-clapi/centreonDowntime.class.php @@ -357,7 +357,6 @@ public function addspecificperiod($parameters) $this->insertPeriod($p); } - /** * Delete period from downtime * @@ -392,134 +391,6 @@ public function delperiod($parameters) $this->db->query($sql, $periodParams); } - /** - * List all Hosts - * - * @param int downtime id - */ - public function listAllHosts($downtimeId) - { - // hosts - $sql = "SELECT host_name - FROM downtime_host_relation dhr, host h - WHERE h.host_id = dhr.host_host_id - AND dhr.dt_id = ?"; - $stmt = $this->db->query($sql, array($downtimeId)); - $rows = $stmt->fetchAll(); - $hosts = array(); - foreach ($rows as $row) { - $hosts[] = $row['host_name']; - } - - // host groups - $sql = "SELECT hg_id - FROM downtime_hostgroup_relation dhr, hostgroup hg - WHERE hg.hg_id = dhr.hg_hg_id - AND dhr.dt_id = ?"; - $stmt = $this->db->query($sql, array($downtimeId)); - $rows = $stmt->fetchAll(); - foreach ($rows as $row) { - $hosts = array_merge($hosts, $this->listHostsByHg($row['hg_id'])); - } - - // print header - echo "hosts;\n"; - echo implode("|", $hosts) . $this->delim . "\n"; - } - - /** - * @param $hgId - * @return array - */ - public function listHostsByHg($hgId) - { - $sql = "SELECT host_name - FROM host h, hostgroup_relation hr - WHERE h.host_id = hr.host_host_id - AND hr.hostgroup_hg_id = ?"; - $stmt = $this->db->query($sql, array($hgId)); - $rows = $stmt->fetchAll(); - $hosts = array(); - foreach ($rows as $row) { - $hosts[] = $row['host_name']; - } - return $hosts; - } - - /** - * List Services - * - * @param int downtime id - */ - public function listAllServices($downtimeId) - { - // services - $sql = "SELECT host_name, service_description - FROM downtime_service_relation dsr, host h, service s - WHERE h.host_id = dsr.host_host_id - AND dsr.service_service_id = s.service_id - AND dsr.dt_id = ?"; - $stmt = $this->db->query($sql, array($downtimeId)); - $rows = $stmt->fetchAll(); - $services = array(); - foreach ($rows as $row) { - $services[] = $row['host_name'] . ',' . $row['service_description']; - } - - // service groups - $sql = "SELECT sg_id - FROM downtime_servicegroup_relation dsr, servicegroup sg - WHERE sg.sg_id = dsr.sg_sg_id - AND dsr.dt_id = ?"; - $stmt = $this->db->query($sql, array($downtimeId)); - $rows = $stmt->fetchAll(); - foreach ($rows as $row) { - $services = array_merge($services, $this->listServicesBySg($row['sg_id'])); - } - - // print header - echo "services;\n"; - echo implode("|", $services) . $this->delim . "\n"; - } - - /** - * @param $sgId - * @return array - */ - public function listServicesBySg($sgId) - { - // service groups / host - $sql = "SELECT h.host_name, s.service_description - FROM servicegroup_relation sgr, host h, service s - WHERE ISNULL(sgr.hostgroup_hg_id) - AND sgr.service_service_id = s.service_id - AND sgr.host_host_id = h.host_id - AND sgr.servicegroup_sg_id = ?"; - $stmt = $this->db->query($sql, array($sgId)); - $rows = $stmt->fetchAll(); - $servicegroups = array(); - foreach ($rows as $row) { - $servicegroups[] = $row['host_name'] . ',' . $row['service_description']; - } - - // service groups / host group - $sql = "SELECT sgr.hostgroup_hg_id, s.service_description FROM servicegroup_relation sgr, service s - WHERE ISNULL(sgr.host_host_id) - AND sgr.service_service_id = s.service_id - AND sgr.servicegroup_sg_id = ?"; - $stmt = $this->db->query($sql, array($sgId)); - $rows = $stmt->fetchAll(); - $servicegroups = array(); - foreach ($rows as $row) { - $hosts = $this->listHostsByHg($row['hostgroup_hg_id']); - foreach ($hosts as $host) { - $servicegroups[] = $host . ',' . $row['service_description']; - } - } - return $servicegroups; - } - - /** * @param $downtimeId * @return string