2
0
forked from Wavyzz/dolibarr

Merge pull request #20495 from atm-john/new_fix_regression_select_extrafield_search

FIX : regression select extrafield search + fix function name
This commit is contained in:
Laurent Destailleur
2022-05-24 21:55:33 +02:00
committed by GitHub
21 changed files with 164 additions and 90 deletions

View File

@@ -370,6 +370,32 @@ function GETPOSTISSET($paramname)
return $isset;
}
/**
* Return true if the parameter $paramname is submit from a POST OR GET as an array.
* Can be used before GETPOST to know if the $check param of GETPOST need to check an array or a string
*
* @param string $paramname Name or parameter to test
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
* @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty)
*/
function GETPOSTISARRAY($paramname, $method = 0)
{
// for $method test need return the same $val as GETPOST
if (empty($method)) {
$val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : '');
} elseif ($method == 1) {
$val = isset($_GET[$paramname]) ? $_GET[$paramname] : '';
} elseif ($method == 2) {
$val = isset($_POST[$paramname]) ? $_POST[$paramname] : '';
} elseif ($method == 3) {
$val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : '');
} else {
$val = 'BadFirstParameterForGETPOST';
}
return is_array($val);
}
/**
* Return value of a param into GET or POST supervariable.
* Use the property $user->default_values[path]['createform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
@@ -660,11 +686,11 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
$tmpcheck = 'alphanohtml';
}
foreach ($out as $outkey => $outval) {
$out[$outkey] = checkVal($outval, $tmpcheck, $filter, $options);
$out[$outkey] = sanitizeVal($outval, $tmpcheck, $filter, $options);
}
}
} else {
$out = checkVal($out, $check, $filter, $options);
$out = sanitizeVal($out, $check, $filter, $options);
}
// Sanitizing for special parameters.
@@ -713,9 +739,11 @@ function GETPOSTINT($paramname, $method = 0)
return (int) GETPOST($paramname, 'int', $method, null, null, 0);
}
/**
* Return a value after checking on a rule. A sanitization may also have been done.
* Return a sanitized or empty value after checking value against a rule.
*
* @deprecated
* @param string|array $out Value to check/clear.
* @param string $check Type of check/sanitizing
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
@@ -723,9 +751,24 @@ function GETPOSTINT($paramname, $method = 0)
* @return string|array Value sanitized (string or array). It may be '' if format check fails.
*/
function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = null)
{
return sanitizeVal($out, $check, $filter, $options);
}
/**
* Return a sanitized or empty value after checking value against a rule.
*
* @param string|array $out Value to check/clear.
* @param string $check Type of check/sanitizing
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
* @param mixed $options Options to pass to filter_var when $check is set to 'custom'
* @return string|array Value sanitized (string or array). It may be '' if format check fails.
*/
function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options = null)
{
global $conf;
// TODO : use class "Validate" to perform tests (and add missing tests) if needed for factorize
// Check is done after replacement
switch ($check) {
case 'none':