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

feat(pagination): persist selected results limit #6392

Merged
merged 1 commit into from
Jun 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions www/include/common/autoNumLimit.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -37,34 +37,42 @@
exit();
}

if (isset($_POST["limit"]) && $_POST["limit"]) {
$limit = $_POST["limit"];
} elseif (isset($_GET["limit"])) {
$limit = $_GET["limit"];
} elseif (!isset($_POST["limit"]) && !isset($_GET["limit"]) && isset($centreon->historyLimit[$url])) {
$limitNotInRequestParameter = !isset($_POST['limit']) && !isset($_GET['limit']);
$historyLimitNotDefault = isset($centreon->historyLimit[$url]) && $centreon->historyLimit[$url] !== 30;
$sessionLimitKey = "results_limit_{$url}";

if (isset($_POST['limit']) && $_POST['limit']) {
$limit = $_POST['limit'];
} elseif (isset($_GET['limit'])) {
$limit = $_GET['limit'];
} elseif ($limitNotInRequestParameter && $historyLimitNotDefault) {
$limit = $centreon->historyLimit[$url];
} elseif (isset($_SESSION[$sessionLimitKey])) {
$limit = $_SESSION[$sessionLimitKey];
} else {
if (($p >= 200 && $p < 300) || ($p >= 20000 && $p < 30000)) {
$DBRESULT = $pearDB->query("SELECT * FROM `options` WHERE `key` = 'maxViewMonitoring'");
$gopt = $DBRESULT->fetchRow();
$limit = myDecode($gopt["value"]);
$gopt = $DBRESULT->fetch();
$limit = myDecode($gopt['value']);
} else {
$DBRESULT = $pearDB->query("SELECT * FROM `options` WHERE `key` = 'maxViewConfiguration'");
$gopt = $DBRESULT->fetchRow();
$limit = myDecode($gopt["value"]);
$gopt = $DBRESULT->fetch();
$limit = myDecode($gopt['value']);
}
}

$_SESSION[$sessionLimitKey] = $limit;

if (!empty($centreon->historyLimit) &&
!empty($centreon->historyLimit[$url]) &&
$limit != $centreon->historyLimit[$url]
) {
$num = 0;
} elseif (isset($_POST["num"]) && $_POST["num"]) {
$num = $_POST["num"];
} elseif (isset($_GET["num"]) && $_GET["num"]) {
$num = $_GET["num"];
} elseif (!isset($_POST["num"]) && !isset($_GET["num"]) && isset($centreon->historyPage[$url])) {
} elseif (isset($_POST['num']) && $_POST['num']) {
$num = $_POST['num'];
} elseif (isset($_GET['num']) && $_GET['num']) {
$num = $_GET['num'];
} elseif (!isset($_POST['num']) && !isset($_GET['num']) && isset($centreon->historyPage[$url])) {
$num = $centreon->historyPage[$url];
} else {
$num = 0;
Expand Down