Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
ffd93213 | 3 | /** |
4f1f1f2a | 4 | * TODO: How to handle NULL values/records? |
ffd93213 EM |
5 | * Class CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised |
6 | */ | |
6a488035 TO |
7 | class CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised extends CRM_Dedupe_BAO_QueryBuilder { |
8 | ||
e0ef6999 | 9 | /** |
db7de9c1 | 10 | * Record - what do I do. |
57507ae6 EM |
11 | * |
12 | * @param object $rg | |
e0ef6999 EM |
13 | * |
14 | * @return array | |
15 | */ | |
00be9182 | 16 | public static function record($rg) { |
6a488035 TO |
17 | |
18 | $civicrm_contact = CRM_Utils_Array::value('civicrm_contact', $rg->params, array()); | |
19 | $civicrm_email = CRM_Utils_Array::value('civicrm_email', $rg->params, array()); | |
20 | ||
21 | $params = array( | |
d8689418 EM |
22 | 1 => array( |
23 | CRM_Utils_Array::value('first_name', $civicrm_contact, ''), | |
24 | 'String', | |
25 | ), | |
26 | 2 => array( | |
27 | CRM_Utils_Array::value('last_name', $civicrm_contact, ''), | |
28 | 'String', | |
29 | ), | |
30 | 3 => array( | |
31 | CRM_Utils_Array::value('email', $civicrm_email, ''), | |
32 | 'String', | |
33 | ), | |
6a488035 TO |
34 | ); |
35 | ||
36 | return array( | |
37 | "civicrm_contact.{$rg->name}.{$rg->threshold}" => CRM_Core_DAO::composeQuery(" | |
38 | SELECT contact.id as id1, {$rg->threshold} as weight | |
39 | FROM civicrm_contact as contact | |
40 | JOIN civicrm_email as email ON email.contact_id=contact.id | |
41 | WHERE contact_type = 'Individual' | |
42 | AND first_name = %1 | |
43 | AND last_name = %2 | |
44 | AND email = %3", $params, TRUE), | |
45 | ); | |
46 | } | |
47 | ||
e0ef6999 | 48 | /** |
57507ae6 EM |
49 | * Internal - what do I do. |
50 | * | |
51 | * @param object $rg | |
e0ef6999 EM |
52 | * |
53 | * @return array | |
54 | */ | |
00be9182 | 55 | public static function internal($rg) { |
c232f005 | 56 | $query = self::filterQueryByContactList($rg->contactIds, " |
6a488035 TO |
57 | SELECT contact1.id as id1, contact2.id as id2, {$rg->threshold} as weight |
58 | FROM civicrm_contact as contact1 | |
59 | JOIN civicrm_email as email1 ON email1.contact_id=contact1.id | |
60 | JOIN civicrm_contact as contact2 ON | |
61 | contact1.first_name = contact2.first_name AND | |
62 | contact1.last_name = contact2.last_name | |
63 | JOIN civicrm_email as email2 ON | |
64 | email2.contact_id=contact2.id AND | |
65 | email1.email=email2.email | |
c232f005 | 66 | WHERE contact1.contact_type = 'Individual'"); |
67 | ||
d8689418 | 68 | return array( |
5c9ff055 | 69 | "civicrm_contact.{$rg->name}.{$rg->threshold}" => $query, |
d8689418 | 70 | ); |
6a488035 | 71 | } |
96025800 | 72 | |
353ffa53 | 73 | } |