From 3d1d395a6b6c8c3836cead048a0d101d614b4324 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 24 Oct 2019 16:28:29 +1300 Subject: [PATCH] dev/core#1339 Dedupe screen check to carry across any data where the other contact has none by default. This change in default means that if the contact to be deleted has data in a field and the contact to be kept does not the checkbox loads as checked by default (so it's easier to keep too much data but harder to lose some.) https://lab.civicrm.org/dev/core/issues/1339 The user can override by unchecking - this is just what is set on screen load --- CRM/Contact/Form/Merge.php | 5 ++++- CRM/Dedupe/Merger.php | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index da804021ea..2cab779d1a 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -225,13 +225,16 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { // @todo consider enabling if it is an add & defaulting to true. $element[4] = array_merge((array) CRM_Utils_Array::value(4, $element, []), ['disabled' => TRUE]); } - $this->addElement($element[0], + $newCheckBox = $this->addElement($element[0], $element[1], array_key_exists('2', $element) ? $element[2] : NULL, array_key_exists('3', $element) ? $element[3] : NULL, array_key_exists('4', $element) ? $element[4] : NULL, array_key_exists('5', $element) ? $element[5] : NULL ); + if (!empty($element['is_checked'])) { + $newCheckBox->setChecked(TRUE); + } } // add related table elements diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 339338bf2a..5eeb90c848 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1109,12 +1109,13 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m // Display a checkbox to migrate, only if the values are different if ($value != $main[$field]) { $elements[] = [ - 'advcheckbox', - "move_$field", - NULL, - NULL, - NULL, - $value, + 0 => 'advcheckbox', + 1 => "move_$field", + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => $value, + 'is_checked' => (!isset($main[$field]) || $main[$field] === ''), ]; } -- 2.25.1