<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
// see HTML_QuickForm_advcheckbox::setValues() - but patching that doesn't
// help, as QF doesn't put the 0-value elements in exportValues() anyway...
// to side-step this, we use the below UUID as a (re)placeholder
- var $_qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
-
+ var $_qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
+
function preProcess() {
if (!CRM_Core_Permission::check('merge duplicate contacts')) {
CRM_Core_Error::fatal(ts('You do not have access to this page'));
$cacheKey .= $rgid ? "_{$rgid}" : '_0';
$cacheKey .= $gid ? "_{$gid}" : '_0';
- $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
+ $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
pn.entity_id2 = de.contact_id2 )";
$where = "de.id IS NULL";
$this->assign('mainUfName', $mainUser ? $mainUser->name : NULL);
}
- $flipUrl = CRM_Utils_system::url('civicrm/contact/merge',
+ $flipUrl = CRM_Utils_System::url('civicrm/contact/merge',
"reset=1&action=update&cid={$oid}&oid={$cid}&rgid={$rgid}&gid={$gid}"
);
if (!$flip) {
$urlParam .= "&gid={$gid}";
}
- $this->$position = CRM_Utils_system::url('civicrm/contact/merge', $urlParam);
+ $this->$position = CRM_Utils_System::url('civicrm/contact/merge', $urlParam);
$this->assign($position, $this->$position);
}
}
if ($gid) {
$urlParam .= "&gid={$gid}";
}
- $session->pushUserContext(CRM_Utils_system::url('civicrm/contact/dedupefind', $urlParam));
+ $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParam));
}
// ensure that oid is not the current user, if so refuse to do the merge
$this->assign('other_name', $other['display_name']);
$this->assign('main_cid', $main['contact_id']);
$this->assign('other_cid', $other['contact_id']);
+ $this->assign('rgid', $rgid);
$this->_cid = $cid;
$this->_oid = $oid;
}
$this->addButtons($button);
+ $this->addFormRule(array('CRM_Contact_Form_Merge', 'formRule'), $this);
+ }
+
+ static function formRule($fields, $files, $self) {
+ $errors = array();
+ $link = CRM_Utils_System::href(ts('Flip between the original and duplicate contacts.'),
+ 'civicrm/contact/merge',
+ 'reset=1&action=update&cid=' . $self->_oid . '&oid=' . $self->_cid . '&rgid=' . $self->_rgid . '&flip=1'
+ );
+ if (CRM_Contact_BAO_Contact::checkDomainContact($self->_oid)) {
+ $errors['_qf_default'] = ts("The Default Organization 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: %1", array(1 => $link));
+ }
+ return $errors;
}
public function postProcess() {
$formValues = $this->exportValues();
-
+
// reset all selected contact ids from session
// when we came from search context, CRM-3526
$session = CRM_Core_Session::singleton();
$cacheKey .= $this->_rgid ? "_{$this->_rgid}" : '_0';
$cacheKey .= $this->_gid ? "_{$this->_gid}" : '_0';
- $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
+ $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
pn.entity_id2 = de.contact_id2 )";
$where = "de.id IS NULL";
$urlParam .= "&gid={$this->_gid}";
}
- $url = CRM_Utils_system::url('civicrm/contact/merge', $urlParam);
+ $url = CRM_Utils_System::url('civicrm/contact/merge', $urlParam);
}
}