Skip to content

Commit

Permalink
* [FIX] Wrong behavior when checking saved search filters in context.…
Browse files Browse the repository at this point in the history
… Thanks to @fprina for the feedback. Related #1178

Signed-off-by: Rubén D <nuxsmin@syspass.org>
  • Loading branch information
nuxsmin committed Jan 19, 2019
1 parent 79e2591 commit f1d9230
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 90 deletions.
Expand Up @@ -65,6 +65,10 @@ final class AccountSearchHelper extends HelperBase
* @var bool
*/
private $isAjax = false;
/**
* @var bool
*/
private $isIndex = false;
/**
* @var AccountSearchFilter
*/
Expand Down Expand Up @@ -281,6 +285,7 @@ protected function initialize()
{
$this->queryTimeStart = microtime(true);
$this->sk = $this->view->get('sk');
$this->isIndex = $this->request->analyzeString('r') === Acl::getActionRoute(ActionsInterface::ACCOUNT);
$this->setVars();
}

Expand All @@ -298,7 +303,6 @@ private function setVars()
$this->configData->isGlobalSearch()
&& $this->context->getUserProfile()->isAccGlobalSearch());

// Obtener el filtro de búsqueda desde la sesión
$this->accountSearchFilter = $this->getFilters();

$this->view->assign('searchCustomer', $this->accountSearchFilter->getClientId());
Expand All @@ -323,13 +327,15 @@ private function getFilters()
{
$accountSearchFilter = $this->context->getSearchFilters();

if ($accountSearchFilter !== null && empty($this->request->analyzeString('sk'))) {
// Obtener el filtro de búsqueda desde la sesión
// Return search filters from session if accessed from menu
if ($accountSearchFilter !== null && $this->isIndex) {
return $accountSearchFilter;
}

$userPreferences = $this->context->getUserData()->getPreferences();
$limitCount = $userPreferences->getResultsPerPage() > 0 ? $userPreferences->getResultsPerPage() : $this->configData->getAccountCount();
$limitCount = $userPreferences->getResultsPerPage() > 0
? $userPreferences->getResultsPerPage()
: $this->configData->getAccountCount();

$accountSearchFilter = new AccountSearchFilter();
$accountSearchFilter->setSortKey($this->request->analyzeInt('skey', 0));
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -46,8 +46,9 @@
"fzaninotto/faker": "~v1.8",
"fabpot/goutte": "~v3.2",
"syspass/extension-installer-plugin": "dev-master",
"syspass/plugin-authenticator": "dev-master",
"ext-xdebug": "*"
"syspass/plugin-authenticator": "^2.0",
"ext-xdebug": "*",
"nikic/php-parser": " ~v4.1"
},
"suggest": {
"syspass/plugin-authenticator": "^2.0",
Expand Down

0 comments on commit f1d9230

Please sign in to comment.