Filter/Errors

* move checks to __construct so they can be run on $_POST data
   and don't create malformed filter urls
 * if we received malformed $_GET params, build new params and reload
 * do not store error state in cache
 * cleanup
This commit is contained in:
Sarjuuk
2025-10-14 19:36:47 +02:00
parent c0097f3987
commit 37beaa2db5
18 changed files with 280 additions and 202 deletions

View File

@@ -99,6 +99,12 @@ class ItemsBaseResponse extends TemplateResponse implements ICache
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
$this->filter = new ItemListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
if ($this->filter->shouldReload)
{
$_SESSION['error']['fi'] = $this->filter::class;
$get = $this->filter->buildGETParam();
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
}
$this->filterError = $this->filter->error;
}
@@ -110,14 +116,9 @@ class ItemsBaseResponse extends TemplateResponse implements ICache
if (!User::isInGroup(U_GROUP_EMPLOYEE))
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
$this->filter->evalCriteria();
$this->filter->evalWeights();
if ($_ = $this->filter->getConditions())
$conditions[] = $_;
$this->filterError = $this->filter->error; // maybe the evalX() caused something
/*******************/
/* evaluate filter */