+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
* $Id$
*
*/
*/
var $contactIds = array();
+ /**
+ * Set the contact IDs to restrict the dedupe to.
+ *
+ * @param array $contactIds
+ */
+ public function setContactIds($contactIds) {
+ $this->contactIds = $contactIds;
+ }
+
/**
* Params to dedupe against (queries against the whole contact set otherwise)
*/
'addressee.label' => 'civicrm_contact.addressee_id',
'email_greeting.label' => 'civicrm_contact.email_greeting_id',
'postal_greeting.label' => 'civicrm_contact.postal_greeting_id',
+ 'civicrm_phone.phone' => 'civicrm_phone.phone_numeric',
);
// the table names we support in dedupe rules - a filter for importableFields()
$supportedTables = array(
if ($this->is_reserved &&
CRM_Utils_File::isIncludable("CRM/Dedupe/BAO/QueryBuilder/{$this->name}.php")
) {
- include_once "CRM/Dedupe/BAO/QueryBuilder/{$this->name}.php";
- $class = "CRM_Dedupe_BAO_QueryBuilder_{$this->name}";
$command = empty($this->params) ? 'internal' : 'record';
- $queries = call_user_func(array($class, $command), $this);
+ $queries = call_user_func(array("CRM_Dedupe_BAO_QueryBuilder_{$this->name}", $command), $this);
}
else {
// All other rule groups have queries generated by the member dedupe
// if there are no rules in this rule group
// add an empty query fulfilling the pattern
if (!$queries) {
- $queries = array('SELECT 0 id1, 0 id2, 0 weight LIMIT 0');
$this->noRules = TRUE;
+ return array();
}
return $queries;
return $result;
}
+
+ /**
+ * Get the cached contact type for a particular rule group.
+ *
+ * @param int $rule_group_id
+ *
+ * @return string
+ */
+ public static function getContactTypeForRuleGroup($rule_group_id) {
+ if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['rule_groups'])) {
+ \Civi::$statics[__CLASS__]['rule_groups'] = array();
+ }
+ if (empty(\Civi::$statics[__CLASS__]['rule_groups'][$rule_group_id])) {
+ \Civi::$statics[__CLASS__]['rule_groups'][$rule_group_id]['contact_type'] = CRM_Core_DAO::getFieldValue(
+ 'CRM_Dedupe_DAO_RuleGroup',
+ $rule_group_id,
+ 'contact_type'
+ );
+ }
+
+ return \Civi::$statics[__CLASS__]['rule_groups'][$rule_group_id]['contact_type'];
+ }
+
}