QA fixes
authoratif-shaikh <shaikh388@gmail.com>
Wed, 25 Jun 2014 16:06:42 +0000 (21:36 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Thu, 26 Jun 2014 15:08:14 +0000 (20:38 +0530)
CRM/Contact/Import/Parser/Contact.php
CRM/Utils/DeprecatedUtils.php

index ea1bdce8388218e15b1b6161c7d5d70eb4a1ce32..2c7448b960aea122689f61bf6132ab93cb9a8dc8 100644 (file)
@@ -1147,7 +1147,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           self::addToErrorMsg(ts('field ID'), $errorMessage);
         }
         // validate null values for required custom fields of type boolean
-        if ($customFields[$customFieldID]['is_required'] && (empty($params['custom_'.$customFieldID]) && $params['custom_'.$customFieldID] !== 0) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
+        if ($customFields[$customFieldID]['is_required'] && (empty($params['custom_'.$customFieldID]) && !is_numeric($params['custom_'.$customFieldID])) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
           self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage);
         }
 
@@ -1172,7 +1172,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           }
           elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
             if (CRM_Utils_String::strtoboolstr($value) === FALSE) {
-              self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
+              self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage);
             }
           }
           // need not check for label filed import
@@ -1875,7 +1875,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           self::formatCustomDate($params, $formatted, $dateType, $key);
         }
         elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
-          if (empty($val) && !empty($params['id']) && !is_numeric($val) && $this->_onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {  //retain earlier value when Import mode is `Fill`
+          if (empty($val) && !is_numeric($val) && $this->_onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
+            //retain earlier value when Import mode is `Fill`
             unset($params[$key]);
           }
           else {
@@ -2010,6 +2011,9 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
     // to check if not update mode and unset the fields with empty value.
     if (!$this->_updateWithId && array_key_exists('custom', $formatted)) {
       foreach ($formatted['custom'] as $customKey => $customvalue) {
+        if (empty($formatted['custom'][$customKey][- 1]['is_required'])) {
+          $formatted['custom'][$customKey][-1]['is_required'] = $customFields[$customKey]['is_required'];
+        }
         $emptyValue = CRM_Utils_Array::value('value', $customvalue[ - 1]);
         if (!isset($emptyValue)) {
           unset($formatted['custom'][$customKey]);
index f3502ae60b5ef4f59dadb354034f80b6c0c6fe54..42e389d7b910ed9efdbbd986c6a03f36b1e5e9ae 100644 (file)
@@ -1180,7 +1180,7 @@ function _civicrm_api3_deprecated_validate_formatted_contact(&$params) {
           $valid = CRM_Core_BAO_CustomValue::typecheck(CRM_Utils_Array::value('type', $value),
             CRM_Utils_Array::value('value', $value)
           );
-          if (!$valid) {
+          if (!$valid && $value['is_required']) {
             return civicrm_api3_create_error('Invalid value for custom field \'' .
               CRM_Utils_Array::value('name', $custom) . '\''
             );