Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-08-19-00-06-22
[civicrm-core.git] / CRM / Utils / Type.php
index 68b0eed2d74f6df97144aed54380290d79cbcd66..ece56c100a291710c1794456c0e98e0bf0212095 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id: $
  *
  */
@@ -70,9 +70,7 @@ class CRM_Utils_Type {
    *
    * @param  $type       integer datatype
    *
-   * @return $string     String datatype respective to integer datatype
-   *
-   * @access public
+   * @return string $string     String datatype respective to integer datatype@access public
    * @static
    */
   static function typeToString($type) {
@@ -160,10 +158,33 @@ class CRM_Utils_Type {
         break;
 
       case 'Positive':
-        // the below 2 are for custom fields of this type
-        // CRM-8925
+      // CRM-8925 the 3 below are for custom fields of this type
       case 'Country':
       case 'StateProvince':
+        // Checked for multi valued state/country value
+        if (is_array($data)) {
+          $returnData = TRUE;
+          foreach ($data as $data) {
+            if (CRM_Utils_Rule::positiveInteger($data) || CRM_Core_DAO::escapeString($data)) {
+              $returnData = TRUE;
+            }
+            else {
+              $returnData = FALSE;
+            }
+          }
+          if ($returnData) {
+            return $data;
+          }
+        }
+        elseif (!is_numeric($data) &&  CRM_Core_DAO::escapeString($data)) {
+          return $data;
+        }
+        elseif (CRM_Utils_Rule::positiveInteger($data)) {
+          return $data;
+        }
+        break;
+
+      case 'File':
         if (CRM_Utils_Rule::positiveInteger($data)) {
           return $data;
         }