return '';
}
- /**
- * Searches for a contact in the db with similar attributes.
- *
- * @param array $params
- * The list of values to be used in the where clause.
- * @param int $id
- * The current contact id (hence excluded from matching).
- * @param string $contactType
- *
- * @return int|null
- * contact_id if found, null otherwise
- */
- public static function findContact(&$params, $id = NULL, $contactType = 'Individual') {
- $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $contactType, 'Supervised', array($id), CRM_Utils_Array::value('check_permission', $params, TRUE));
- if (!empty($ids)) {
- return implode(',', $ids);
- }
- else {
- return NULL;
- }
- }
-
/**
* Given a contact id and a field set, return the values from the db.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
- * @return CRM_Friend_BAO_Friend
+ * @return int
*/
public static function add(&$params) {
- $friend = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
- return $friend;
+ return CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
}
/**
//create contact only if it does not exits in db
$value['email'] = $value['email-Primary'];
- $value['check_permission'] = FALSE;
- $contact = CRM_Core_BAO_UFGroup::findContact($value, NULL, 'Individual');
+ $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($value, 'Individual', 'Supervised', array(), FALSE);
- if (!$contact) {
- $contact = self::add($value);
+ if (!$contactID) {
+ $contactID = self::add($value);
}
// attempt to save activity targets
$targetParams = array(
'activity_id' => $activity->id,
- 'contact_id' => $contact,
+ 'contact_id' => $contactID,
'record_type_id' => $targetID,
);
// See if it already exists
$activityContact = new CRM_Activity_DAO_ActivityContact();
$activityContact->activity_id = $activity->id;
- $activityContact->contact_id = $contact;
+ $activityContact->contact_id = $contactID;
$activityContact->find(TRUE);
if (empty($activityContact->id)) {
- $resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
+ CRM_Activity_BAO_ActivityContact::create($targetParams);
}
}