From: pdontthink Date: Fri, 8 Sep 2006 06:33:53 +0000 (+0000) Subject: Use constants for sqgetGlobalVar() typecasting X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c2b585c5e1d529845bf8e596f1c20c90e4caa1e5;p=squirrelmail.git Use constants for sqgetGlobalVar() typecasting git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11685 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/global.php b/functions/global.php index b04a5adb..d7612d16 100644 --- a/functions/global.php +++ b/functions/global.php @@ -147,6 +147,9 @@ function sqsession_is_registered ($name) { * @param string name the name of the var to search * @param mixed value the variable to return * @param int search constant defining where to look + * @param int typecast force variable to be cast to given type (please + * use SQ_TYPE_XXX constants or set to FALSE (default) + * to leave variable type unmolested) * @return bool whether variable is found. */ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER, $default = NULL, $typecast = false) { @@ -201,8 +204,9 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER, $default = NULL, $ } if ($result && $typecast) { switch ($typecast) { - case 'int': $value = (int) $value; break; - case 'bool': $value = (bool) $value; break; + case SQ_TYPE_INT: $value = (int) $value; break; + case SQ_TYPE_STRING: $value = (string) $value; break; + case SQ_TYPE_BOOL: $value = (bool) $value; break; default: break; } } else if (!is_null($default)) { diff --git a/include/constants.php b/include/constants.php index 9745b8b0..adaff817 100644 --- a/include/constants.php +++ b/include/constants.php @@ -150,3 +150,13 @@ define('SQM_COL_INT_DATE', 8); define('SQM_COL_TO', 9); define('SQM_COL_CC', 10); define('SQM_COL_BCC', 11); + +/** + * Generic variable type constants + * @since 1.5.2 + */ +define('SQ_TYPE_INT', 'int'); +define('SQ_TYPE_STRING', 'string'); +define('SQ_TYPE_BOOL', 'bool'); +define('SQ_TYPE_ARRAY', 'array'); +