* 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).
+ * - A 'safe' value skips the merge if there are any un-resolved conflicts.
+ * - Does a force merge otherwise (aggressive mode).
*
* @param array $conflicts
*
$allPhoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$allProviderTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$allWebsiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
+ $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
// Fetch contacts
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
$rows = $elements = $relTableElements = $migrationInfo = array();
- $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
-
foreach ($compareFields['contact'] as $field) {
if ($field == 'contact_sub_type') {
// CRM-15681 don't display sub-types in UI
if (is_array($value) && empty($value[1])) {
$value[1] = NULL;
}
- $elements[] = array('advcheckbox', "move_$field", NULL, NULL, NULL, $value);
+
+ // Display a checkbox to migrate, only if the values are different
+ if ($value != $main[$field]) {
+ $elements[] = array('advcheckbox', "move_$field", NULL, NULL, NULL, $value);
+ }
+
$migrationInfo["move_$field"] = $value;
}
}
// Handle location blocks.
// @todo OpenID not in API yet, so is not supported here.
- $locationBlocks = array('Address', 'Email', 'IM', 'Phone', 'Website');
+ $locationBlocks = array(
+ 'address' => 'Address',
+ 'email' => 'Email',
+ 'im' => 'IM',
+ 'phone' => 'Phone',
+ 'website' => 'Website',
+ );
$locations = array();
- foreach ($locationBlocks as $block) {
- $blockName = strtolower($block);
+ foreach ($locationBlocks as $blockName => $block) {
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
$cnt = 1;
$searchParams = array(
'contact_id' => $cid,
);
// CRM-17556 Order by location and type
- // @todo Temporary fix for websites (no location, only type)
+ // Handle websites (no location, only type)
if ($blockName == 'website') {
$searchParams['options'] = array('sort' => 'website_type_id');
}
$locBlockIds['main'] = $locBlockIds['other'] = array();
$typeBlockIds['main'] = $typeBlockIds['other'] = array();
- foreach ($locationBlocks as $block) {
+ foreach ($locationBlocks as $blockName => $block) {
$name = strtolower($block);
foreach (array('main', 'other') as $moniker) {
$locIndex = CRM_Utils_Array::value($moniker, $locations);
$elements[] = array('advcheckbox', "move_location_{$name}_{$count}");
// Add location select list for location block (websites don't have a location)
- // @todo make sure websites can be migrated as well
if ($name != 'website') {
$migrationInfo["move_location_{$name}_{$count}"] = 1;
// make sure default location type is always on top
}
// **** Do location related migration.
- // @todo Handle websites.
// @todo Handle OpenID (not currently in API).
if (!empty($locBlocks)) {
- $locComponent = array(
+
+ $locationBlocks = array(
+ 'address' => 'Address',
'email' => 'Email',
- 'phone' => 'Phone',
'im' => 'IM',
- 'address' => 'Address',
+ 'phone' => 'Phone',
'website' => 'Website',
);
if (!is_array($block) || CRM_Utils_System::isNull($block)) {
continue;
}
- $daoName = 'CRM_Core_DAO_' . $locComponent[$name];
+ $daoName = 'CRM_Core_DAO_' . $locationBlocks[$name];
$primaryDAOId = (array_key_exists($name, $primaryBlockIds)) ? array_pop($primaryBlockIds[$name]) : NULL;
$billingDAOId = (array_key_exists($name, $billingBlockIds)) ? array_pop($billingBlockIds[$name]) : NULL;
$idKey = $blkCount;
if (
$name != 'website'
- && array_key_exists($name, $locComponent)
+ && array_key_exists($name, $locationBlocks)
) {
$idKey = $locTypeId;
}
{crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid}
- <tr style="background-color: #FFFFCC !important; border-bottom:1px solid #ccc !important;">
+ <tr>
<td>Last modified</td>
<td>{$other_result.values.0.modified_date|date_format:"%d/%m/%y %H:%M:%S"} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if}</td>
<td></td>
</td>
{else}
{if $row.main eq $row.other}
- <tr style="background-color: #EFFFE7 !important; border-bottom:1px solid #ccc !important;" class="equal-data {cycle values="odd-row,even-row"}">
+ <tr class="merge-row-equal {cycle values="odd-row,even-row"}">
{else}
- <tr style="background-color: #FFECEC !important; border-bottom:1px solid #ccc !important;" class="diff-data {cycle values="odd-row,even-row"}">
+ <tr class="merge-row-diff {cycle values="odd-row,even-row"}">
{/if}
<td>
{$row.title}
<td>
{if isset($row.main) || isset($row.other)}
<span id="main_{$blockName}_{$blockId}_overwrite">
- {if $row.main}
+ {if $row.main == $row.other}
+ <span class="action_label">(match)</span><br />
+ {elseif $row.main}
<span class="action_label">(overwrite)</span><br />
{else}
<span class="action_label">(add)</span>
// Show/hide matching data rows
$('.toggle_equal_rows').click(function() {
- $('tr.equal-data').toggle();
+ $('tr.merge-row-equal').toggle();
});
});