Details
Description
There are many calls to variations of this bit of code....
- // dupeCheck - check if contact record already exists
- // code modified from api/v2/Contact.php-function civicrm_contact_check_params()
- $params['contact_type'] = $this->_ctype;
- $dedupeParams = CRM_Dedupe_Finder::formatParams($params, $params['contact_type']);
- $dedupeParams['check_permission'] = '';
- //dupesByParams($params, $ctype, $level = 'Unsupervised', $except = array())
- $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type']);
I intend to rationalise it to this
$ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $this->_ctype, 'Unsupervised', array(), FALSE);
In many cases the result is then parsed for the first id, it any. I intend to reduce that to
- // add contact using dedupe rule
- $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
- $dedupeParams['check_permission'] = FALSE;
- $dupeIds = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
- // if we find more than one contact, use the first one
- if (!empty($dupeIds[0])) { - $params['contact_id'] = $dupeIds[0]; - }
+ $params['contact_id'] = CRM_Contact_BAO_Contact::getFirstDuplicateContact($params, 'Individual', 'Unsupervised', array(), FALSE);
Attachments
Issue Links
- links to
(1 links to)