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


PHP CRM_Core_BAO_Mapping::checkMapping方法代码示例

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


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

示例1: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $values
  * @param int $mappingTypeId
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields, $values, $mappingTypeId)
 {
     $errors = array();
     if (!empty($fields['saveMapping']) && !empty($fields['_qf_Map_next'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Export Mapping');
         } else {
             //check for Duplicate mappingName
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Export Mapping Name');
             }
         }
     }
     if (!empty($errors)) {
         $_flag = 1;
         $assignError = new CRM_Core_Page();
         $assignError->assign('mappingDetailsError', $_flag);
         return $errors;
     } else {
         return TRUE;
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:35,代码来源:Map.php

示例2: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array('participant_contact_id' => ts('Contact ID'), 'event_id' => ts('Event ID'));
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId]);
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if ($field == 'participant_contact_id') {
                     if ($weightSum >= $threshold || in_array('external_identifier', $importKeys) || in_array('participant_id', $importKeys)) {
                         continue;
                     }
                     if ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
                         $errors['_qf_default'] .= ts('Missing required field: Provide Particiapnt ID') . '<br />';
                     } else {
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " {$fieldMessage} " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . ' ' . ts('Or Provide Contact Id or External Identifier.') . '<br />';
                     }
                 } elseif (!in_array('event_title', $importKeys)) {
                     $errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2', array(1 => $title, 2 => 'Event Title')) . '<br />';
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('saveMapping', $fields)) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Participant Mapping Name');
             }
         }
     }
     //display Error if loaded mapping is not selected
     if (array_key_exists('loadMapping', $fields)) {
         $getMapName = CRM_Utils_Array::value('savedMapping', $fields);
         if (empty($getMapName)) {
             $errors['savedMapping'] = ts('Select saved mapping');
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:78,代码来源:MapField.php

示例3: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param $self
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array('membership_contact_id' => ts('Contact ID'), 'membership_type_id' => ts('Membership Type'), 'membership_start_date' => ts('Membership Start Date'));
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId]);
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         $fieldMessage = '';
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if ($field == 'membership_contact_id') {
                     if (($weightSum >= $threshold || in_array('external_identifier', $importKeys)) && $self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE || in_array('membership_id', $importKeys)) {
                         continue;
                     } else {
                         if (!isset($errors['_qf_default'])) {
                             $errors['_qf_default'] = '';
                         }
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " {$fieldMessage} " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . ' ' . ts('(OR Membership ID if update mode.)') . '<br />';
                     }
                 } else {
                     if (!isset($errors['_qf_default'])) {
                         $errors['_qf_default'] = '';
                     }
                     $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
                 }
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Membership', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Membership Mapping Name');
             }
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:77,代码来源:MapField.php

示例4: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields)
 {
     $errors = array();
     // define so we avoid notices below
     $errors['_qf_default'] = '';
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array('target_contact_id' => ts('Contact ID'), 'activity_date_time' => ts('Activity Date'), 'activity_subject' => ts('Activity Subject'), 'activity_type_id' => ts('Activity Type Id'));
         $params = array('used' => 'Unsupervised', 'contact_type' => 'Individual');
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if ($field == 'target_contact_id') {
                     if ($weightSum >= $threshold || in_array('external_identifier', $importKeys)) {
                         continue;
                     } else {
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . $fieldMessage . ' ' . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . '<br />';
                     }
                 } elseif ($field == 'activity_type_id') {
                     if (in_array('activity_label', $importKeys)) {
                         continue;
                     } else {
                         $errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2', array(1 => $title, 2 => 'Activity Type Label')) . '<br />';
                     }
                 } else {
                     $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
                 }
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Mapping Name');
             }
         }
     }
     if (empty($errors['_qf_default'])) {
         unset($errors['_qf_default']);
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:77,代码来源:MapField.php

示例5: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields)
 {
     $errors = array();
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         $requiredFields = array('contact_id' => ts('Contact ID'));
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if (!isset($errors['_qf_default'])) {
                     $errors['_qf_default'] = '';
                 }
                 $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title));
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Multi value custom data', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate ' . $self->_mappingType . 'Mapping Name');
             }
         }
     }
     //display Error if loaded mapping is not selected
     if (array_key_exists('loadMapping', $fields)) {
         $getMapName = CRM_Utils_Array::value('savedMapping', $fields);
         if (empty($getMapName)) {
             $errors['savedMapping'] = ts('Select saved mapping');
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:56,代码来源:MapField.php

示例6: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param $self
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     $fieldMessage = NULL;
     $contactORContributionId = $self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE ? 'contribution_id' : 'contribution_contact_id';
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => isset($contactTypes[$contactTypeId]) ? $contactTypes[$contactTypeId] : '');
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
             if ($val == "soft_credit") {
                 $mapperKey = CRM_Utils_Array::key('soft_credit', $importKeys);
                 if (empty($fields['mapper'][$mapperKey][1])) {
                     if (empty($errors['_qf_default'])) {
                         $errors['_qf_default'] = '';
                     }
                     $errors['_qf_default'] .= ts('Missing required fields: Soft Credit') . '<br />';
                 }
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array($contactORContributionId == 'contribution_id' ? 'contribution_id' : 'contribution_contact_id' => $contactORContributionId == 'contribution_id' ? ts('Contribution ID') : ts('Contact ID'), 'total_amount' => ts('Total Amount'), 'financial_type' => ts('Financial Type'));
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if (empty($errors['_qf_default'])) {
                     $errors['_qf_default'] = '';
                 }
                 if ($field == $contactORContributionId) {
                     if (!($weightSum >= $threshold || in_array('external_identifier', $importKeys)) && $self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " {$fieldMessage} " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . '<br />';
                     } elseif ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && !(in_array('invoice_id', $importKeys) || in_array('trxn_id', $importKeys) || in_array('contribution_id', $importKeys))) {
                         $errors['_qf_default'] .= ts('Invoice ID or Transaction ID or Contribution ID are required to match to the existing contribution records in Update mode.') . '<br />';
                     }
                 } else {
                     $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
                 }
             }
         }
         //at least one field should be mapped during update.
         if ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
             $atleastOne = FALSE;
             foreach ($self->_mapperFields as $key => $field) {
                 if (in_array($key, $importKeys) && !in_array($key, array('doNotImport', 'contribution_id', 'invoice_id', 'trxn_id'))) {
                     $atleastOne = TRUE;
                     break;
                 }
             }
             if (!$atleastOne) {
                 $errors['_qf_default'] .= ts('At least one contribution field needs to be mapped for update during update mode.') . '<br />';
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Contribution Mapping Name');
             }
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         if (!empty($errors['_qf_default'])) {
             CRM_Core_Session::setStatus($errors['_qf_default'], ts("Error"), "error");
             return $errors;
         }
     }
     return TRUE;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:100,代码来源:MapField.php

示例7: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields)
 {
     $errors = array();
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contact', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Mapping Name');
             }
         }
     }
     $template = CRM_Core_Smarty::singleton();
     if (!empty($fields['saveMapping'])) {
         $template->assign('isCheked', TRUE);
     }
     if (!empty($errors)) {
         $_flag = 1;
         $assignError = new CRM_Core_Page();
         $assignError->assign('mappingDetailsError', $_flag);
         return $errors;
     } else {
         return TRUE;
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:36,代码来源:MapField.php

示例8: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @param $files
  * @param $self
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId]);
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
     }
     if (CRM_Utils_Array::value('saveMapping', $fields)) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $this->_mappingType, 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate ' . $this->_mappingType . 'Mapping Name');
             }
         }
     }
     //display Error if loaded mapping is not selected
     if (array_key_exists('loadMapping', $fields)) {
         $getMapName = CRM_Utils_Array::value('savedMapping', $fields);
         if (empty($getMapName)) {
             $errors['savedMapping'] = ts('Select saved mapping');
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:wayneYaw,项目名称:nz.co.fuzion.csvimport,代码行数:63,代码来源:MapFieldBaseClass.php


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