Fix the "back to list" link also restore the contextpage

This commit is contained in:
Laurent Destailleur
2018-06-23 11:55:04 +02:00
parent f2ac5dab4a
commit 4dcc74d08f
5 changed files with 62 additions and 33 deletions

View File

@@ -293,7 +293,6 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
if (empty($method) || $method == 3 || $method == 4)
{
$relativepathstring = $_SERVER["PHP_SELF"];
// Clean $relativepathstring
if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
@@ -303,21 +302,32 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
//var_dump($user->default_values);
// Code for search criteria persistence.
// Retrieve values if restore_lastsearch_values is set and there is saved values
if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here
// Retrieve values if restore_lastsearch_values
if (! empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST
{
$tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
if (is_array($tmp))
if (! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values
{
foreach($tmp as $key => $val)
$tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
if (is_array($tmp))
{
if ($key == $paramname)
foreach($tmp as $key => $val)
{
$out=$val;
break;
if ($key == $paramname) // We are on the requested parameter
{
$out=$val;
break;
}
}
}
}
if (! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) // If there is saved contextpage
{
if ($paramname == 'contextpage')
{
$out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
//var_dump($paramname.' '.$out);
}
}
}
// Else, retreive default values if we are not doing a sort
elseif (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set