X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FType.php;h=e2786712a420786e263ea190cd925d0c160516db;hb=cf726992aa4ce457eb4fba768b075085167ad7cb;hp=7b0aeb5133d235aa8603bb59623b15db6d861222;hpb=fa3cdb8efb79c28c9f425543815556f6cfefe9ac;p=civicrm-core.git diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 7b0aeb5133..e2786712a4 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -67,6 +67,16 @@ class CRM_Utils_Type { FORTYFIVE = 45, HUGE = 45; + /** + * Maximum size of a MySQL BLOB or TEXT column in bytes. + */ + const BLOB_SIZE = 65535; + + /** + * Maximum value of a MySQL signed INT column. + */ + const INT_MAX = 2147483647; + /** * Gets the string representation for a data type. * @@ -148,7 +158,7 @@ class CRM_Utils_Type { * An array of type in the form 'type name' => 'int representing type' */ public static function getValidTypes() { - return array( + return [ 'Int' => self::T_INT, 'String' => self::T_STRING, 'Enum' => self::T_ENUM, @@ -162,7 +172,7 @@ class CRM_Utils_Type { 'Money' => self::T_MONEY, 'Email' => self::T_EMAIL, 'Mediumblob' => self::T_MEDIUMBLOB, - ); + ]; } /** @@ -361,7 +371,7 @@ class CRM_Utils_Type { } // Normal clause. - $part = preg_replace_callback('/^(?:(?:((?:`[\w-]{1,64}`|[\w-]{1,64}))(?:\.))?(`[\w-]{1,64}`|[\w-]{1,64})(?: (asc|desc))?)$/i', array('CRM_Utils_Type', 'mysqlOrderByCallback'), trim($part)); + $part = preg_replace_callback('/^(?:(?:((?:`[\w-]{1,64}`|[\w-]{1,64}))(?:\.))?(`[\w-]{1,64}`|[\w-]{1,64})(?: (asc|desc))?)$/i', ['CRM_Utils_Type', 'mysqlOrderByCallback'], trim($part)); } return implode(', ', $parts); } @@ -403,7 +413,7 @@ class CRM_Utils_Type { */ public static function validate($data, $type, $abort = TRUE, $name = 'One of parameters ', $isThrowException = FALSE) { - $possibleTypes = array( + $possibleTypes = [ 'Integer', 'Int', 'Positive', @@ -424,7 +434,8 @@ class CRM_Utils_Type { 'ExtensionKey', 'Json', 'Alphanumeric', - ); + 'Color', + ]; if (!in_array($type, $possibleTypes)) { if ($isThrowException) { throw new CRM_Core_Exception(ts('Invalid type, must be one of : ' . implode($possibleTypes))); @@ -544,6 +555,12 @@ class CRM_Utils_Type { return $data; } break; + + case 'Color': + if (CRM_Utils_Rule::color($data)) { + return $data; + } + break; } if ($abort) { @@ -601,7 +618,7 @@ class CRM_Utils_Type { * @return array */ public static function dataTypes() { - $types = array( + $types = [ 'Integer', 'String', 'Date', @@ -609,7 +626,7 @@ class CRM_Utils_Type { 'Timestamp', 'Money', 'Email', - ); + ]; return array_combine($types, $types); }