* @return bool
* the result of this processing
*/
- public function summary(&$values) {
+ public function summary(&$values): int {
$erroneousField = NULL;
- $response = $this->setActiveFieldValues($values, $erroneousField);
-
+ $this->setActiveFieldValues($values, $erroneousField);
+ $rowNumber = (int) ($values[count($values) - 1]);
$errorMessage = NULL;
$errorRequired = FALSE;
switch ($this->_contactType) {
break;
}
- $statusFieldName = $this->_statusFieldName;
-
if ($this->_emailIndex >= 0) {
/* If we don't have the required fields, bail */
- if ($this->_contactType == 'Individual' && !$this->_updateWithId) {
+ if ($this->_contactType === 'Individual' && !$this->_updateWithId) {
if ($errorRequired && empty($values[$this->_emailIndex])) {
if ($errorMessage) {
$errorMessage .= ' ' . ts('OR') . ' ' . ts('Email Address');
$errorMessage = ts('Missing required field:') . ' ' . ts('Email Address');
}
array_unshift($values, $errorMessage);
- $importRecordParams = [
- $statusFieldName => 'ERROR',
- "${statusFieldName}Msg" => $errorMessage,
- ];
- $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+ $this->setImportStatus($rowNumber, 'ERROR', $errorMessage);
return CRM_Import_Parser::ERROR;
}
if (!CRM_Utils_Rule::email($email)) {
$errorMessage = ts('Invalid Email address');
array_unshift($values, $errorMessage);
- $importRecordParams = [
- $statusFieldName => 'ERROR',
- "${statusFieldName}Msg" => $errorMessage,
- ];
- $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+ $this->setImportStatus($rowNumber, 'ERROR', $errorMessage);
return CRM_Import_Parser::ERROR;
}
$errorMessage = ts('Missing required field:') . ' ' . ts('Email Address');
}
array_unshift($values, $errorMessage);
- $importRecordParams = [
- $statusFieldName => 'ERROR',
- "${statusFieldName}Msg" => $errorMessage,
- ];
- $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+ $this->setImportStatus($rowNumber, 'ERROR', $errorMessage);
return CRM_Import_Parser::ERROR;
}
if ($externalDupe = CRM_Utils_Array::value($externalID, $this->_allExternalIdentifiers)) {
$errorMessage = ts('External ID conflicts with record %1', [1 => $externalDupe]);
array_unshift($values, $errorMessage);
- $importRecordParams = [
- $statusFieldName => 'ERROR',
- "${statusFieldName}Msg" => $errorMessage,
- ];
- $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+ $this->setImportStatus($rowNumber, 'ERROR', $errorMessage);
return CRM_Import_Parser::ERROR;
}
//otherwise, count it and move on
$this->isErrorInCoreData($params, $errorMessage);
if ($errorMessage) {
$tempMsg = "Invalid value for field(s) : $errorMessage";
- // put the error message in the import record in the DB
- $importRecordParams = [
- $statusFieldName => 'ERROR',
- "${statusFieldName}Msg" => $tempMsg,
- ];
- $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+ $this->setImportStatus($rowNumber, 'ERROR', $tempMsg);
array_unshift($values, $tempMsg);
$errorMessage = NULL;
return CRM_Import_Parser::ERROR;
}
-
- //if user correcting errors by walking back
- //need to reset status ERROR msg to null
- //now currently we are having valid data.
- $importRecordParams = [
- $statusFieldName => 'NEW',
- ];
- $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+ $this->setImportStatus($rowNumber, 'NEW', '');
return CRM_Import_Parser::VALID;
}
* @throws \API_Exception
*/
public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) {
- $config = CRM_Core_Config::singleton();
$this->_unparsedStreetAddressContacts = [];
if (!$doGeocodeAddress) {
// CRM-5854, reset the geocode method to null to prevent geocoding
}
// check for values for custom fields for checkboxes and multiselect
- if ($isSerialized) {
+ if ($isSerialized && $dataType != 'ContactReference') {
$value = trim($value);
$value = str_replace('|', ',', $value);
$mulValues = explode(',', $value);
$defaults = [];
$contactObj = CRM_Contact_BAO_Contact::retrieve($contactParams, $defaults);
- $modeUpdate = $modeFill = FALSE;
-
- if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
- $modeUpdate = TRUE;
- }
-
- if ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
- $modeFill = TRUE;
- }
+ $modeFill = ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL);
$groupTree = CRM_Core_BAO_CustomGroup::getTree($params['contact_type'], NULL, $cid, 0, NULL);
CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults, FALSE, FALSE);
return array_keys($possibleMatches['values']);
}
if ($possibleMatches['count']) {
- if (in_array($extIDMatch, array_keys($possibleMatches['values']))) {
+ if (array_key_exists($extIDMatch, $possibleMatches['values'])) {
return [$extIDMatch];
}
throw new CRM_Core_Exception(ts(