$this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
}
$query = "SELECT dedupe.id1, dedupe.id2, dedupe.weight
- FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id
+ FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id
JOIN civicrm_contact c2 ON dedupe.id2 = c2.id {$this->_aclFrom}
LEFT JOIN civicrm_dedupe_exception exc ON dedupe.id1 = exc.contact_id1 AND dedupe.id2 = exc.contact_id2
- WHERE c1.contact_type = '{$this->contact_type}' AND
+ WHERE c1.contact_type = '{$this->contact_type}' AND
c2.contact_type = '{$this->contact_type}' {$this->_aclWhere}
AND weight >= {$this->threshold} AND exc.contact_id1 IS NULL";
}
* @return (rule field => weight) array and threshold associated to rule group
* @access public
*/
- function dedupeRuleFieldsWeight($params) {
+ static function dedupeRuleFieldsWeight($params) {
$rgBao = new CRM_Dedupe_BAO_RuleGroup();
$rgBao->used = $params['used'];
$rgBao->contact_type = $params['contact_type'];
}
//Relationship importables
- $this->_relationships = $relations = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $this->_contactType, FALSE, 'label', TRUE, $this->_contactSubType);
+ $this->_relationships = $relations =
+ CRM_Contact_BAO_Relationship::getContactRelationshipType(
+ NULL, NULL, NULL, $this->_contactType,
+ FALSE, 'label', TRUE, $this->_contactSubType
+ );
asort($relations);
foreach ($relations as $key => $var) {
$errorMessage = NULL;
+ //CRM-5125
+ //add custom fields for contact sub type
+ $csType = NULL;
+ if (!empty($this->_contactSubType)) {
+ $csType = $this->_contactSubType;
+ }
+
//checking error in custom data
- $this->isErrorInCustomData($params, $errorMessage);
+ $this->isErrorInCustomData($params, $errorMessage, $csType, $this->_relationships);
//checking error in core data
$this->isErrorInCoreData($params, $errorMessage);
$relatedCsType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$key]['id'], 'contact_sub_type');
}
- if (!empty($relatedCsType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params[$key]['id'], $relatedCsType) &&
+ if (!empty($relatedCsType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params[$key]['id'], $relatedCsType) &&
$relatedCsType != CRM_Utils_Array::value('contact_sub_type', $formatting))) {
$errorMessage = ts("Mismatched or Invalid contact subtype found for this related contact ID: %1", array(1 => $params[$key]['id']));
array_unshift($values, $errorMessage);
*
* @access public
*/
- function isErrorInCustomData($params, &$errorMessage) {
+ static function isErrorInCustomData($params, &$errorMessage, $csType = NULL, $relationships = NULL) {
$session = CRM_Core_Session::singleton();
$dateType = $session->get("dateTypes");
- //CRM-5125
- //add custom fields for contact sub type
- $csType = NULL;
- if (!empty($this->_contactSubType)) {
- $csType = $this->_contactSubType;
- }
-
if (CRM_Utils_Array::value('contact_sub_type', $params)) {
$csType = CRM_Utils_Array::value('contact_sub_type', $params);
}
+
if (!CRM_Utils_Array::value('contact_type', $params)) {
$params['contact_type'] = 'Individual';
}
elseif (is_array($params[$key]) && isset($params[$key]["contact_type"])) {
//CRM-5125
//supporting custom data of related contact subtypes
- if (array_key_exists($key, $this->_relationships)) {
- $relation = $key;
- }
- elseif (CRM_Utils_Array::key($key, $this->_relationships)) {
- $relation = CRM_Utils_Array::key($key, $this->_relationships);
+ $relation = NULL;
+ if ($relationships) {
+ if (array_key_exists($key, $relationships)) {
+ $relation = $key;
+ }
+ elseif (CRM_Utils_Array::key($key, $relationships)) {
+ $relation = CRM_Utils_Array::key($key, $relationships);
+ }
}
if (!empty($relation)) {
list($id, $first, $second) = CRM_Utils_System::explode('_', $relation, 3);
$relationshipType->free();
}
- self::isErrorInCustomData($params[$key], $errorMessage);
+ self::isErrorInCustomData($params[$key], $errorMessage, $csType, $relationships);
}
}
}
if (!empty($value)) {
foreach ($value as $stateValue) {
if ($stateValue['state_province']) {
- if (self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) ||
+ if (self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) ||
self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvince())) {
continue;
}