CRM-13780 fix - Don't allow users to attempt to merge the Default Organization into...
authormonishdeb <monish.deb@webaccess.co.in>
Mon, 18 Nov 2013 13:49:46 +0000 (19:19 +0530)
committermonishdeb <monish.deb@webaccess.co.in>
Tue, 19 Nov 2013 09:06:56 +0000 (14:36 +0530)
http://issues.civicrm.org/jira/browse/CRM-13780

CRM/Contact/Form/Merge.php

index c305672e4397ad52de7c6bee639926d623f5cdf1..c0fc66d172f8263bea557612b1e6601b02991285 100644 (file)
@@ -293,6 +293,15 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
     }
 
     $this->addButtons($button);
+    $this->addFormRule(array('CRM_Contact_Form_Merge', 'formRule'), $this);
+  }
+
+  static function formRule($fields, $files, $self) {
+    $errors = array();
+    if (CRM_Contact_BAO_Contact::checkDomainContact($self->_oid)) {
+      $errors['_qf_default'] = ts("The <b>Default Organization</b> contact cannot be merged into another contact record. It is associated with the CiviCRM installation for this domain and contains information used for system functions. If you want to merge these records, you can click the link to <a class='action-item action-item-first' href=%1>Flip between the original and duplicate contacts</a> and then continue with the merge.", array(1 => CRM_Utils_System::url('civicrm/contact/merge', 'reset=1&action=update&cid=' . $self->_oid . '&oid=' . $self->_cid . '&rgid=' . $self->_rgid . '&flip=1')));
+    }
+    return $errors;
   }
 
   public function postProcess() {