+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016 |
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
* Whether to actually restore, not delete.
* @param bool $skipUndelete
* Whether to force contact delete or not.
+ * @param bool $checkPermissions
*
* @return bool
* Was contact deleted?
),
);
+ // @todo This can be figured out from metadata & we can avoid the uncached query.
CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);
$values['preferred_communication_method'] = $preffComm;
$values['age']['y'] = CRM_Utils_Array::value('years', $age);
$values['age']['m'] = CRM_Utils_Array::value('months', $age);
}
-
- list($values['birth_date']) = CRM_Utils_Date::setDateDefaults($contact->birth_date, 'birth');
- $values['birth_date_display'] = $contact->birth_date;
- }
-
- if ($contact->deceased_date) {
- list($values['deceased_date']) = CRM_Utils_Date::setDateDefaults($contact->deceased_date, 'birth');
- $values['deceased_date_display'] = $contact->deceased_date;
}
$contact->contact_id = $contact->id;
* Ensures that is_primary gets assigned to another object if available
* Also calls pre/post hooks
*
- * @var object $type
- * @var int $id
+ * @param string $type
+ * @param int $id
* @return bool
*/
public static function deleteObjectWithPrimary($type, $id) {
return $clauses;
}
+ /**
+ * Get any existing duplicate contacts based on the input parameters.
+ *
+ * @param array $input
+ * Input parameters to be matched.
+ * @param string $contactType
+ * @param string $rule
+ * - Supervised
+ * - Unsupervised
+ * @param $excludedContactIDs
+ * An array of ids not to be included in the results.
+ * @param bool $checkPermissions
+ * @param int $ruleGroupID
+ * ID of the rule group to be used if an override is desirable.
+ *
+ * @return array
+ */
+ public static function getDuplicateContacts($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = array(), $checkPermissions = TRUE, $ruleGroupID = NULL) {
+ $dedupeParams = CRM_Dedupe_Finder::formatParams($input, $contactType);
+ $dedupeParams['check_permission'] = $checkPermissions;
+ $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $contactType, $rule, $excludedContactIDs, $ruleGroupID);
+ return $ids;
+ }
+
+ /**
+ * Get the first duplicate contacts based on the input parameters.
+ *
+ * @param array $input
+ * Input parameters to be matched.
+ * @param string $contactType
+ * @param string $rule
+ * - Supervised
+ * - Unsupervised
+ * @param $excludedContactIDs
+ * An array of ids not to be included in the results.
+ * @param bool $checkPermissions
+ * @param int $ruleGroupID
+ * ID of the rule group to be used if an override is desirable.
+ *
+ * @return int|NULL
+ */
+ public static function getFirstDuplicateContact($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = array(), $checkPermissions = TRUE, $ruleGroupID = NULL) {
+ $ids = self::getDuplicateContacts($input, $contactType, $rule, $excludedContactIDs, $checkPermissions, $ruleGroupID);
+ if (empty($ids)) {
+ return NULL;
+ }
+ return $ids[0];
+ }
+
}