From 70dd449fdbb5880b0fab0848c5685f959be2dcd3 Mon Sep 17 00:00:00 2001 From: atif-shaikh Date: Wed, 25 Jun 2014 21:36:42 +0530 Subject: [PATCH] QA fixes --- CRM/Contact/Import/Parser/Contact.php | 10 +++++++--- CRM/Utils/DeprecatedUtils.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index ea1bdce838..2c7448b960 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -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]); diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index f3502ae60b..42e389d7b9 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -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) . '\'' ); -- 2.25.1