[-] BO: Fix #PSCFV-5930 #PSCFV-5939 the filters are handled as the same between tabs which can cause sql errors

This commit is contained in:
Rémi Gaillard
2013-01-14 12:08:12 +01:00
parent 556955a7f0
commit ef904c9083
2 changed files with 18 additions and 28 deletions
+13 -24
View File
@@ -419,41 +419,28 @@ class AdminControllerCore extends Controller
*/
public function processFilter()
{
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
// Filter memorization
if (isset($_POST) && !empty($_POST) && isset($this->table))
foreach ($_POST as $key => $value)
{
if (is_array($this->table))
{
foreach ($this->table as $table)
if (stripos($key, $table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
}
elseif (stripos($key, $this->table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
if (stripos($key, $this->table.'Filter_') === 0)
$this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : serialize($value);
elseif(stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
}
if (isset($_GET) && !empty($_GET) && isset($this->table))
foreach ($_GET as $key => $value)
{
if (is_array($this->table))
{
foreach ($this->table as $table)
if (stripos($key, $table.'OrderBy') === 0 || stripos($key, $table.'Orderway') === 0)
$this->context->cookie->$key = $value;
}
elseif (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
if (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
$this->context->cookie->$key = $value;
}
$filters = $this->context->cookie->getFamily($this->table.'Filter_');
$filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
foreach ($filters as $key => $value)
{
/* Extracting filters from $_POST on key filter_ */
if ($value != null && !strncmp($key, $this->table.'Filter_', 7 + Tools::strlen($this->table)))
if ($value != null && !strncmp($key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)))
{
$key = Tools::substr($key, 7 + Tools::strlen($this->table));
$key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->table));
/* Table alias could be specified using a ! eg. alias!field */
$tmp_tab = explode('!', $key);
$filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0];
@@ -835,11 +822,12 @@ class AdminControllerCore extends Controller
*/
public function processResetFilters()
{
$filters = $this->context->cookie->getFamily($this->table.'Filter_');
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
$filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
foreach ($filters as $cookie_key => $filter)
if (strncmp($cookie_key, $this->table.'Filter_', 7 + Tools::strlen($this->table)) == 0)
if (strncmp($cookie_key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)) == 0)
{
$key = substr($cookie_key, 7 + Tools::strlen($this->table));
$key = substr($cookie_key, 7 + Tools::strlen($prefix.$this->table));
/* Table alias could be specified using a ! eg. alias!field */
$tmp_tab = explode('!', $key);
$key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
@@ -1592,6 +1580,7 @@ class AdminControllerCore extends Controller
$helper->multiple_fieldsets = $this->multiple_fieldsets;
$helper->row_hover = $this->row_hover;
$helper->position_identifier = $this->position_identifier;
$helper->controller_name = $this->controller_name;
// For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions;