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


PHP CRM_Core_BAO_Mapping::getMappingFields方法代码示例

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


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

示例1: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     //to save the current mappings
     if (!$this->get('savedMapping')) {
         $saveDetailsName = ts('Save this field mapping');
         $this->applyFilter('saveMappingName', 'trim');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     } else {
         $savedMapping = $this->get('savedMapping');
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
         $mappingName = $mappingName[1];
         $mappingContactType = $mappingContactType[1];
         $mappingLocation = CRM_Utils_Array::value('1', $mappingLocation);
         $mappingPhoneType = CRM_Utils_Array::value('1', $mappingPhoneType);
         $mappingRelation = CRM_Utils_Array::value('1', $mappingRelation);
         //mapping is to be loaded from database
         $params = array('id' => $savedMapping);
         $temp = array();
         $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
         $this->assign('loadedMapping', $mappingDetails->name);
         $this->set('loadedMapping', $savedMapping);
         $getMappingName = new CRM_Core_DAO_Mapping();
         $getMappingName->id = $savedMapping;
         $getMappingName->mapping_type = 'Import Memberships';
         $getMappingName->find();
         while ($getMappingName->fetch()) {
             $mapperName = $getMappingName->name;
         }
         $this->assign('savedName', $mapperName);
         $this->add('hidden', 'mappingId', $savedMapping);
         $this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
         $saveDetailsName = ts('Save as a new field mapping');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     }
     $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
     $this->addFormRule(array('CRM_Member_Import_Form_MapField', 'formRule'), $this);
     //-------- end of saved mapping stuff ---------
     $defaults = array();
     $mapperKeys = array_keys($this->_mapperFields);
     $hasHeaders = !empty($this->_columnHeaders);
     $headerPatterns = $this->get('headerPatterns');
     $dataPatterns = $this->get('dataPatterns');
     $hasLocationTypes = $this->get('fieldTypes');
     /* Initialize all field usages to false */
     foreach ($mapperKeys as $key) {
         $this->_fieldUsed[$key] = FALSE;
     }
     $this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $sel1 = $this->_mapperFields;
     if (!$this->get('onDuplicate')) {
         unset($sel1['id']);
         unset($sel1['membership_id']);
     }
     $sel2[''] = NULL;
     $js = "<script type='text/javascript'>\n";
     $formName = 'document.forms.' . $this->_name;
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($i = 0; $i < $this->_columnCount; $i++) {
         $sel =& $this->addElement('hierselect', "mapper[{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
         $jsSet = FALSE;
         if ($this->get('savedMapping')) {
             if (isset($mappingName[$i])) {
                 if ($mappingName[$i] != ts('- do not import -')) {
                     $mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);
                     //When locationType is not set
                     $js .= "{$formName}['mapper[{$i}][1]'].style.display = 'none';\n";
                     //When phoneType is not set
                     $js .= "{$formName}['mapper[{$i}][2]'].style.display = 'none';\n";
                     $js .= "{$formName}['mapper[{$i}][3]'].style.display = 'none';\n";
                     $defaults["mapper[{$i}]"] = array($mappingHeader[0]);
                     $jsSet = TRUE;
                 } else {
                     $defaults["mapper[{$i}]"] = array();
                 }
                 if (!$jsSet) {
                     for ($k = 1; $k < 4; $k++) {
                         $js .= "{$formName}['mapper[{$i}][{$k}]'].style.display = 'none';\n";
                     }
                 }
             } else {
                 // this load section to help mapping if we ran out of saved columns when doing Load Mapping
                 $js .= "swapOptions({$formName}, 'mapper[{$i}]', 0, 3, 'hs_mapper_" . $i . "_');\n";
                 if ($hasHeaders) {
                     $defaults["mapper[{$i}]"] = array($this->defaultFromHeader($this->_columnHeaders[$i], $headerPatterns));
                 } else {
                     $defaults["mapper[{$i}]"] = array($this->defaultFromData($dataPatterns, $i));
                 }
             }
             //end of load mapping
         } else {
             $js .= "swapOptions({$formName}, 'mapper[{$i}]', 0, 3, 'hs_mapper_" . $i . "_');\n";
             if ($hasHeaders) {
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:MapField.php

示例2: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     //to save the current mappings
     if (!$this->get('savedMapping')) {
         $saveDetailsName = ts('Save this field mapping');
         $this->applyFilter('saveMappingName', 'trim');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     } else {
         $savedMapping = $this->get('savedMapping');
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
         $mappingName = $mappingName[1];
         $mappingContactType = $mappingContactType[1];
         $mappingLocation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingLocation));
         $mappingPhoneType = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingPhoneType));
         $mappingRelation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingRelation));
         //mapping is to be loaded from database
         $params = array('id' => $savedMapping);
         $temp = array();
         $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
         $this->assign('loadedMapping', $mappingDetails->name);
         $this->set('loadedMapping', $savedMapping);
         $getMappingName = new CRM_Core_DAO_Mapping();
         $getMappingName->id = $savedMapping;
         $getMappingName->mapping_type = 'Import Contributions';
         $getMappingName->find();
         while ($getMappingName->fetch()) {
             $mapperName = $getMappingName->name;
         }
         $this->assign('savedName', $mapperName);
         $this->add('hidden', 'mappingId', $savedMapping);
         $this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
         $saveDetailsName = ts('Save as a new field mapping');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     }
     $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
     $this->addFormRule(array('CRM_Contribute_Import_Form_MapField', 'formRule'), $this);
     //-------- end of saved mapping stuff ---------
     $defaults = array();
     $mapperKeys = array_keys($this->_mapperFields);
     $hasHeaders = !empty($this->_columnHeaders);
     $headerPatterns = $this->get('headerPatterns');
     $dataPatterns = $this->get('dataPatterns');
     $hasLocationTypes = $this->get('fieldTypes');
     $mapperKeysValues = $this->controller->exportValue($this->_name, 'mapper');
     /* Initialize all field usages to false */
     foreach ($mapperKeys as $key) {
         $this->_fieldUsed[$key] = FALSE;
     }
     $this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $sel1 = $this->_mapperFields;
     if (!$this->get('onDuplicate')) {
         unset($sel1['id']);
         unset($sel1['contribution_id']);
     }
     // start of soft credit section
     // get contact type for this import
     $contactTypeId = $this->get('contactType');
     $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
     $contactType = isset($contactTypes[$contactTypeId]) ? $contactTypes[$contactTypeId] : '';
     // get importable fields for contact type
     $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
     // get the Dedupe rule for this contact type and build soft credit array
     $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
     $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
     $softCreditFields['contact_id'] = ts('Contact ID');
     $softCreditFields['external_identifier'] = ts('External ID');
     $softCreditFields['email'] = ts('Email');
     $sel2['soft_credit'] = $softCreditFields;
     $sel3['soft_credit']['contact_id'] = $sel3['soft_credit']['external_identifier'] = $sel3['soft_credit']['email'] = CRM_Core_OptionGroup::values('soft_credit_type');
     $sel4 = NULL;
     // end of soft credit section
     $js = "<script type='text/javascript'>\n";
     $formName = 'document.forms.' . $this->_name;
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($i = 0; $i < $this->_columnCount; $i++) {
         $sel =& $this->addElement('hierselect', "mapper[{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
         $jsSet = FALSE;
         if ($this->get('savedMapping')) {
             if (isset($mappingName[$i])) {
                 if ($mappingName[$i] != ts('- do not import -')) {
                     $mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);
                     // reusing contact_type field array for soft credit
                     $softField = isset($mappingContactType[$i]) ? $mappingContactType[$i] : 0;
                     if (!$softField) {
                         $js .= "{$formName}['mapper[{$i}][1]'].style.display = 'none';\n";
                     }
                     $js .= "{$formName}['mapper[{$i}][2]'].style.display = 'none';\n";
                     $js .= "{$formName}['mapper[{$i}][3]'].style.display = 'none';\n";
                     $defaults["mapper[{$i}]"] = array(CRM_Utils_Array::value(0, $mappingHeader), $softField ? $softField : "", isset($locationId) ? $locationId : "", isset($phoneType) ? $phoneType : "");
                     $jsSet = TRUE;
                 } else {
                     $defaults["mapper[{$i}]"] = array();
                 }
                 if (!$jsSet) {
//.........这里部分代码省略.........
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:MapField.php

示例3: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     //to save the current mappings
     if (!$this->get('savedMapping')) {
         $saveDetailsName = ts('Save this field mapping');
         $this->applyFilter('saveMappingName', 'trim');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     } else {
         $savedMapping = $this->get('savedMapping');
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue, $mappingWebsiteType) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
         //get loaded Mapping Fields
         $mappingName = CRM_Utils_Array::value(1, $mappingName);
         $mappingContactType = CRM_Utils_Array::value(1, $mappingContactType);
         $mappingLocation = CRM_Utils_Array::value(1, $mappingLocation);
         $mappingPhoneType = CRM_Utils_Array::value(1, $mappingPhoneType);
         $mappingImProvider = CRM_Utils_Array::value(1, $mappingImProvider);
         $mappingRelation = CRM_Utils_Array::value(1, $mappingRelation);
         $mappingWebsiteType = CRM_Utils_Array::value(1, $mappingWebsiteType);
         $this->assign('loadedMapping', $savedMapping);
         $this->set('loadedMapping', $savedMapping);
         $params = array('id' => $savedMapping);
         $temp = array();
         $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
         $this->assign('savedName', $mappingDetails->name);
         $this->add('hidden', 'mappingId', $savedMapping);
         $this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
         $saveDetailsName = ts('Save as a new field mapping');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     }
     $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
     $this->addFormRule(array('CRM_Contact_Import_Form_MapField', 'formRule'));
     //-------- end of saved mapping stuff ---------
     $defaults = array();
     $mapperKeys = array_keys($this->_mapperFields);
     $hasColumnNames = !empty($this->_columnNames);
     $columnPatterns = $this->get('columnPatterns');
     $dataPatterns = $this->get('dataPatterns');
     $hasLocationTypes = $this->get('fieldTypes');
     $this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     // Pass default location to js
     if ($defaultLocationType) {
         $this->assign('defaultLocationType', $defaultLocationType->id);
         $this->assign('defaultLocationTypeLabel', $this->_location_types[$defaultLocationType->id]);
     }
     /* Initialize all field usages to false */
     foreach ($mapperKeys as $key) {
         $this->_fieldUsed[$key] = FALSE;
     }
     $sel1 = $this->_mapperFields;
     $sel2[''] = NULL;
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
     foreach ($this->_location_types as $key => $value) {
         $sel3['phone'][$key] =& $phoneTypes;
         //build array for IM service provider type for contact
         $sel3['im'][$key] =& $imProviders;
     }
     $sel4 = NULL;
     // store and cache all relationship types
     $contactRelation = new CRM_Contact_DAO_RelationshipType();
     $contactRelation->find();
     while ($contactRelation->fetch()) {
         $contactRelationCache[$contactRelation->id] = array();
         $contactRelationCache[$contactRelation->id]['contact_type_a'] = $contactRelation->contact_type_a;
         $contactRelationCache[$contactRelation->id]['contact_sub_type_a'] = $contactRelation->contact_sub_type_a;
         $contactRelationCache[$contactRelation->id]['contact_type_b'] = $contactRelation->contact_type_b;
         $contactRelationCache[$contactRelation->id]['contact_sub_type_b'] = $contactRelation->contact_sub_type_b;
     }
     $highlightedFields = $highlightedRelFields = array();
     $highlightedFields['email'] = 'All';
     $highlightedFields['external_identifier'] = 'All';
     $highlightedFields['first_name'] = 'Individual';
     $highlightedFields['last_name'] = 'Individual';
     $highlightedFields['household_name'] = 'Household';
     $highlightedFields['organization_name'] = 'Organization';
     foreach ($mapperKeys as $key) {
         // check if there is a _a_b or _b_a in the key
         if (strpos($key, '_a_b') || strpos($key, '_b_a')) {
             list($id, $first, $second) = explode('_', $key);
         } else {
             $id = $first = $second = NULL;
         }
         if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
             $cType = $contactRelationCache[$id]["contact_type_{$second}"];
             //CRM-5125 for contact subtype specific relationshiptypes
             $cSubType = NULL;
             if (!empty($contactRelationCache[$id]["contact_sub_type_{$second}"])) {
                 $cSubType = $contactRelationCache[$id]["contact_sub_type_{$second}"];
             }
             if (!$cType) {
                 $cType = 'All';
             }
             $relatedFields = array();
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:MapField.php

示例4: buildMappingForm


//.........这里部分代码省略.........
             }
         }
         //Location Type for relationship fields
         foreach ($sel5 as $k => $v) {
             if ($v) {
                 foreach ($v as $rel => $fields) {
                     foreach ($fields as $field => $fieldLabel) {
                         if (isset($hasLocationTypes[$k][$field])) {
                             $sel6[$k][$rel][$field] = $locationTypes;
                         }
                     }
                 }
             }
         }
         //PhoneTypes for  relationship fields
         $sel7[''] = NULL;
         foreach ($sel6 as $k => $rel) {
             if ($k) {
                 foreach ($rel as $phonekey => $phonevalue) {
                     foreach ($locationTypes as $locType => $loc) {
                         if (trim($locType) != '') {
                             $sel7[$k][$phonekey]['phone'][$locType] =& $phoneTypes;
                             $sel7[$k][$phonekey]['im'][$locType] =& $imProviders;
                         }
                     }
                 }
             }
         }
     }
     //special fields that have location, hack for primary location
     $specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'phone', 'email', 'im');
     if (isset($mappingId)) {
         $colCnt = 0;
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
         $blkCnt = count($mappingName);
         if ($blkCnt >= $blockCount) {
             $blockCount = $blkCnt + 1;
         }
         for ($x = 1; $x < $blockCount; $x++) {
             if (isset($mappingName[$x])) {
                 $colCnt = count($mappingName[$x]);
                 if ($colCnt >= $columnCount[$x]) {
                     $columnCount[$x] = $colCnt;
                 }
             }
         }
     }
     $form->_blockCount = $blockCount;
     $form->_columnCount = $columnCount;
     $form->set('blockCount', $form->_blockCount);
     $form->set('columnCount', $form->_columnCount);
     $defaults = $noneArray = $nullArray = array();
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($x = 1; $x < $blockCount; $x++) {
         for ($i = 0; $i < $columnCount[$x]; $i++) {
             $sel =& $form->addElement('hierselect', "mapper[{$x}][{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
             $jsSet = FALSE;
             if (isset($mappingId)) {
                 $locationId = isset($mappingLocation[$x][$i]) ? $mappingLocation[$x][$i] : 0;
                 if (isset($mappingName[$x][$i])) {
                     if (is_array($mapperFields[$mappingContactType[$x][$i]])) {
                         if (isset($mappingRelation[$x][$i])) {
                             $contactDetails = strtolower(str_replace(" ", "_", $mappingName[$x][$i]));
                             $relLocationId = isset($mappingLocation[$x][$i]) ? $mappingLocation[$x][$i] : 0;
                             if (!$relLocationId && in_array($mappingName[$x][$i], $specialFields)) {
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:67,代码来源:Mapping.php

示例5: buildMappingForm

 /**
  * Build the mapping form.
  *
  * @param CRM_Core_Form $form
  * @param string $mappingType
  *   (Export/Import/Search Builder).
  * @param int $mappingId
  * @param int $columnNo
  * @param int $blockCount
  *   (no of blocks shown).
  * @param NULL $exportMode
  *
  * @return void
  */
 public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL)
 {
     $name = "Map";
     $columnCount = array('1' => $columnNo);
     $form->applyFilter('saveMappingName', 'trim');
     //to save the current mappings
     if (!isset($mappingId)) {
         $saveDetailsName = ts('Save this field mapping');
         $form->add('text', 'saveMappingName', ts('Name'));
         $form->add('text', 'saveMappingDesc', ts('Description'));
     } else {
         $form->assign('loadedMapping', $mappingId);
         $params = array('id' => $mappingId);
         $temp = array();
         $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
         $form->assign('savedName', $mappingDetails->name);
         $form->add('hidden', 'mappingId', $mappingId);
         $form->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
         $saveDetailsName = ts('Save as a new field mapping');
         $form->add('text', 'saveMappingName', ts('Name'));
         $form->add('text', 'saveMappingDesc', ts('Description'));
     }
     $form->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
     $form->addFormRule(array('CRM_Export_Form_Map', 'formRule'), $form->get('mappingTypeId'));
     $defaults = array();
     $hasLocationTypes = array();
     $hasRelationTypes = array();
     $fields = array();
     if ($mappingType == 'Export') {
         $required = TRUE;
     }
     $fields = CRM_Contact_BAO_Relationship::fields();
     // add custom fields
     $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Relationship'));
     ksort($fields);
     // add component fields
     $compArray = array();
     foreach ($fields as $key => $value) {
         //CRM-2676, replacing the conflict for same custom field name from different custom group.
         $customGroupName = self::getCustomGroupName($key);
         if ($customGroupName) {
             $relatedMapperFields[$key] = $mapperFields[$key] = $customGroupName . ': ' . $value['title'];
         } else {
             $relatedMapperFields[$key] = $mapperFields[$key] = $value['title'];
         }
     }
     $mapperKeys = array_keys($mapperFields);
     $sel1 = array('' => ts('- select field -')) + $mapperFields;
     if (isset($mappingId)) {
         $colCnt = 0;
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
         $blkCnt = count($mappingName);
         if ($blkCnt >= $blockCount) {
             $blockCount = $blkCnt + 1;
         }
         for ($x = 1; $x < $blockCount; $x++) {
             if (isset($mappingName[$x])) {
                 $colCnt = count($mappingName[$x]);
                 if ($colCnt >= $columnCount[$x]) {
                     $columnCount[$x] = $colCnt;
                 }
             }
         }
     }
     $form->_blockCount = $blockCount;
     $form->_columnCount = $columnCount;
     $form->set('blockCount', $form->_blockCount);
     $form->set('columnCount', $form->_columnCount);
     $defaults = $noneArray = $nullArray = array();
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($x = 1; $x < $blockCount; $x++) {
         for ($i = 0; $i < $columnCount[$x]; $i++) {
             $sel =& $form->addElement('hierselect', "mapper[{$x}][{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
             $jsSet = FALSE;
             if (isset($mappingId)) {
                 //TODO opgeslagen mappings
             }
             //Fix for Export
             $j = 7;
             $formValues = $form->exportValues();
             if (!$jsSet) {
                 if (empty($formValues)) {
                     // Incremented length for third select box(relationship type)
                     for ($k = 1; $k < $j; $k++) {
                         $noneArray[] = array($x, $i, $k);
//.........这里部分代码省略.........
开发者ID:Chirojeugd-Vlaanderen,项目名称:civicrm-relationship-entity,代码行数:101,代码来源:Relationship.php

示例6: tempFixFormValues

 /**
  * Function to deal with groups that may have been mis-saved during a glitch.
  *
  * This deals with groups that may have been saved with differing mapping parameters than
  * the latest supported ones.
  *
  * @param int $id
  * @param array $formValues
  */
 public function tempFixFormValues($id, &$formValues)
 {
     $mappingID = CRM_Core_DAO::singleValueQuery('SELECT mapping_id FROM civicrm_saved_search WHERE id = %1', array(1 => array($id, 'Integer')));
     $addressFields = civicrm_api3('Address', 'getfields');
     $options = self::fieldOptions();
     $entities = array('contact', 'address', 'activity', 'participant', 'pledge', 'membership', 'contribution', 'case', 'grant');
     if (empty($formValues['mapper']) && $mappingID) {
         $mappingFields = CRM_Core_BAO_Mapping::getMappingFields($mappingID);
         foreach ($mappingFields[0][1] as $index => $mappingField) {
             $formValues['mapper'][1][$index] = array($mappingFields[1][1][$index], $mappingFields[0][1][$index]);
             $formValues['operator'][1][$index] = $mappingFields[6][1][$index];
             $formValues['value'][1][$index] = $mappingFields[7][1][$index];
         }
     }
     /*
       foreach ($formValues['mapper'] as $index => $fields) {
         foreach ($fields as $fieldIndex => $field) {
           $entity = $options[$field[1]];
           if ($entity == 'contact' || isset($addressFields['values'][$field[1]])) {
     
             $existing = (CRM_Core_DAO::singleValueQuery("SELECT contact_type FROM civicrm_mapping_field WHERE mapping_id = $mappingID AND grouping = $index AND column_number = $fieldIndex"));
             if ($existing != 'Contact') {
               $formValues['mapper'][$index][$fieldIndex][0] = 'Contact';
               //CRM_Core_DAO::executeQuery("UPDATE civicrm_mapping_field SET contact_type = 'Contact' WHERE mapping_id = $mappingID AND grouping = $index AND column_number = $fieldIndex");
             }
           }
           if (in_array($entity, $entities)) {
             $values = civicrm_api3($entity, 'getoptions', array('field' => $field[1]));
             $currentValue = $formValues['value'][$index][$fieldIndex];
             if (!isset($values['values'][$currentValue]) && in_array($currentValue, $values['values'])) {
               $newValue = array_search($currentValue, $values['values']);
               $formValues['value'][$index][$fieldIndex] = $newValue;
               //CRM_Core_DAO::executeQuery("UPDATE civicrm_mapping_field SET value = $newValue WHERE mapping_id = $mappingID AND grouping = $index AND column_number = $fieldIndex");
     
             }
           }
           /*
           $i = $index;
           while ($i > 0) {
             if ($fields == $formValues['mapper'][$i] && ($formValues['operator'][$i] == $formValues['operator'][$index]) && '=' == $formValues['operator'][$index]) {
             }
             $i--;
           }
     
         }
       }
     */
     $savedSearch = new CRM_Contact_DAO_SavedSearch();
     $savedSearch->id = $id;
     $savedSearch->find(TRUE);
     $tables = $whereTables = array();
     $savedSearch->where_clause = CRM_Contact_BAO_Query::getWhereClause($formValues, NULL, $tables, $whereTables);
     if (!empty($tables)) {
         $savedSearch->select_tables = serialize($tables);
     }
     if (!empty($whereTables)) {
         $savedSearch->where_tables = serialize($whereTables);
     }
     $savedSearch->form_values = serialize($formValues);
     $savedSearch->save();
 }
开发者ID:kidaa30,项目名称:yes,代码行数:70,代码来源:Builder.php


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