Beispiel #1
0
 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  */
 public function preProcess()
 {
     //fetch the dedupe exception contacts.
     $dedupeExceptions = array();
     $exception = new CRM_Dedupe_DAO_Exception();
     $exception->find();
     $contactIds = array();
     while ($exception->fetch()) {
         $key = "{$exception->contact_id1}_{$exception->contact_id2}";
         $contactIds[$exception->contact_id1] = $exception->contact_id1;
         $contactIds[$exception->contact_id2] = $exception->contact_id2;
         $dedupeExceptions[$key] = array('main' => array('id' => $exception->contact_id1), 'other' => array('id' => $exception->contact_id2));
     }
     //get the dupe contacts display names.
     if (!empty($dedupeExceptions)) {
         $sql = 'select id, display_name from civicrm_contact where id IN ( ' . implode(', ', $contactIds) . ' )';
         $contact = CRM_Core_DAO::executeQuery($sql);
         $displayNames = array();
         while ($contact->fetch()) {
             $displayNames[$contact->id] = $contact->display_name;
         }
         foreach ($dedupeExceptions as $key => &$values) {
             $values['main']['name'] = CRM_Utils_Array::value($values['main']['id'], $displayNames);
             $values['other']['name'] = CRM_Utils_Array::value($values['other']['id'], $displayNames);
         }
     }
     $this->assign('dedupeExceptions', $dedupeExceptions);
 }
Beispiel #2
0
 /**
  * Process dupes.
  */
 public static function processDupes()
 {
     $oper = CRM_Utils_Type::escape($_REQUEST['op'], 'String');
     $cid = CRM_Utils_Type::escape($_REQUEST['cid'], 'Positive');
     $oid = CRM_Utils_Type::escape($_REQUEST['oid'], 'Positive');
     if (!$oper || !$cid || !$oid) {
         return;
     }
     $exception = new CRM_Dedupe_DAO_Exception();
     $exception->contact_id1 = $cid;
     $exception->contact_id2 = $oid;
     //make sure contact2 > contact1.
     if ($cid > $oid) {
         $exception->contact_id1 = $oid;
         $exception->contact_id2 = $cid;
     }
     $exception->find(TRUE);
     $status = NULL;
     if ($oper == 'dupe-nondupe') {
         $status = $exception->save();
     }
     if ($oper == 'nondupe-dupe') {
         $status = $exception->delete();
     }
     CRM_Utils_JSON::output(array('status' => $status ? $oper : $status));
 }
 function validateContacts($cid, $oid)
 {
     if (!$cid || !$oid) {
         return;
     }
     $exception = new CRM_Dedupe_DAO_Exception();
     $exception->contact_id1 = $cid;
     $exception->contact_id2 = $oid;
     //make sure contact2 > contact1.
     if ($cid > $oid) {
         $exception->contact_id1 = $oid;
         $exception->contact_id2 = $cid;
     }
     return $exception->find(TRUE) ? FALSE : TRUE;
 }
Beispiel #4
0
 function validateContacts($cid, $oid)
 {
     if (!$cid || !$oid) {
         return;
     }
     require_once 'CRM/Dedupe/DAO/Exception.php';
     $exception = new CRM_Dedupe_DAO_Exception();
     $exception->contact_id1 = $cid;
     $exception->contact_id2 = $oid;
     //make sure contact2 > contact1.
     if ($cid > $oid) {
         $exception->contact_id1 = $oid;
         $exception->contact_id2 = $cid;
     }
     if ($exception->find(true)) {
         CRM_Core_Error::fatal(ts('Oops, these contacts seems to be marked as non duplicates.'));
     }
 }
Beispiel #5
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  * @static
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['dedupe_exception'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
Beispiel #6
0
 /**
  * Function to process dupes.
  *
  */
 static function processDupes()
 {
     $oper = CRM_Utils_Type::escape($_POST['op'], 'String');
     $cid = CRM_Utils_Type::escape($_POST['cid'], 'Positive');
     $oid = CRM_Utils_Type::escape($_POST['oid'], 'Positive');
     if (!$oper || !$cid || !$oid) {
         return;
     }
     require_once 'CRM/Dedupe/DAO/Exception.php';
     $exception = new CRM_Dedupe_DAO_Exception();
     $exception->contact_id1 = $cid;
     $exception->contact_id2 = $oid;
     //make sure contact2 > contact1.
     if ($cid > $oid) {
         $exception->contact_id1 = $oid;
         $exception->contact_id2 = $cid;
     }
     $exception->find(true);
     $status = null;
     if ($oper == 'dupe-nondupe') {
         $status = $exception->save();
     }
     if ($oper == 'nondupe-dupe') {
         $status = $exception->delete();
     }
     echo json_encode(array('status' => $status ? $oper : $status));
     CRM_Utils_System::civiExit();
 }