当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Dedupe_BAO_Rule类代码示例

本文整理汇总了PHP中CRM_Dedupe_BAO_Rule的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Dedupe_BAO_Rule类的具体用法?PHP CRM_Dedupe_BAO_Rule怎么用?PHP CRM_Dedupe_BAO_Rule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CRM_Dedupe_BAO_Rule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * Combine all the importable fields from the lower levels object.
  *
  * @param string $contactType
  * @param bool $status
  * @param bool $onlyParticipant
  * @param bool $checkPermission
  *   Is this a permissioned retrieval?
  *
  * @return array
  *   array of importable Fields
  */
 public static function &importableFields($contactType = 'Individual', $status = TRUE, $onlyParticipant = FALSE, $checkPermission = TRUE)
 {
     if (!self::$_importableFields) {
         if (!$onlyParticipant) {
             if (!$status) {
                 $fields = array('' => array('title' => ts('- do not import -')));
             } else {
                 $fields = array('' => array('title' => ts('- Participant Fields -')));
             }
         } else {
             $fields = array();
         }
         $tmpFields = CRM_Event_DAO_Participant::import();
         $note = array('participant_note' => array('title' => ts('Participant Note'), 'name' => 'participant_note', 'headerPattern' => '/(participant.)?note$/i'));
         // Split status and status id into 2 fields
         // Fixme: it would be better to leave as 1 field and intelligently handle both during import
         $participantStatus = array('participant_status' => array('title' => ts('Participant Status'), 'name' => 'participant_status', 'data_type' => CRM_Utils_Type::T_STRING));
         $tmpFields['participant_status_id']['title'] = ts('Participant Status Id');
         // Split role and role id into 2 fields
         // Fixme: it would be better to leave as 1 field and intelligently handle both during import
         $participantRole = array('participant_role' => array('title' => ts('Participant Role'), 'name' => 'participant_role', 'data_type' => CRM_Utils_Type::T_STRING));
         $tmpFields['participant_role_id']['title'] = ts('Participant Role Id');
         $eventType = array('event_type' => array('title' => ts('Event Type'), 'name' => 'event_type', 'data_type' => CRM_Utils_Type::T_STRING));
         $tmpContactField = $contactFields = array();
         $contactFields = array();
         if (!$onlyParticipant) {
             $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
             // Using new Dedupe rule.
             $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
             $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
             if (is_array($fieldsArray)) {
                 foreach ($fieldsArray as $value) {
                     $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
                     $value = $customFieldId ? 'custom_' . $customFieldId : $value;
                     $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
                     if (!$status) {
                         $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)';
                     } else {
                         $title = $tmpContactField[trim($value)]['title'];
                     }
                     $tmpContactField[trim($value)]['title'] = $title;
                 }
             }
         }
         $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields);
         if ($extIdentifier) {
             $tmpContactField['external_identifier'] = $extIdentifier;
             $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
         }
         $tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . ' (match to contact)';
         $fields = array_merge($fields, $tmpContactField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, $note, $participantStatus, $participantRole, $eventType);
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant', FALSE, FALSE, FALSE, $checkPermission));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:70,代码来源:Participant.php

示例2: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @param NULL
  * 
  * @return array    array of importable Fields
  * @access public
  */
 function &importableFields()
 {
     if (!self::$_importableFields) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         if (!$status) {
             $fields = array('' => array('title' => ts('- do not import -')));
         } else {
             $fields = array('' => array('title' => ts('- Activity Fields -')));
         }
         require_once 'CRM/Activity/DAO/Activity.php';
         $tmpFields = CRM_Activity_DAO_Activity::import();
         require_once 'CRM/Contact/BAO/Contact.php';
         $contactFields = CRM_Contact_BAO_Contact::importableFields('Individual', null);
         // Using new Dedupe rule.
         $ruleParams = array('contact_type' => 'Individual', 'level' => 'Strict');
         require_once 'CRM/Dedupe/BAO/Rule.php';
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
         $tmpConatctField = array();
         if (is_array($fieldsArray)) {
             foreach ($fieldsArray as $value) {
                 $tmpConatctField[trim($value)] = $contactFields[trim($value)];
                 $tmpConatctField[trim($value)]['title'] = $tmpConatctField[trim($value)]['title'] . " (match to contact)";
             }
         }
         $tmpConatctField['external_identifier'] = $contactFields['external_identifier'];
         $tmpConatctField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " (match to contact)";
         $fields = array_merge($fields, $tmpConatctField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Activity'));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:47,代码来源:Activity.php

示例3: array

 /**
  * Combine all the importable fields from the lower levels object.
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @param string $contactType
  * @param bool $status
  *
  * @return array
  *   array of importable Fields
  */
 public static function &importableFields($contactType = 'Individual', $status = TRUE)
 {
     if (!self::$_importableFields) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         if (!$status) {
             $fields = array('' => array('title' => ts('- do not import -')));
         } else {
             $fields = array('' => array('title' => ts('- Contribution Fields -')));
         }
         $note = CRM_Core_DAO_Note::import();
         $tmpFields = CRM_Contribute_DAO_Contribution::import();
         unset($tmpFields['option_value']);
         $optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
         $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
         // Using new Dedupe rule.
         $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
         $tmpContactField = array();
         if (is_array($fieldsArray)) {
             foreach ($fieldsArray as $value) {
                 //skip if there is no dupe rule
                 if ($value == 'none') {
                     continue;
                 }
                 $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
                 $value = $customFieldId ? 'custom_' . $customFieldId : $value;
                 $tmpContactField[trim($value)] = $contactFields[trim($value)];
                 if (!$status) {
                     $title = $tmpContactField[trim($value)]['title'] . ' ' . ts('(match to contact)');
                 } else {
                     $title = $tmpContactField[trim($value)]['title'];
                 }
                 $tmpContactField[trim($value)]['title'] = $title;
             }
         }
         $tmpContactField['external_identifier'] = $contactFields['external_identifier'];
         $tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . ' ' . ts('(match to contact)');
         $tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . ' ' . ts('(match to contact)');
         $fields = array_merge($fields, $tmpContactField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, $note);
         $fields = array_merge($fields, $optionFields);
         $fields = array_merge($fields, CRM_Financial_DAO_FinancialType::export());
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:63,代码来源:Contribution.php

示例4: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @return array array of importable Fields
  * @access public
  */
 function &importableFields($contacType = 'Individual', $status = true)
 {
     if (!self::$_importableFields) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         if (!$status) {
             $fields = array('' => array('title' => ts('- do not import -')));
         } else {
             $fields = array('' => array('title' => ts('- Contribution Fields -')));
         }
         require_once 'CRM/Core/DAO/Note.php';
         $note = CRM_Core_DAO_Note::import();
         $tmpFields = CRM_Contribute_DAO_Contribution::import();
         unset($tmpFields['option_value']);
         require_once 'CRM/Core/OptionValue.php';
         $optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
         require_once 'CRM/Contact/BAO/Contact.php';
         $contactFields = CRM_Contact_BAO_Contact::importableFields($contacType, null);
         // Using new Dedupe rule.
         $ruleParams = array('contact_type' => $contacType, 'level' => 'Strict');
         require_once 'CRM/Dedupe/BAO/Rule.php';
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
         $tmpConatctField = array();
         if (is_array($fieldsArray)) {
             foreach ($fieldsArray as $value) {
                 //skip if there is no dupe rule
                 if ($value == 'none') {
                     continue;
                 }
                 $tmpConatctField[trim($value)] = $contactFields[trim($value)];
                 if (!$status) {
                     $title = $tmpConatctField[trim($value)]['title'] . " (match to contact)";
                 } else {
                     $title = $tmpConatctField[trim($value)]['title'];
                 }
                 $tmpConatctField[trim($value)]['title'] = $title;
             }
         }
         $tmpConatctField['external_identifier'] = $contactFields['external_identifier'];
         $tmpConatctField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " (match to contact)";
         $tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . " (match to contact)";
         $fields = array_merge($fields, $tmpConatctField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, $note);
         $fields = array_merge($fields, $optionFields);
         require_once 'CRM/Contribute/DAO/ContributionType.php';
         $fields = array_merge($fields, CRM_Contribute_DAO_ContributionType::export());
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Contribution.php

示例5: import


//.........这里部分代码省略.........
     if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
         $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, NULL, 'Participant');
     } else {
         if ($formatValues['participant_id']) {
             $dao = new CRM_Event_BAO_Participant();
             $dao->id = $formatValues['participant_id'];
             $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, $formatValues['participant_id'], 'Participant');
             if ($dao->find(TRUE)) {
                 $ids = array('participant' => $formatValues['participant_id'], 'userId' => $session->get('userID'));
                 $participantValues = array();
                 //@todo calling api functions directly is not supported
                 $newParticipant = _civicrm_api3_deprecated_participant_check_params($formatted, $participantValues, FALSE);
                 if ($newParticipant['error_message']) {
                     array_unshift($values, $newParticipant['error_message']);
                     return CRM_Import_Parser::ERROR;
                 }
                 $newParticipant = CRM_Event_BAO_Participant::create($formatted, $ids);
                 if (!empty($formatted['fee_level'])) {
                     $otherParams = array('fee_label' => $formatted['fee_level'], 'event_id' => $newParticipant->event_id);
                     CRM_Price_BAO_LineItem::syncLineItems($newParticipant->id, 'civicrm_participant', $newParticipant->fee_amount, $otherParams);
                 }
                 $this->_newParticipant[] = $newParticipant->id;
                 return CRM_Import_Parser::VALID;
             } else {
                 array_unshift($values, 'Matching Participant record not found for Participant ID ' . $formatValues['participant_id'] . '. Row was skipped.');
                 return CRM_Import_Parser::ERROR;
             }
         }
     }
     if ($this->_contactIdIndex < 0) {
         //retrieve contact id using contact dedupe rule
         $formatValues['contact_type'] = $this->_contactType;
         $formatValues['version'] = 3;
         $error = _civicrm_api3_deprecated_check_contact_dedupe($formatValues);
         if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
             $matchedIDs = explode(',', $error['error_message']['params'][0]);
             if (count($matchedIDs) >= 1) {
                 foreach ($matchedIDs as $contactId) {
                     $formatted['contact_id'] = $contactId;
                     $formatted['version'] = 3;
                     $newParticipant = _civicrm_api3_deprecated_create_participant_formatted($formatted, $onDuplicate);
                 }
             }
         } else {
             // Using new Dedupe rule.
             $ruleParams = array('contact_type' => $this->_contactType, 'used' => 'Unsupervised');
             $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
             $disp = '';
             foreach ($fieldsArray as $value) {
                 if (array_key_exists(trim($value), $params)) {
                     $paramValue = $params[trim($value)];
                     if (is_array($paramValue)) {
                         $disp .= $params[trim($value)][0][trim($value)] . " ";
                     } else {
                         $disp .= $params[trim($value)] . " ";
                     }
                 }
             }
             if (!empty($params['external_identifier'])) {
                 if ($disp) {
                     $disp .= "AND {$params['external_identifier']}";
                 } else {
                     $disp = $params['external_identifier'];
                 }
             }
             array_unshift($values, 'No matching Contact found for (' . $disp . ')');
             return CRM_Import_Parser::ERROR;
         }
     } else {
         if (!empty($formatValues['external_identifier'])) {
             $checkCid = new CRM_Contact_DAO_Contact();
             $checkCid->external_identifier = $formatValues['external_identifier'];
             $checkCid->find(TRUE);
             if ($checkCid->id != $formatted['contact_id']) {
                 array_unshift($values, 'Mismatch of External ID:' . $formatValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
                 return CRM_Import_Parser::ERROR;
             }
         }
         $newParticipant = _civicrm_api3_deprecated_create_participant_formatted($formatted, $onDuplicate);
     }
     if (is_array($newParticipant) && civicrm_error($newParticipant)) {
         if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP) {
             $contactID = CRM_Utils_Array::value('contactID', $newParticipant);
             $participantID = CRM_Utils_Array::value('participantID', $newParticipant);
             $url = CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&id={$participantID}&cid={$contactID}&action=view", TRUE);
             if (is_array($newParticipant['error_message']) && $participantID == $newParticipant['error_message']['params'][0]) {
                 array_unshift($values, $url);
                 return CRM_Import_Parser::DUPLICATE;
             } elseif ($newParticipant['error_message']) {
                 array_unshift($values, $newParticipant['error_message']);
                 return CRM_Import_Parser::ERROR;
             }
             return CRM_Import_Parser::ERROR;
         }
     }
     if (!(is_array($newParticipant) && civicrm_error($newParticipant))) {
         $this->_newParticipants[] = CRM_Utils_Array::value('id', $newParticipant);
     }
     return CRM_Import_Parser::VALID;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:Participant.php

示例6: preProcess

 function preProcess()
 {
     if (!CRM_Core_Permission::check('merge duplicate contacts')) {
         CRM_Core_Error::fatal(ts('You do not have access to this page'));
     }
     $rows = array();
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, TRUE);
     $flip = CRM_Utils_Request::retrieve('flip', 'Positive', $this, FALSE);
     $this->_rgid = $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE);
     $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE);
     $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE);
     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 <a href=\'%1\'>Dedupe Exceptions</a> page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1'))));
     }
     //load cache mechanism
     $contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'contact_type');
     $cacheKey = "merge {$contactType}";
     $cacheKey .= $rgid ? "_{$rgid}" : '_0';
     $cacheKey .= $gid ? "_{$gid}" : '_0';
     $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND\n                                                             pn.entity_id2 = de.contact_id2 )";
     $where = "de.id IS NULL";
     $pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $cid, $oid, $this->_mergeId, $join, $where, $flip);
     // Block access if user does not have EDIT permissions for both contacts.
     if (!(CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT) && CRM_Contact_BAO_Contact_Permission::allow($oid, CRM_Core_Permission::EDIT))) {
         CRM_Utils_System::permissionDenied();
     }
     // get user info of main contact.
     $config = CRM_Core_Config::singleton();
     $config->doNotResetCache = 1;
     $viewUser = CRM_Core_Permission::check('access user profiles');
     $mainUfId = CRM_Core_BAO_UFMatch::getUFId($cid);
     $mainUser = NULL;
     if ($mainUfId) {
         // d6 compatible
         if ($config->userSystem->is_drupal == '1') {
             $mainUser = user_load($mainUfId);
         } elseif ($config->userFramework == 'Joomla') {
             $mainUser = JFactory::getUser($mainUfId);
         }
         $this->assign('mainUfId', $mainUfId);
         $this->assign('mainUfName', $mainUser ? $mainUser->name : NULL);
     }
     $flipUrl = CRM_Utils_System::url('civicrm/contact/merge', "reset=1&action=update&cid={$oid}&oid={$cid}&rgid={$rgid}&gid={$gid}");
     if (!$flip) {
         $flipUrl .= '&flip=1';
     }
     $this->assign('flip', $flipUrl);
     $this->prev = $this->next = NULL;
     foreach (array('prev', 'next') as $position) {
         if (!empty($pos[$position])) {
             if ($pos[$position]['id1'] && $pos[$position]['id2']) {
                 $urlParam = "reset=1&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update";
                 if ($rgid) {
                     $urlParam .= "&rgid={$rgid}";
                 }
                 if ($gid) {
                     $urlParam .= "&gid={$gid}";
                 }
                 $this->{$position} = CRM_Utils_System::url('civicrm/contact/merge', $urlParam);
                 $this->assign($position, $this->{$position});
             }
         }
     }
     // get user info of other contact.
     $otherUfId = CRM_Core_BAO_UFMatch::getUFId($oid);
     $otherUser = NULL;
     if ($otherUfId) {
         // d6 compatible
         if ($config->userSystem->is_drupal == '1') {
             $otherUser = user_load($otherUfId);
         } elseif ($config->userFramework == 'Joomla') {
             $otherUser = JFactory::getUser($otherUfId);
         }
         $this->assign('otherUfId', $otherUfId);
         $this->assign('otherUfName', $otherUser ? $otherUser->name : NULL);
     }
     $cmsUser = $mainUfId && $otherUfId ? TRUE : FALSE;
     $this->assign('user', $cmsUser);
     $session = CRM_Core_Session::singleton();
     // context fixed.
     if ($rgid) {
         $urlParam = "reset=1&action=browse&rgid={$rgid}";
         if ($gid) {
             $urlParam .= "&gid={$gid}";
         }
         $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
     if ($session->get('userID') == $oid) {
         $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $oid, 'display_name');
         $message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', array(1 => $display_name));
         CRM_Core_Error::statusBounce($message);
     }
     $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($cid, $oid);
     $main =& $rowsElementsAndInfo['main_details'];
     $other =& $rowsElementsAndInfo['other_details'];
     if ($main['contact_id'] != $cid) {
         CRM_Core_Error::fatal(ts('The main contact record does not exist'));
     }
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Merge.php

示例7: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * @return array array of importable Fields
  * @access public
  * @static
  */
 static function &importableFields($contactType = 'Individual', $status = TRUE, $onlyParticipant = FALSE)
 {
     if (!self::$_importableFields) {
         if (!$onlyParticipant) {
             if (!$status) {
                 $fields = array('' => array('title' => ts('- do not import -')));
             } else {
                 $fields = array('' => array('title' => ts('- Participant Fields -')));
             }
         } else {
             $fields = array();
         }
         $tmpFields = CRM_Event_DAO_Participant::import();
         $note = array('participant_note' => array('title' => 'Participant Note', 'name' => 'participant_note', 'headerPattern' => '/(participant.)?note$/i'));
         $participantStatus = array('participant_status' => array('title' => 'Participant Status', 'name' => 'participant_status', 'data_type' => CRM_Utils_Type::T_STRING));
         $participantRole = array('participant_role' => array('title' => 'Participant Role', 'name' => 'participant_role', 'data_type' => CRM_Utils_Type::T_STRING));
         $eventType = array('event_type' => array('title' => 'Event Type', 'name' => 'event_type', 'data_type' => CRM_Utils_Type::T_STRING));
         $tmpContactField = $contactFields = array();
         $contactFields = array();
         if (!$onlyParticipant) {
             $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
             // Using new Dedupe rule.
             $ruleParams = array('contact_type' => $contactType, 'level' => 'Strict');
             $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
             if (is_array($fieldsArray)) {
                 foreach ($fieldsArray as $value) {
                     $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
                     $value = $customFieldId ? 'custom_' . $customFieldId : $value;
                     $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
                     if (!$status) {
                         $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)';
                     } else {
                         $title = $tmpContactField[trim($value)]['title'];
                     }
                     $tmpContactField[trim($value)]['title'] = $title;
                 }
             }
         }
         $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields);
         if ($extIdentifier) {
             $tmpContactField['external_identifier'] = $extIdentifier;
             $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
         }
         $tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . ' (match to contact)';
         //campaign fields.
         if (isset($tmpFields['participant_campaign_id'])) {
             $tmpFields['participant_campaign'] = array('title' => ts('Campaign Title'));
         }
         $fields = array_merge($fields, $tmpContactField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, $note, $participantStatus, $participantRole, $eventType);
         //$fields = array_merge($fields, $optionFields);
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant'));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:64,代码来源:Participant.php

示例8: import


//.........这里部分代码省略.........
                 //fix for CRM-3570, exclude the statuses those having is_admin = 1
                 //now user can import is_admin if is override is true.
                 $excludeIsAdmin = false;
                 if (!CRM_Utils_Array::value('is_override', $formatted)) {
                     $formatted['exclude_is_admin'] = $excludeIsAdmin = true;
                 }
                 $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($startDate, $endDate, $joinDate, 'today', $excludeIsAdmin);
                 if (!$formatted['status_id']) {
                     $formatted['status_id'] = $calcStatus['id'];
                 } elseif (!CRM_Utils_Array::value('is_override', $formatted)) {
                     if (empty($calcStatus)) {
                         array_unshift($values, "Status in import row (" . $formatValues['status_id'] . ") does not match calculated status based on your configured Membership Status Rules. Record was not imported.");
                         return CRM_Member_Import_Parser::ERROR;
                     } else {
                         if ($formatted['status_id'] != $calcStatus['id']) {
                             //Status Hold" is either NOT mapped or is FALSE
                             array_unshift($values, "Status in import row (" . $formatValues['status_id'] . ") does not match calculated status based on your configured Membership Status Rules (" . $calcStatus['name'] . "). Record was not imported.");
                             return CRM_Member_Import_Parser::ERROR;
                         }
                     }
                 }
                 $newMembership = civicrm_contact_membership_create($formatted);
                 if (civicrm_error($newMembership)) {
                     array_unshift($values, $newMembership['error_message']);
                     return CRM_Member_Import_Parser::ERROR;
                 }
                 $this->_newMemberships[] = $newMembership['id'];
                 return CRM_Member_Import_Parser::VALID;
             }
         } else {
             // Using new Dedupe rule.
             $ruleParams = array('contact_type' => $this->_contactType, 'level' => 'Strict');
             require_once 'CRM/Dedupe/BAO/Rule.php';
             $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
             foreach ($fieldsArray as $value) {
                 if (array_key_exists(trim($value), $params)) {
                     $paramValue = $params[trim($value)];
                     if (is_array($paramValue)) {
                         $disp .= $params[trim($value)][0][trim($value)] . " ";
                     } else {
                         $disp .= $params[trim($value)] . " ";
                     }
                 }
             }
             if (CRM_Utils_Array::value('external_identifier', $params)) {
                 if ($disp) {
                     $disp .= "AND {$params['external_identifier']}";
                 } else {
                     $disp = $params['external_identifier'];
                 }
             }
             array_unshift($values, "No matching Contact found for (" . $disp . ")");
             return CRM_Member_Import_Parser::ERROR;
         }
     } else {
         if ($formatValues['external_identifier']) {
             $checkCid = new CRM_Contact_DAO_Contact();
             $checkCid->external_identifier = $formatValues['external_identifier'];
             $checkCid->find(true);
             if ($checkCid->id != $formatted['contact_id']) {
                 array_unshift($values, "Mismatch of External identifier :" . $formatValues['external_identifier'] . " and Contact Id:" . $formatted['contact_id']);
                 return CRM_Member_Import_Parser::ERROR;
             }
         }
         //to calculate dates
         require_once 'CRM/Member/BAO/MembershipType.php';
开发者ID:bhirsch,项目名称:voipdev,代码行数:67,代码来源:Membership.php

示例9: dedupeRuleFieldsWeight

 /**
  * To find fields related to a rule group.
  *
  * @param array contains the rule group property to identify rule group
  *
  * @return (rule field => weight) array and threshold associated to rule group
  * @access public
  */
 function dedupeRuleFieldsWeight($params)
 {
     $rgBao = new CRM_Dedupe_BAO_RuleGroup();
     $rgBao->level = $params['level'];
     $rgBao->contact_type = $params['contact_type'];
     $rgBao->is_default = 1;
     $rgBao->find(TRUE);
     $ruleBao = new CRM_Dedupe_BAO_Rule();
     $ruleBao->dedupe_rule_group_id = $rgBao->id;
     $ruleBao->find();
     $ruleFields = array();
     while ($ruleBao->fetch()) {
         $ruleFields[$ruleBao->rule_field] = $ruleBao->rule_weight;
     }
     return array($ruleFields, $rgBao->threshold);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:24,代码来源:RuleGroup.php

示例10: import


//.........这里部分代码省略.........
     }
     if (!CRM_Utils_Rule::integer($formatted['event_id'])) {
         array_unshift($values, ts('Invalid value for Event ID'));
         return CRM_Event_Import_Parser::ERROR;
     }
     if ($onDuplicate != CRM_Event_Import_Parser::DUPLICATE_UPDATE) {
         $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, null, 'Participant');
     } else {
         if ($formatValues['participant_id']) {
             require_once 'CRM/Event/BAO/Participant.php';
             $dao = new CRM_Event_BAO_Participant();
             $dao->id = $formatValues['participant_id'];
             $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, $formatValues['participant_id'], 'Participant');
             if ($dao->find(true)) {
                 $ids = array('participant' => $formatValues['participant_id'], 'userId' => $session->get('userID'));
                 $newParticipant = civicrm_participant_check_params($formatted, false);
                 if ($newParticipant['error_message']) {
                     array_unshift($values, $newParticipant['error_message']);
                     return CRM_Event_Import_Parser::ERROR;
                 }
                 $newParticipant =& CRM_Event_BAO_Participant::create($formatted, $ids);
                 $this->_newParticipant[] = $newParticipant->id;
                 return CRM_Event_Import_Parser::VALID;
             } else {
                 array_unshift($values, "Matching Participant record not found for Participant ID " . $formatValues['participant_id'] . ". Row was skipped.");
                 return CRM_Event_Import_Parser::ERROR;
             }
         }
     }
     if ($this->_contactIdIndex < 0) {
         //retrieve contact id using contact dedupe rule
         $formatValues['contact_type'] = $this->_contactType;
         $error = civicrm_check_contact_dedupe($formatValues);
         if (civicrm_duplicate($error)) {
             $matchedIDs = explode(',', $error['error_message']['params'][0]);
             if (count($matchedIDs) >= 1) {
                 foreach ($matchedIDs as $contactId) {
                     $formatted['contact_id'] = $contactId;
                     $newParticipant = civicrm_create_participant_formatted($formatted, $onDuplicate);
                 }
             }
         } else {
             // Using new Dedupe rule.
             $ruleParams = array('contact_type' => $this->_contactType, 'level' => 'Strict');
             require_once 'CRM/Dedupe/BAO/Rule.php';
             $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
             foreach ($fieldsArray as $value) {
                 if (array_key_exists(trim($value), $params)) {
                     $paramValue = $params[trim($value)];
                     if (is_array($paramValue)) {
                         $disp .= $params[trim($value)][0][trim($value)] . " ";
                     } else {
                         $disp .= $params[trim($value)] . " ";
                     }
                 }
             }
             if (CRM_Utils_Array::value('external_identifier', $params)) {
                 if ($disp) {
                     $disp .= "AND {$params['external_identifier']}";
                 } else {
                     $disp = $params['external_identifier'];
                 }
             }
             array_unshift($values, "No matching Contact found for (" . $disp . ")");
             return CRM_Event_Import_Parser::ERROR;
         }
     } else {
         if ($formatValues['external_identifier']) {
             $checkCid = new CRM_Contact_DAO_Contact();
             $checkCid->external_identifier = $formatValues['external_identifier'];
             $checkCid->find(true);
             if ($checkCid->id != $formatted['contact_id']) {
                 array_unshift($values, "Mismatch of External identifier :" . $formatValues['external_identifier'] . " and Contact Id:" . $formatted['contact_id']);
                 return CRM_Event_Import_Parser::ERROR;
             }
         }
         $newParticipant = civicrm_create_participant_formatted($formatted, $onDuplicate);
     }
     if (is_array($newParticipant) && civicrm_error($newParticipant)) {
         if ($onDuplicate == CRM_Event_Import_Parser::DUPLICATE_SKIP) {
             $contactID = CRM_Utils_Array::value('contactID', $newParticipant['error_data']);
             $participantID = CRM_Utils_Array::value('participantID', $newParticipant['error_data']);
             $url = CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&id={$participantID}&cid={$contactID}&action=view", true);
             if (is_array($newParticipant['error_message']) && $participantID == $newParticipant['error_message']['params'][0]) {
                 array_unshift($values, $url);
                 return CRM_Event_Import_Parser::DUPLICATE;
             } else {
                 if ($newParticipant['error_message']) {
                     array_unshift($values, $newParticipant['error_message']);
                     return CRM_Event_Import_Parser::ERROR;
                 }
             }
             return CRM_Event_Import_Parser::ERROR;
         }
     }
     if (!(is_array($newParticipant) && civicrm_error($newParticipant))) {
         $this->_newParticipants[] = $newParticipant['id'];
     }
     return CRM_Event_Import_Parser::VALID;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Participant.php

示例11: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important
  *
  * @param int     $contactType     contact Type
  * @param boolean $status          status is used to manipulate first title
  * @param boolean $showAll         if true returns all fields (includes disabled fields)
  * @param boolean $isProfile       if its profile mode
  * @param boolean $checkPermission if false, do not include permissioning clause (for custom data)
  *
  * @return array array of importable Fields
  * @access public
  * @static
  */
 static function &importableFields($contactType = 'Individual', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     $contactType = 'Individual';
     $fields = CRM_Hrjobcontract_DAO_HRJobContract::import();
     $tmpContactField = $contactFields = array();
     $contactFields = array();
     $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
     // Using new Dedupe rule.
     $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
     $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
     if (is_array($fieldsArray)) {
         foreach ($fieldsArray as $value) {
             $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
             $value = $customFieldId ? 'custom_' . $customFieldId : $value;
             $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
             if (!$status) {
                 $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)';
             } else {
                 $title = $tmpContactField[trim($value)]['title'];
             }
             $tmpContactField[trim($value)]['title'] = $title;
         }
     }
     $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields);
     if ($extIdentifier) {
         $tmpContactField['external_identifier'] = $extIdentifier;
         $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
     }
     $fields = array_merge($fields, $tmpContactField);
     self::$_importableFields = $fields;
     return self::$_importableFields;
     //$fields;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:49,代码来源:HRJobContract.php

示例12: dedupeRuleFields

 /**
  * To find fields related to a rule group.
  * @param array contains the rule group property to identify rule group
  *
  * @return rule fields array associated to rule group
  * @access public
  */
 function dedupeRuleFields($params)
 {
     require_once 'CRM/Dedupe/BAO/RuleGroup.php';
     $rgBao = new CRM_Dedupe_BAO_RuleGroup();
     $rgBao->level = $params['level'];
     $rgBao->contact_type = $params['contact_type'];
     $rgBao->is_default = 1;
     $rgBao->find(true);
     $ruleBao = new CRM_Dedupe_BAO_Rule();
     $ruleBao->dedupe_rule_group_id = $rgBao->id;
     $ruleBao->find();
     $ruleFields = array();
     while ($ruleBao->fetch()) {
         $ruleFields[] = $ruleBao->rule_field;
     }
     return $ruleFields;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:24,代码来源:Rule.php

示例13: import

 /**
  * handle the values in import mode
  *
  * @param int $onDuplicate the code for what action to take on duplicates
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function import($onDuplicate, &$values)
 {
     // first make sure this is a valid line
     $response = $this->summary($values);
     if ($response != CRM_Activity_Import_Parser::VALID) {
         return $response;
     }
     $params =& $this->getActiveFieldParams();
     $activityName = array_search('activity_name', $this->_mapperKeys);
     if ($activityName) {
         $params = array_merge($params, array('activity_name' => $values[$activityName]));
     }
     //for date-Formats
     $session =& CRM_Core_Session::singleton();
     $dateType = $session->get("dateTypes");
     $params['source_contact_id'] = $session->get('userID');
     $formatted = array();
     $customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
     foreach ($params as $key => $val) {
         if ($key == 'activity_date_time') {
             if ($val) {
                 if ($dateType == 1) {
                     $params[$key] = CRM_Utils_Date::customFormat($val, '%Y%m%d%H%i');
                     //hack to add seconds
                     $params[$key] = $params[$key] . '00';
                 } else {
                     CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
                 }
             }
         } elseif ($key == 'duration') {
             $params['duration_minutes'] = $params['duration'];
             unset($params['duration']);
         }
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
             if ($customFields[$customFieldID]['data_type'] == 'Date') {
                 CRM_Import_Parser_Contact::formatCustomDate($params, $params, $dateType, $key);
             } else {
                 if ($customFields[$customFieldID]['data_type'] == 'Boolean') {
                     $params[$key] = CRM_Utils_String::strtoboolstr($val);
                 }
             }
         }
     }
     //date-Format part ends
     $formatError = _civicrm_activity_formatted_param($params, $params, true);
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, CRM_Core_DAO::$_nullObject, null, 'Activity');
     if ($this->_contactIdIndex < 0) {
         //retrieve contact id using contact dedupe rule.
         //since we are support only individual's activity import.
         $params['contact_type'] = 'Individual';
         $error = civicrm_check_contact_dedupe($params);
         if (civicrm_duplicate($error)) {
             $matchedIDs = explode(',', $error['error_message']['params'][0]);
             if (count($matchedIDs) > 1) {
                 array_unshift($values, "Multiple matching contact records detected for this row. The activity was not imported");
                 return CRM_Activity_Import_Parser::ERROR;
             } else {
                 $cid = $matchedIDs[0];
                 $params['target_contact_id'] = $cid;
                 $newActivity = civicrm_activity_create($params);
                 if (CRM_Utils_Array::value('is_error', $newActivity)) {
                     array_unshift($values, $newActivity['error_message']);
                     return CRM_Activity_Import_Parser::ERROR;
                 }
                 $this->_newActivity[] = $newActivity['id'];
                 return CRM_Activity_Import_Parser::VALID;
             }
         } else {
             // Using new Dedupe rule.
             $ruleParams = array('contact_type' => 'Individual', 'level' => 'Strict');
             require_once 'CRM/Dedupe/BAO/Rule.php';
             $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
             foreach ($fieldsArray as $value) {
                 if (array_key_exists(trim($value), $params)) {
                     $paramValue = $params[trim($value)];
                     if (is_array($paramValue)) {
                         $disp .= $params[trim($value)][0][trim($value)] . " ";
                     } else {
                         $disp .= $params[trim($value)] . " ";
                     }
                 }
             }
             if (CRM_Utils_Array::value('external_identifier', $params)) {
                 if ($disp) {
                     $disp .= "AND {$params['external_identifier']}";
                 } else {
                     $disp = $params['external_identifier'];
                 }
             }
             array_unshift($values, "No matching Contact found for (" . $disp . ")");
             return CRM_Activity_Import_Parser::ERROR;
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Activity.php

示例14: dedupeRuleFields

 /**
  * To find fields related to a rule group.
  *
  * @param array contains the rule group property to identify rule group
  *
  * @return rule fields array associated to rule group
  * @access public
  */
 static function dedupeRuleFields($params)
 {
     $rgBao = new CRM_Dedupe_BAO_RuleGroup();
     $rgBao->level = $params['level'];
     $rgBao->contact_type = $params['contact_type'];
     $rgBao->is_default = 1;
     $rgBao->find(TRUE);
     $ruleBao = new CRM_Dedupe_BAO_Rule();
     $ruleBao->dedupe_rule_group_id = $rgBao->id;
     $ruleBao->find();
     $ruleFields = array();
     while ($ruleBao->fetch()) {
         $ruleFields[] = $ruleBao->rule_field;
     }
     return $ruleFields;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:24,代码来源:Rule.php

示例15: buildQuickForm

 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     $this->applyFilter('__ALL__', 'trim');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
     $this->addElement('checkbox', 'is_online_registration', ts('Allow Online Registration?'), null, array('onclick' => "return showHideByValue('is_online_registration', \n                                                                       '', \n                                                                       'registration_blocks', \n                                                                       'block', \n                                                                       'radio', \n                                                                       false );"));
     $this->add('text', 'registration_link_text', ts('Registration Link Text'));
     if (!$this->_isTemplate) {
         $this->addDateTime('registration_start_date', ts('Registration Start Date'), false, array('formatType' => 'activityDateTime'));
         $this->addDateTime('registration_end_date', ts('Registration End Date'), false, array('formatType' => 'activityDateTime'));
     }
     $this->addElement('checkbox', 'is_multiple_registrations', ts('Register multiple participants?'), null, array('onclick' => "return showHideByValue('is_multiple_registrations', '', 'additional_profile_pre|additional_profile_post', 'table-row', 'radio', false);"));
     require_once 'CRM/Dedupe/BAO/Rule.php';
     $params = array('level' => 'Fuzzy', 'contact_type' => 'Individual');
     $dedupeRuleFields = CRM_Dedupe_BAO_Rule::dedupeRuleFields($params);
     foreach ($dedupeRuleFields as $key => $fields) {
         $ruleFields[$key] = ucwords(str_replace('_', ' ', $fields));
     }
     $this->addElement('checkbox', 'allow_same_participant_emails', ts('Allow multiple registrations from the same email address?'), null, array('onclick' => "return showRuleFields( " . json_encode($ruleFields) . " );"));
     $this->assign('ruleFields', json_encode($ruleFields));
     require_once 'CRM/Event/PseudoConstant.php';
     $participantStatuses =& CRM_Event_PseudoConstant::participantStatus();
     if (in_array('Awaiting approval', $participantStatuses) and in_array('Pending from approval', $participantStatuses) and in_array('Rejected', $participantStatuses)) {
         $this->addElement('checkbox', 'requires_approval', ts('Require participant approval?'), null, array('onclick' => "return showHideByValue('requires_approval', '', 'id-approval-text', 'table-row', 'radio', false);"));
         $this->add('textarea', 'approval_req_text', ts('Approval message'), $attributes['approval_req_text']);
     }
     $this->add('text', 'expiration_time', ts('Pending participant expiration (hours)'));
     $this->addRule('expiration_time', ts('Please enter the number of hours (as an integer).'), 'integer');
     self::buildRegistrationBlock($this);
     self::buildConfirmationBlock($this);
     self::buildMailBlock($this);
     self::buildThankYouBlock($this);
     parent::buildQuickForm();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:39,代码来源:Registration.php


注:本文中的CRM_Dedupe_BAO_Rule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。