+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
// Allow hook_civicrm_merge() to adjust $locTables
CRM_Utils_Hook::merge('locTables', $locTables);
// Allow hook_civicrm_merge() to adjust $locTables
CRM_Utils_Hook::merge('locTables', $locTables);
'extends' => array('IN' => array('Individual', 'Organization', 'Household', 'Contact')),
'return' => array('id', 'title', 'table_name', 'style'),
));
'extends' => array('IN' => array('Individual', 'Organization', 'Household', 'Contact')),
'return' => array('id', 'title', 'table_name', 'style'),
));
$data['cidRefs'][$custom['table_name']] = array('entity_id');
$urlSuffix = $custom['style'] == 'Tab' ? '&selectedChild=custom_' . $custom['id'] : '';
$data['relTables']['rel_table_custom_' . $custom['id']] = array(
$data['cidRefs'][$custom['table_name']] = array('entity_id');
$urlSuffix = $custom['style'] == 'Tab' ? '&selectedChild=custom_' . $custom['id'] : '';
$data['relTables']['rel_table_custom_' . $custom['id']] = array(
* Tables which require custom processing should declare functions to call here.
* Doing so will override normal processing.
*/
* Tables which require custom processing should declare functions to call here.
* Doing so will override normal processing.
*/
- static function operationSql($mainId, $otherId, $tableName, $tableOperations = array(), $mode = 'add') {
+ public static function operationSql($mainId, $otherId, $tableName, $tableOperations = array(), $mode = 'add') {
DELETE membership1.* FROM civicrm_membership membership1
INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = membership2.membership_type_id
AND membership1.contact_id = {$mainId}
AND membership2.contact_id = {$otherId} ";
DELETE membership1.* FROM civicrm_membership membership1
INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = membership2.membership_type_id
AND membership1.contact_id = {$mainId}
AND membership2.contact_id = {$otherId} ";
DELETE contribution.* FROM civicrm_contribution contribution
INNER JOIN civicrm_membership_payment payment ON payment.contribution_id = contribution.id
INNER JOIN civicrm_membership membership1 ON membership1.id = payment.membership_id
AND membership1.contact_id = {$mainId}
INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = membership2.membership_type_id
AND membership2.contact_id = {$otherId}";
DELETE contribution.* FROM civicrm_contribution contribution
INNER JOIN civicrm_membership_payment payment ON payment.contribution_id = contribution.id
INNER JOIN civicrm_membership membership1 ON membership1.id = payment.membership_id
AND membership1.contact_id = {$mainId}
INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = membership2.membership_type_id
AND membership2.contact_id = {$otherId}";
* Based on the provided two contact_ids and a set of tables, move the
* belongings of the other contact to the main one.
*
* Based on the provided two contact_ids and a set of tables, move the
* belongings of the other contact to the main one.
*
- static function moveContactBelongings($mainId, $otherId, $tables = FALSE, $tableOperations = array()) {
+ public static function moveContactBelongings($mainId, $otherId, $tables = FALSE, $tableOperations = array()) {
$cidRefs = self::cidRefs();
$eidRefs = self::eidRefs();
$cpTables = self::cpTables();
$cidRefs = self::cidRefs();
$eidRefs = self::eidRefs();
$cpTables = self::cpTables();
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise.
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise.
- static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $redirectForPerformance = FALSE) {
+ public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $redirectForPerformance = FALSE) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
$cacheKeyString = "merge {$contactType}";
$cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
$cacheKeyString = "merge {$contactType}";
$cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
- * @param array $dupePairs set of pair of contacts for whom merge is to be done.
- * @param array $cacheParams prev-next-cache params based on which next pair of contacts are computed.
+ * @param array $dupePairs
+ * Set of pair of contacts for whom merge is to be done.
+ * @param array $cacheParams
+ * Prev-next-cache params based on which next pair of contacts are computed.
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise (aggressive mode).
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise (aggressive mode).
- static function merge($dupePairs = array(), $cacheParams = array(), $mode = 'safe',
- $autoFlip = TRUE, $redirectForPerformance = FALSE
+ public static function merge($dupePairs = array(), $cacheParams = array(), $mode = 'safe',
+ $autoFlip = TRUE, $redirectForPerformance = FALSE
) {
$cacheKeyString = CRM_Utils_Array::value('cache_key_string', $cacheParams);
$resultStats = array('merged' => array(), 'skipped' => array());
) {
$cacheKeyString = CRM_Utils_Array::value('cache_key_string', $cacheParams);
$resultStats = array('merged' => array(), 'skipped' => array());
* A function which uses various rules / algorithms for choosing which contact to bias to
* when there's a conflict (to handle "gotchas"). Plus the safest route to merge.
*
* A function which uses various rules / algorithms for choosing which contact to bias to
* when there's a conflict (to handle "gotchas"). Plus the safest route to merge.
*
- * @param int $mainId main contact with whom merge has to happen
- * @param int $otherId duplicate contact which would be deleted after merge operation
- * @param array $migrationInfo array of information about which elements to merge.
- * @param string $mode helps decide how to behave when there are conflicts.
+ * @param int $mainId
+ * Main contact with whom merge has to happen.
+ * @param int $otherId
+ * Duplicate contact which would be deleted after merge operation.
+ * @param array $migrationInfo
+ * Array of information about which elements to merge.
+ * @param string $mode
+ * Helps decide how to behave when there are conflicts.
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise (aggressive mode).
*
* @return bool
* A 'safe' value skips the merge if there are any un-resolved conflicts.
* Does a force merge otherwise (aggressive mode).
*
* @return bool
- static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe') {
+ public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe') {
}
elseif ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) or
substr($key, 0, 12) == 'move_custom_'
}
elseif ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) or
substr($key, 0, 12) == 'move_custom_'
// Rule: if both main-contact has other-contact, let $mode decide if to merge a
// particular field or not
if (!empty($migrationInfo['rows'][$key]['main'])) {
// Rule: if both main-contact has other-contact, let $mode decide if to merge a
// particular field or not
if (!empty($migrationInfo['rows'][$key]['main'])) {
if ($fieldName == 'address') {
$mainNewLocTypeId = $migrationInfo['location'][$fieldName][$fieldCount]['locTypeId'];
if (!empty($migrationInfo['main_loc_address']) &&
if ($fieldName == 'address') {
$mainNewLocTypeId = $migrationInfo['location'][$fieldName][$fieldCount]['locTypeId'];
if (!empty($migrationInfo['main_loc_address']) &&
// main loc already has some address for the loc-type. Its a overwrite situation.
// look for next available loc-type
// main loc already has some address for the loc-type. Its a overwrite situation.
// look for next available loc-type
- * @param int $mainId main contact with whom merge has to happen
- * @param int $otherId duplicate contact which would be deleted after merge operation
+ * @param int $mainId
+ * Main contact with whom merge has to happen.
+ * @param int $otherId
+ * Duplicate contact which would be deleted after merge operation.
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
// Fetch contacts
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
// Fetch contacts
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
- $params = array('contact_id' => $cid, 'version' => 3, 'return' => array_merge(array('display_name'), self::getContactFields()));
+ $params = array(
+ 'contact_id' => $cid,
+ 'version' => 3,
+ 'return' => array_merge(array('display_name'), self::getContactFields()),
+ );
$result = civicrm_api('contact', 'get', $params);
if (empty($result['values'][$cid]['contact_type'])) {
$result = civicrm_api('contact', 'get', $params);
if (empty($result['values'][$cid]['contact_type'])) {
- if (!empty($contact['preferred_communication_method'])){
- // api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
- $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ?
- implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) :
- $specialValues[$moniker]['preferred_communication_method'];
+ if (!empty($contact['preferred_communication_method'])) {
+ // api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
+ $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : $specialValues[$moniker]['preferred_communication_method'];
'newName' => 'preferred_communication_method_display',
'groupName' => 'preferred_communication_method',
),
'newName' => 'preferred_communication_method_display',
'groupName' => 'preferred_communication_method',
),
- 'select', "location[{$name}][$count][locTypeId]", NULL,
- $defaultLocType + $locTypeValues, $js,
+ 'select',
+ "location[{$name}][$count][locTypeId]",
+ NULL,
+ $defaultLocType + $locTypeValues,
+ $js,
);
// keep location-type-id same as that of other-contact
$migrationInfo['location'][$name][$count]['locTypeId'] = $locTypeId;
);
// keep location-type-id same as that of other-contact
$migrationInfo['location'][$name][$count]['locTypeId'] = $locTypeId;
* other contact to the main one - be it Location / CustomFields or Contact .. related info.
* A superset of moveContactBelongings() function.
*
* other contact to the main one - be it Location / CustomFields or Contact .. related info.
* A superset of moveContactBelongings() function.
*
- * @param int $mainId main contact with whom merge has to happen
- * @param int $otherId duplicate contact which would be deleted after merge operation
+ * @param int $mainId
+ * Main contact with whom merge has to happen.
+ * @param int $otherId
+ * Duplicate contact which would be deleted after merge operation.
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPARATOR
if (in_array($htmlType, array(
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPARATOR
if (in_array($htmlType, array(
- 'Multi-Select Country', 'Multi-Select State/Province'))) {
+ 'Multi-Select Country',
+ 'Multi-Select State/Province',
+ ))) {
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
// move the other contact's file to main contact
//NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
// move the other contact's file to main contact
//NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
- if ( CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}") ) {
- $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
+ if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
+ $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
}
else {
$sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
}
CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
}
else {
$sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
}
CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
// CRM-15681 merge sub_types
if ($other_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['other_details'])) {
if ($main_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['main_details'])) {
// CRM-15681 merge sub_types
if ($other_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['other_details'])) {
if ($main_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['main_details'])) {
if ($currentEmloyerId = CRM_Utils_Array::value('current_employer_id', $submitted)) {
if (!CRM_Utils_System::isNull($currentEmloyerId)) {
$submitted['current_employer'] = $submitted['current_employer_id'];
if ($currentEmloyerId = CRM_Utils_Array::value('current_employer_id', $submitted)) {
if (!CRM_Utils_System::isNull($currentEmloyerId)) {
$submitted['current_employer'] = $submitted['current_employer_id'];
$submitted['current_employer'] = '';
}
unset($submitted['current_employer_id']);
}
//CRM-14312 include prefix/suffix from mainId if not overridden for proper construction of display/sort name
$submitted['current_employer'] = '';
}
unset($submitted['current_employer_id']);
}
//CRM-14312 include prefix/suffix from mainId if not overridden for proper construction of display/sort name
- $invalidFields = array('api_key', 'contact_is_deleted', 'created_date', 'display_name', 'hash', 'id', 'modified_date',
- 'primary_contact_id', 'sort_name', 'user_unique_id');
+ $invalidFields = array(
+ 'api_key',
+ 'contact_is_deleted',
+ 'created_date',
+ 'display_name',
+ 'hash',
+ 'id',
+ 'modified_date',
+ 'primary_contact_id',
+ 'sort_name',
+ 'user_unique_id',
+ );
foreach ($contactFields as $field => $value) {
if (in_array($field, $invalidFields)) {
unset($contactFields[$field]);
foreach ($contactFields as $field => $value) {
if (in_array($field, $invalidFields)) {
unset($contactFields[$field]);
'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date),
'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date),
'source' => $dao->source,
'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date),
'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date),
'source' => $dao->source,
);
// create/update membership(s) for related contact(s)
CRM_Member_BAO_Membership::createRelatedMemberships($membershipParams, $dao);
);
// create/update membership(s) for related contact(s)
CRM_Member_BAO_Membership::createRelatedMemberships($membershipParams, $dao);