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

Commit

Permalink
fix(ui): saving configuration > other command pages filters
Browse files Browse the repository at this point in the history
  • Loading branch information
sc979 committed Apr 2, 2019
1 parent 898e0b9 commit 4be6b42
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions www/include/configuration/configObject/command/listCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,43 @@
FILTER_SANITIZE_STRING
);

if (isset($_POST['searchC']) || $_GET['search']) {
$centreon->historySearch[$url] = $search;
$num = filter_var(
$_POST['num'] ?? $_GET['num'] ?? $centreon->historyPage[$url] ?? 0,
FILTER_VALIDATE_INT
);

$type = filter_var(
$_POST['type'] ?? $_GET['type'] ?? null,
FILTER_VALIDATE_INT
);

// As the four pages of this menu are generated dynamically from the same ihtml and php files,
// we need to save $type and to overload the $num value set in the pagination.php file to restore each user's filter.
$savedType = $centreon->historySearch[$url]['type'] ?? null;

// As pagination.php will already check if the current page was previously loaded or not,
// we're only checking if the last loaded page have the same $type value (1,2,3 or 4)
if (isset($type) && $type !== $savedType) {
//if so, we reset the pagination and save the current $type
$num = $centreon->historyPage[$url] = 0;
$centreon->historySearch[$url]['type'] = $type;
} else {
$search = $centreon->historySearch[$url];
//saving again the pagination filter
$centreon->historyPage[$url] = $num;
}

$type_str = $type ? " AND `command_type` = " . $type : "";
if (isset($_POST['searchC'])) {
//restoring user's search field value
$centreon->historySearch[$url] = array();
// the four pages have the same $url, so we need to distinguish each page using its $type,
// and to save the four search filters.
$centreon->historySearch[$url]['search' . $type] = $search;
} else {
//saving user's search field value
$search = $centreon->historySearch[$url]['search' . $type] ?? null;
}

$type_str = $type ? " AND `command_type` = " . $type : "";
$search = tidySearchKey($search, $advanced_search);

//List of elements - Depends on different criteria
Expand Down Expand Up @@ -98,7 +127,12 @@
$style = "one";

// Define command Type table
$commandType = array("1" => _("Notification"), "2" => _("Check"), "3" => _("Miscellaneous"), "4" => _("Discovery"));
$commandType = array(
"1" => _("Notification"),
"2" => _("Check"),
"3" => _("Miscellaneous"),
"4" => _("Discovery")
);

// Fill a tab with a multidimensional Array we put in $tpl
$elemArr = array();
Expand Down

0 comments on commit 4be6b42

Please sign in to comment.