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

Commit

Permalink
Mon 3807 service disabled filter (#7612)
Browse files Browse the repository at this point in the history
* fix(filter) fix status filter for services by host
* fix(filter) fix status filter for services by host group
  • Loading branch information
loiclau committed Jun 18, 2019
1 parent c17bda0 commit 93827c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
11 changes: 3 additions & 8 deletions www/include/configuration/configObject/host/listHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
FILTER_VALIDATE_INT
);

$status = -1;

if (isset($_POST['searchH']) || isset($_GET['searchH'])) {
//saving chosen filters values
$centreon->historySearch[$url] = array();
Expand All @@ -86,21 +84,18 @@
$centreon->historySearch[$url]["hostgroup"] = $hostgroup;
$centreon->historySearch[$url]["template"] = $template;
$status = $_POST["status"] ?? '';
// Security fix
$status = (int)(($status != '') ? $status : -1);
$centreon->historySearch[$url]["status"] = $status;
} else {
//restoring saved values
$search = $centreon->historySearch[$url]['search'] ?? null;
$poller = $centreon->historySearch[$url]["poller"] ?? 0;
$hostgroup = $centreon->historySearch[$url]["hostgroup"] ?? 0;
$template = $centreon->historySearch[$url]["template"] ?? 0;
if (isset($centreon->historySearch[$url]["status"])) {
$status = $centreon->historySearch[$url]["status"];
}
$status = $centreon->historySearch[$url]["status"] ?? -1;
}

// Security fix
$status = (int)(($status != '') ? $status : -1);

// set object history
$centreon->poller = $poller;
$centreon->hostgroup = $hostgroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@

$hostgroups = null;

$status = filter_var(
$_POST["status"] ?? $_GET["status"] ?? -1,
FILTER_VALIDATE_INT
);

$template = filter_var(
$_POST['template'] ?? $_GET['template'] ?? null,
FILTER_SANITIZE_STRING
Expand All @@ -81,20 +76,24 @@
//saving filters values
$centreon->historySearch[$url] = array();
$centreon->historySearch[$url]["template"] = $template;
$centreon->historySearch[$url]["status"] = $status;
$centreon->historySearch[$url]["searchH"] = $searchH;
$centreon->historySearch[$url]["searchS"] = $searchS;
$hostStatus = isset($_POST["statusHostFilter"]) ? 1 : 0;
$centreon->historySearch[$url]["hostStatus"] = $hostStatus;
$status = $_POST["status"] ?? '';
// Security fix
$status = (int)(($status != '') ? $status : -1);
$centreon->historySearch[$url]["status"] = $status;
} else {
//restoring saved values
$template = $centreon->historySearch[$url]['template'] ?? null;
$status = $centreon->historySearch[$url]["status"] ?? -1;
$searchH = $centreon->historySearch[$url]["searchH"] ?? null;
$searchS = $centreon->historySearch[$url]["searchS"] ?? null;
$hostStatus = $centreon->historySearch[$url]["hostStatus"] ?? 0;
$status = $centreon->historySearch[$url]["status"] ?? -1;
}


$searchH_SQL = '';
if ($searchH) {
$searchH_SQL .= "AND (host.host_name LIKE '%" . $pearDB->escape($searchH) .
Expand Down Expand Up @@ -136,12 +135,12 @@
$statusFilter .= "<option value='1'" .
(($status == 1) ? " selected" : "") . ">" . _("Enabled") . "</option>";
$statusFilter .= "<option value='0'" .
(($status == 0 && $status != '') ? " selected" : "") . ">" . _("Disabled") . "</option>";
(($status == 0) ? " selected" : "") . ">" . _("Disabled") . "</option>";

$sqlFilterCase = "";
if ($status == 1) {
$sqlFilterCase = " AND sv.service_activate = '1' ";
} elseif ($status == 0 && $status != "") {
} elseif ($status == 0) {
$sqlFilterCase = " AND sv.service_activate = '0' ";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@
FILTER_SANITIZE_STRING
);

$status = filter_var(
$_POST["status"] ?? $_GET["status"] ?? -1,
FILTER_VALIDATE_INT
);

if (isset($_POST['Search']) || isset($_GET ['Search'])) {
//saving filters values
$centreon->historySearch[$url] = array();
$centreon->historySearch[$url]["hostgroups"] = $searchHG;
$centreon->historySearch[$url]["search"] = $searchS;
$centreon->historySearch[$url]["template"] = $template;
$status = $_POST["status"] ?? '';
// Security fix
$status = (int)(($status != '') ? $status : -1);
$centreon->historySearch[$url]["status"] = $status;
} else {
//restoring saved values
Expand All @@ -76,6 +74,8 @@
$status = $centreon->historySearch[$url]["status"] ?? -1;
}



/*
* Get Service Template List
*/
Expand All @@ -96,12 +96,12 @@
$statusFilter = "<option value=''" . (($status == -1) ? " selected" : "") . "> </option>";
$statusFilter .= "<option value='1'" . (($status == 1) ? " selected" : "") . ">" . _("Enabled") . "</option>";
$statusFilter .= "<option value='0'" .
(($status == 0 && $status != '') ? " selected" : "") . ">" . _("Disabled") . "</option>";
(($status == 0) ? " selected" : "") . ">" . _("Disabled") . "</option>";

$sqlFilterCase = "";
if ($status == 1) {
$sqlFilterCase = " AND sv.service_activate = '1' ";
} elseif ($status == 0 && $status != "") {
} elseif ($status == 0) {
$sqlFilterCase = " AND sv.service_activate = '0' ";
}

Expand Down

0 comments on commit 93827c0

Please sign in to comment.