Skip to content

Commit

Permalink
Fixed issue #11509: numerical input option integer only leads to posi…
Browse files Browse the repository at this point in the history
…tive integer input only

Dev: DECIMAL value for numeric make me mad ;)
  • Loading branch information
Shnoulle committed Aug 1, 2016
1 parent 84dadaf commit 0fbeaa8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -2743,16 +2743,18 @@ function exprmgr_if($test,$ok,$error)

/**
* Return true if the variable is an integer for LimeSurvey
* Can not really use is_int due to SQL DECIMAL system
* Can not really use is_int due to SQL DECIMAL system. This function can surely be improved
* @param string $arg
* @return boolean
* @link http://php.net/is_int#82857
*/
function exprmgr_int($arg)
{
if(strpos($arg,"."))
{
$arg=preg_replace("/\.$/","",rtrim(strval($arg),"0"));// DECIMAL from SQL return always .00000000, the remove all 0 and one . , see #09550
return (ctype_digit($arg));// Accept empty value too before PHP 5.1 see http://php.net/ctype-digit#refsect1-function.ctype-digit-changelog
}
return (preg_match("/^-?[0-9]*$/",$arg));// Allow 000 for value, @link https://bugs.limesurvey.org/view.php?id=9550 DECIMAL sql type.
}
/**
* Join together $args[0-N] with ', '
Expand Down

0 comments on commit 0fbeaa8

Please sign in to comment.