本文整理汇总了PHP中_civicrm_api3_deprecated_duplicate_formatted_contact函数的典型用法代码示例。如果您正苦于以下问题:PHP _civicrm_api3_deprecated_duplicate_formatted_contact函数的具体用法?PHP _civicrm_api3_deprecated_duplicate_formatted_contact怎么用?PHP _civicrm_api3_deprecated_duplicate_formatted_contact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_civicrm_api3_deprecated_duplicate_formatted_contact函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _civicrm_api3_deprecated_check_contact_dedupe
/**
* check duplicate contacts based on de-deupe parameters
*/
function _civicrm_api3_deprecated_check_contact_dedupe($params)
{
static $cIndieFields = NULL;
static $defaultLocationId = NULL;
$contactType = $params['contact_type'];
if ($cIndieFields == NULL) {
require_once 'CRM/Contact/BAO/Contact.php';
$cTempIndieFields = CRM_Contact_BAO_Contact::importableFields($contactType);
$cIndieFields = $cTempIndieFields;
require_once "CRM/Core/BAO/LocationType.php";
$defaultLocation = CRM_Core_BAO_LocationType::getDefault();
// set the value to default location id else set to 1
if (!($defaultLocationId = (int) $defaultLocation->id)) {
$defaultLocationId = 1;
}
}
require_once 'CRM/Contact/BAO/Query.php';
$locationFields = CRM_Contact_BAO_Query::$_locationSpecificFields;
$contactFormatted = array();
foreach ($params as $key => $field) {
if ($field == NULL || $field === '') {
continue;
}
if (is_array($field)) {
foreach ($field as $value) {
$break = FALSE;
if (is_array($value)) {
foreach ($value as $name => $testForEmpty) {
if ($name !== 'phone_type' && ($testForEmpty === '' || $testForEmpty == NULL)) {
$break = TRUE;
break;
}
}
} else {
$break = TRUE;
}
if (!$break) {
_civicrm_api3_deprecated_add_formatted_param($value, $contactFormatted);
}
}
continue;
}
$value = array($key => $field);
// check if location related field, then we need to add primary location type
if (in_array($key, $locationFields)) {
$value['location_type_id'] = $defaultLocationId;
} elseif (array_key_exists($key, $cIndieFields)) {
$value['contact_type'] = $contactType;
}
_civicrm_api3_deprecated_add_formatted_param($value, $contactFormatted);
}
$contactFormatted['contact_type'] = $contactType;
return _civicrm_api3_deprecated_duplicate_formatted_contact($contactFormatted);
}
示例2: import
/**
* handle the values in import mode
*
* @param int $onDuplicate the code for what action to take on duplicates
* @param array $values the array of values belonging to this line
*
* @return boolean the result of this processing
* @access public
*/
function import($onDuplicate, &$values)
{
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
$activityLabel = array_search('activity_label', $this->_mapperKeys);
if ($activityLabel) {
$params = array_merge($params, array('activity_label' => $values[$activityLabel]));
}
//for date-Formats
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
if (!isset($params['source_contact_id'])) {
$params['source_contact_id'] = $session->get('userID');
}
$formatted = array();
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
foreach ($params as $key => $val) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($key == 'activity_date_time' && $val) {
$params[$key] = CRM_Utils_Date::formatDate($val, $dateType);
} elseif ($customFields[$customFieldID]['data_type'] == 'Date') {
CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $params, $dateType, $key);
} elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
} elseif ($key == 'activity_subject') {
$params['subject'] = $val;
}
}
//date-Format part ends
require_once 'CRM/Utils/DeprecatedUtils.php';
$formatError = _civicrm_api3_deprecated_activity_formatted_param($params, $params, TRUE);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
return CRM_Import_Parser::ERROR;
}
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, CRM_Core_DAO::$_nullObject, NULL, 'Activity');
if ($this->_contactIdIndex < 0) {
//retrieve contact id using contact dedupe rule.
//since we are support only individual's activity import.
$params['contact_type'] = 'Individual';
$params['version'] = 3;
$error = _civicrm_api3_deprecated_duplicate_formatted_contact($params);
if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
$matchedIDs = explode(',', $error['error_message']['params'][0]);
if (count($matchedIDs) > 1) {
array_unshift($values, 'Multiple matching contact records detected for this row. The activity was not imported');
return CRM_Import_Parser::ERROR;
} else {
$cid = $matchedIDs[0];
$params['target_contact_id'] = $cid;
$params['version'] = 3;
$newActivity = civicrm_api('activity', 'create', $params);
if (CRM_Utils_Array::value('is_error', $newActivity)) {
array_unshift($values, $newActivity['error_message']);
return CRM_Import_Parser::ERROR;
}
$this->_newActivity[] = $newActivity['id'];
return CRM_Import_Parser::VALID;
}
} else {
// Using new Dedupe rule.
$ruleParams = array('contact_type' => 'Individual', 'used' => 'Unsupervised');
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
$disp = NULL;
foreach ($fieldsArray as $value) {
if (array_key_exists(trim($value), $params)) {
$paramValue = $params[trim($value)];
if (is_array($paramValue)) {
$disp .= $params[trim($value)][0][trim($value)] . " ";
} else {
$disp .= $params[trim($value)] . " ";
}
}
}
if (CRM_Utils_Array::value('external_identifier', $params)) {
if ($disp) {
$disp .= "AND {$params['external_identifier']}";
} else {
$disp = $params['external_identifier'];
}
}
array_unshift($values, 'No matching Contact found for (' . $disp . ')');
return CRM_Import_Parser::ERROR;
}
} else {
if (CRM_Utils_Array::value('external_identifier', $params)) {
//.........这里部分代码省略.........
示例3: import
/**
* Handle the values in import mode.
*
* @param int $onDuplicate
* The code for what action to take on duplicates.
* @param array $values
* The array of values belonging to this line.
*
* @param bool $doGeocodeAddress
*
* @return bool
* the result of this processing
*/
public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE)
{
$config = CRM_Core_Config::singleton();
$this->_unparsedStreetAddressContacts = array();
if (!$doGeocodeAddress) {
// CRM-5854, reset the geocode method to null to prevent geocoding
$config->geocodeMethod = NULL;
}
// first make sure this is a valid line
//$this->_updateWithId = false;
$response = $this->summary($values);
$statusFieldName = $this->_statusFieldName;
if ($response != CRM_Import_Parser::VALID) {
$importRecordParams = array($statusFieldName => 'INVALID', "{$statusFieldName}Msg" => "Invalid (Error Code: {$response})");
$this->updateImportRecord($values[count($values) - 1], $importRecordParams);
return $response;
}
$params =& $this->getActiveFieldParams();
$formatted = array('contact_type' => $this->_contactType);
static $contactFields = NULL;
if ($contactFields == NULL) {
$contactFields = CRM_Contact_DAO_Contact::import();
}
//check if external identifier exists in database
if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, array(CRM_Import_Parser::DUPLICATE_SKIP, CRM_Import_Parser::DUPLICATE_NOCHECK)))) {
if ($internalCid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
if ($internalCid != CRM_Utils_Array::value('id', $params)) {
$errorMessage = ts('External ID already exists in Database.');
array_unshift($values, $errorMessage);
$importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
$this->updateImportRecord($values[count($values) - 1], $importRecordParams);
return CRM_Import_Parser::DUPLICATE;
}
}
}
if (!empty($this->_contactSubType)) {
$params['contact_sub_type'] = $this->_contactSubType;
}
if ($subType = CRM_Utils_Array::value('contact_sub_type', $params)) {
if (CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType, FALSE, 'label')) {
$subTypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType, FALSE, NULL);
$params['contact_sub_type'] = array_search($subType, $subTypes);
} elseif (!CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType)) {
$message = "Mismatched or Invalid Contact Subtype.";
array_unshift($values, $message);
return CRM_Import_Parser::NO_MATCH;
}
}
//get contact id to format common data in update/fill mode,
//if external identifier is present, CRM-4423
if ($this->_updateWithId && empty($params['id']) && !empty($params['external_identifier'])) {
if ($cid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
$formatted['id'] = $cid;
}
}
//format common data, CRM-4062
$this->formatCommonData($params, $formatted, $contactFields);
$relationship = FALSE;
$createNewContact = TRUE;
// Support Match and Update Via Contact ID
if ($this->_updateWithId) {
$createNewContact = FALSE;
if (empty($params['id']) && !empty($params['external_identifier'])) {
if ($cid) {
$params['id'] = $cid;
}
}
$error = _civicrm_api3_deprecated_duplicate_formatted_contact($formatted);
if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
$matchedIDs = explode(',', $error['error_message']['params'][0]);
if (count($matchedIDs) >= 1) {
$updateflag = TRUE;
foreach ($matchedIDs as $contactId) {
if ($params['id'] == $contactId) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_type');
if ($formatted['contact_type'] == $contactType) {
//validation of subtype for update mode
//CRM-5125
$contactSubType = NULL;
if (!empty($params['contact_sub_type'])) {
$contactSubType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_sub_type');
}
if (!empty($contactSubType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params['id'], $contactSubType) && $contactSubType != CRM_Utils_Array::value('contact_sub_type', $formatted))) {
$message = "Mismatched contact SubTypes :";
array_unshift($values, $message);
$updateflag = FALSE;
$this->_retCode = CRM_Import_Parser::NO_MATCH;
//.........这里部分代码省略.........