//@todo direct call to API function not supported.
// setting required check to false, CRM-2839
// plus we do our own required check in import
- $error = _civicrm_api3_deprecated_contact_check_params($formatted, $dupeCheck, TRUE, FALSE, $dedupeRuleGroupID);
+ $error = _civicrm_api3_deprecated_contact_check_params($formatted, $dupeCheck, $dedupeRuleGroupID);
if ((is_null($error)) && (civicrm_error(_civicrm_api3_deprecated_validate_formatted_contact($formatted)))) {
$error = _civicrm_api3_deprecated_validate_formatted_contact($formatted);
/**
* @param array $params
* @param bool $dupeCheck
- * @param bool $dupeErrorArray
- * @param bool $requiredCheck
* @param int $dedupeRuleGroupID
*
* @return array|null
function _civicrm_api3_deprecated_contact_check_params(
&$params,
$dupeCheck = TRUE,
- $dupeErrorArray = FALSE,
- $requiredCheck = TRUE,
$dedupeRuleGroupID = NULL) {
+
+ $requiredCheck = TRUE;
+
if (isset($params['id']) && is_numeric($params['id'])) {
$requiredCheck = FALSE;
}
// $ids = $dupes['count'] ? implode(',', array_keys($dupes['values'])) : NULL;
$ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $params['contact_type'], 'Unsupervised', array(), CRM_Utils_Array::value('check_permissions', $params, $dedupeRuleGroupID));
if ($ids != NULL) {
- if ($dupeErrorArray) {
- $error = CRM_Core_Error::createError("Found matching contacts: $ids",
- CRM_Core_Error::DUPLICATE_CONTACT,
- 'Fatal', $ids
- );
- return civicrm_api3_create_error($error->pop());
- }
-
- return civicrm_api3_create_error("Found matching contacts: $ids");
+ $error = CRM_Core_Error::createError("Found matching contacts: " . implode(',', $ids),
+ CRM_Core_Error::DUPLICATE_CONTACT,
+ 'Fatal', $ids
+ );
+ return civicrm_api3_create_error($error->pop());
}
}
public function testCheckParamsWithNoContactType() {
$params = array('foo' => 'bar');
$contact = _civicrm_api3_deprecated_contact_check_params($params, FALSE);
- $this->assertEquals(1, $contact['is_error'], "In line " . __LINE__);
- }
-
-
- /**
- * Test civicrm_contact_check_params with a duplicate.
- */
- public function testCheckParamsWithDuplicateContact() {
- // Insert a row in civicrm_contact creating individual contact
- $op = new PHPUnit_Extensions_Database_Operation_Insert();
- $op->execute($this->_dbconn,
- $this->createXMLDataSet(
- dirname(__FILE__) . '/../../api/v3/dataset/contact_17.xml'
- )
- );
- $op->execute($this->_dbconn,
- $this->createXMLDataSet(
- dirname(__FILE__) . '/../../api/v3/dataset/email_contact_17.xml'
- )
- );
-
- $params = array(
- 'first_name' => 'Test',
- 'last_name' => 'Contact',
- 'email' => 'TestContact@example.com',
- 'contact_type' => 'Individual',
- );
- $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE);
$this->assertEquals(1, $contact['is_error']);
- $this->assertRegexp("/matching contacts.*17/s",
- CRM_Utils_Array::value('error_message', $contact)
- );
}
-
/**
* Test civicrm_contact_check_params with a duplicate.
* and request the error in array format
'email' => 'TestContact@example.com',
'contact_type' => 'Individual',
);
- $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE, TRUE);
+ $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE);
$this->assertEquals(1, $contact['is_error']);
$this->assertRegexp("/matching contacts.*17/s",
$contact['error_message']['message']
public function testCheckParamsWithNoParams() {
$params = array();
$contact = _civicrm_api3_deprecated_contact_check_params($params, FALSE);
- $this->assertEquals(1, $contact['is_error'], "In line " . __LINE__);
+ $this->assertEquals(1, $contact['is_error']);
}
}