Skip to content

Commit

Permalink
Merge pull request #15594 from eileenmcnaughton/dedupe2
Browse files Browse the repository at this point in the history
[REF] minor refactor towards removing complexity.
  • Loading branch information
mattwire authored Oct 25, 2019
2 parents 6b5dfd1 + bdc6e6e commit 55af4b2
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,36 +1091,34 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
// CRM-15681 don't display sub-types in UI
continue;
}
foreach (['main' => $main, 'other' => $other] as $moniker => $contact) {
list($label, $value) = self::getFieldValueAndLabel($field, $contact);
$rows["move_$field"][$moniker] = $label;
if ($moniker == 'other') {
//CRM-14334
if ($value === NULL || $value == '') {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $qfZeroBug;
}
if (is_array($value) && empty($value[1])) {
$value[1] = NULL;
}
$rows["move_$field"]['main'] = self::getFieldValueAndLabel($field, $main)['label'];
$rows["move_$field"]['other'] = self::getFieldValueAndLabel($field, $other)['label'];

// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
$elements[] = [
'advcheckbox',
"move_$field",
NULL,
NULL,
NULL,
$value,
];
}
$value = self::getFieldValueAndLabel($field, $other)['value'];
//CRM-14334
if ($value === NULL || $value == '') {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $qfZeroBug;
}
if (is_array($value) && empty($value[1])) {
$value[1] = NULL;
}

$migrationInfo["move_$field"] = $value;
}
// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
$elements[] = [
'advcheckbox',
"move_$field",
NULL,
NULL,
NULL,
$value,
];
}

$migrationInfo["move_$field"] = $value;
$rows["move_$field"]['title'] = $fields[$field]['title'];
}

Expand Down Expand Up @@ -2524,7 +2522,7 @@ private static function getFieldValueAndLabel($field, $contact): array {
elseif ($field == 'current_employer_id' && !empty($value)) {
$label = "$value (" . CRM_Contact_BAO_Contact::displayName($value) . ")";
}
return [$label, $value];
return ['label' => $label, 'value' => $value];
}

/**
Expand Down

0 comments on commit 55af4b2

Please sign in to comment.