mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 07:32:32 +01:00
NEW Default filter and sort order can use partial list of query
parameters to set the qualified URLs.
This commit is contained in:
@@ -277,12 +277,14 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
||||
|
||||
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);
|
||||
$relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
||||
$relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
|
||||
//var_dump($relativepathstring);
|
||||
//var_dump($relativepathstring);
|
||||
//var_dump($user->default_values);
|
||||
|
||||
// Code for search criteria persistence.
|
||||
// Retrieve values if restore_lastsearch_values is set and there is saved values
|
||||
@@ -319,46 +321,85 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
||||
if (! empty($user->default_values)) // $user->default_values defined from menu default values
|
||||
{
|
||||
//var_dump($user->default_values[$relativepathstring]);
|
||||
if ($paramname == 'sortfield')
|
||||
if ($paramname == 'sortfield') // Sorted on which fields ?
|
||||
{
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // We will use the key of $user->default_values[path][sortorder]
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
$out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder_queries'])) // Even if paramname is sortfield, data are stored into ['sortorder...']
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['sortorder_queries']);
|
||||
$tmpqueryarraywehave=explode('&', $_SERVER['QUERY_STRING']);
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // We will use the key of $user->default_values[path][sortorder]
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
$out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($paramname == 'sortorder')
|
||||
elseif ($paramname == 'sortorder') // ASC or DESC ?
|
||||
{
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // We will use the val of $user->default_values[path][sortorder]
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
$out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder_queries']))
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['sortorder_queries']);
|
||||
$tmpqueryarraywehave=explode('&', $_SERVER['QUERY_STRING']);
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // We will use the val of $user->default_values[path][sortorder]
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
$out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($user->default_values[$relativepathstring]['filters'][$paramname]))
|
||||
{
|
||||
if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all']))
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['filters_queries']))
|
||||
{
|
||||
// We made a search from quick search menu, do we still use default filter ?
|
||||
if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH))
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['filters_queries']);
|
||||
$tmpqueryarraywehave=explode('&', $_SERVER['QUERY_STRING']);
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], '', $forbidden_chars_to_replace);
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], '', $forbidden_chars_to_replace);
|
||||
}
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all']))
|
||||
{
|
||||
// We made a search from quick search menu, do we still use default filter ?
|
||||
if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH))
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user