X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FForm%2FMerge.php;h=170727e74df8d1349087f483ca6095699e2f1c71;hb=91c0d0d891ebf3174f34feb6983fce71d46542f0;hp=61cbf0df793bf1a3c4ab46c63c15c45291fc0b51;hpb=61ac5f959d775677c6eadffed193fde1d815eac4;p=civicrm-core.git diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index 61cbf0df79..170727e74d 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -34,6 +34,10 @@ */ require_once 'api/api.php'; + +/** + * Class CRM_Contact_Form_Merge + */ class CRM_Contact_Form_Merge extends CRM_Core_Form { // the id of the contact that tere's a duplicate for; this one will // possibly inherit some of $_oid's properties and remain in the system @@ -67,6 +71,11 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE); $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE); + // Sanity check + if ($cid == $oid) { + CRM_Core_Error::statusBounce(ts('Cannot merge a contact with itself.')); + } + if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) { CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the Dedupe Exceptions page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1')))); } @@ -190,19 +199,7 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { CRM_Core_Error::fatal(ts('The other contact record does not exist')); } - $subtypes = CRM_Contact_BAO_ContactType::subTypePairs(NULL, TRUE, ''); - $this->assign('contact_type', $main['contact_type']); - if (!empty($main['contact_sub_type'])) { - $this->assign('main_contact_subtype', - CRM_Utils_Array::value('contact_sub_type', $subtypes[$main['contact_sub_type'][0]]) - ); - } - if (!empty($other['contact_sub_type'])) { - $this->assign('other_contact_subtype', - CRM_Utils_Array::value('contact_sub_type', $subtypes[$other['contact_sub_type'][0]]) - ); - } $this->assign('main_name', $main['display_name']); $this->assign('other_name', $other['display_name']); $this->assign('main_cid', $main['contact_id']); @@ -244,6 +241,18 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $this->assign('userContextURL', $session->readUserContext()); } + /** + * This virtual function is used to set the default values of + * various form elements + * + * access public + * + * @return array reference to the array of default values + * + */ + /** + * @return array + */ function setDefaultValues() { return array('deleteOther' => 1); } @@ -296,6 +305,13 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $this->addFormRule(array('CRM_Contact_Form_Merge', 'formRule'), $this); } + /** + * @param $fields + * @param $files + * @param $self + * + * @return array + */ static function formRule($fields, $files, $self) { $errors = array(); $link = CRM_Utils_System::href(ts('Flip between the original and duplicate contacts.'), @@ -323,7 +339,10 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { CRM_Dedupe_Merger::moveAllBelongings($this->_cid, $this->_oid, $formValues); - CRM_Core_Session::setStatus(ts('Contact id %1 has been updated and contact id %2 has been deleted.', array(1 => $this->_cid, 2 => $this->_oid)), ts('Contacts Merged'), 'success'); + $name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_cid, 'display_name'); + $message = ''; + CRM_Core_Session::setStatus($message, ts('Contacts Merged'), 'success'); + $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_cid}"); if (!empty($formValues['_qf_Merge_submit'])) { $listParamsURL = "reset=1&action=update&rgid={$this->_rgid}";