- if ($dupeCheck) {
- // check for record already existing
- $dedupeParams = CRM_Dedupe_Finder::formatParams($params, $params['contact_type']);
-
- // CRM-6431
- // setting 'check_permission' here means that the dedupe checking will be carried out even if the
- // person does not have permission to carry out de-dupes
- // this is similar to the front end form
- if (isset($params['check_permission'])) {
- $dedupeParams['check_permission'] = $params['check_permission'];
- }
-
- $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type'], 'Unsupervised', array());
-
- if (count($ids) > 0) {
- throw new API_Exception("Found matching contacts: " . implode(',', $ids), "duplicate", array("ids" => $ids));
- }
- }
-