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


PHP CRM_Core_BAO_Address::validateAddressOptions方法代码示例

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


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

示例1: 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)
 {
     if ($mappingType == 'Export') {
         $name = "Map";
         $columnCount = array('1' => $columnNo);
     } elseif ($mappingType == 'Search Builder') {
         $name = "Builder";
         $columnCount = $columnNo;
     }
     //get the saved mapping details
     if ($mappingType == 'Export') {
         $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'));
     } elseif ($mappingType == 'Search Builder') {
         $form->addElement('submit', 'addBlock', ts('Also include contacts where'), array('class' => 'submit-link'));
     }
     $defaults = array();
     $hasLocationTypes = array();
     $hasRelationTypes = array();
     $fields = array();
     if ($mappingType == 'Export') {
         $required = TRUE;
     } elseif ($mappingType == 'Search Builder') {
         $required = FALSE;
     }
     $contactType = array('Individual', 'Household', 'Organization');
     foreach ($contactType as $value) {
         $contactFields = CRM_Contact_BAO_Contact::exportableFields($value, FALSE, $required);
         $contactFields = array_merge($contactFields, CRM_Contact_BAO_Query_Hook::singleton()->getFields());
         // exclude the address options disabled in the Address Settings
         $fields[$value] = CRM_Core_BAO_Address::validateAddressOptions($contactFields);
         ksort($fields[$value]);
         if ($mappingType == 'Export') {
             $relationships = array();
             $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $value);
             asort($relationshipTypes);
             foreach ($relationshipTypes as $key => $var) {
                 list($type) = explode('_', $key);
                 $relationships[$key]['title'] = $var;
                 $relationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
                 $relationships[$key]['export'] = TRUE;
                 $relationships[$key]['relationship_type_id'] = $type;
                 $relationships[$key]['related'] = TRUE;
                 $relationships[$key]['hasRelationType'] = 1;
             }
             if (!empty($relationships)) {
                 $fields[$value] = array_merge($fields[$value], array('related' => array('title' => ts('- related contact info -'))), $relationships);
             }
         }
     }
     //get the current employer for mapping.
     if ($required) {
         $fields['Individual']['current_employer']['title'] = ts('Current Employer');
     }
     // add component fields
     $compArray = array();
     //we need to unset groups, tags, notes for component export
     if ($exportMode != CRM_Export_Form_Select::CONTACT_EXPORT) {
         foreach (array('groups', 'tags', 'notes') as $value) {
             unset($fields['Individual'][$value]);
             unset($fields['Household'][$value]);
             unset($fields['Organization'][$value]);
         }
     }
     if ($mappingType == 'Search Builder') {
         //build the common contact fields array.
         $fields['Contact'] = array();
         foreach ($fields['Individual'] as $key => $value) {
//.........这里部分代码省略.........
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:101,代码来源:Mapping.php

示例2: init

 /**
  * The initializer code, called before the processing
  *
  * @return void
  */
 public function init()
 {
     $contactFields = CRM_Contact_BAO_Contact::importableFields($this->_contactType);
     // exclude the address options disabled in the Address Settings
     $fields = CRM_Core_BAO_Address::validateAddressOptions($contactFields);
     //CRM-5125
     //supporting import for contact subtypes
     $csType = NULL;
     if (!empty($this->_contactSubType)) {
         //custom fields for sub type
         $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($this->_contactSubType);
         if (!empty($subTypeFields)) {
             foreach ($subTypeFields as $customSubTypeField => $details) {
                 $fields[$customSubTypeField] = $details;
             }
         }
     }
     //Relationship importables
     $this->_relationships = $relations = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $this->_contactType, FALSE, 'label', TRUE, $this->_contactSubType);
     asort($relations);
     foreach ($relations as $key => $var) {
         list($type) = explode('_', $key);
         $relationshipType[$key]['title'] = $var;
         $relationshipType[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
         $relationshipType[$key]['import'] = TRUE;
         $relationshipType[$key]['relationship_type_id'] = $type;
         $relationshipType[$key]['related'] = TRUE;
     }
     if (!empty($relationshipType)) {
         $fields = array_merge($fields, array('related' => array('title' => ts('- related contact info -'))), $relationshipType);
     }
     foreach ($fields as $name => $field) {
         $this->addField($name, $field['title'], CRM_Utils_Array::value('type', $field), CRM_Utils_Array::value('headerPattern', $field), CRM_Utils_Array::value('dataPattern', $field), CRM_Utils_Array::value('hasLocationType', $field));
     }
     $this->_newContacts = array();
     $this->setActiveFields($this->_mapperKeys);
     $this->setActiveFieldLocationTypes($this->_mapperLocType);
     $this->setActiveFieldPhoneTypes($this->_mapperPhoneType);
     $this->setActiveFieldWebsiteTypes($this->_mapperWebsiteType);
     //set active fields of IM provider of contact
     $this->setActiveFieldImProviders($this->_mapperImProvider);
     //related info
     $this->setActiveFieldRelated($this->_mapperRelated);
     $this->setActiveFieldRelatedContactType($this->_mapperRelatedContactType);
     $this->setActiveFieldRelatedContactDetails($this->_mapperRelatedContactDetails);
     $this->setActiveFieldRelatedContactLocType($this->_mapperRelatedContactLocType);
     $this->setActiveFieldRelatedContactPhoneType($this->_mapperRelatedContactPhoneType);
     $this->setActiveFieldRelatedContactWebsiteType($this->_mapperRelatedContactWebsiteType);
     //set active fields of IM provider of related contact
     $this->setActiveFieldRelatedContactImProvider($this->_mapperRelatedContactImProvider);
     $this->_phoneIndex = -1;
     $this->_emailIndex = -1;
     $this->_firstNameIndex = -1;
     $this->_lastNameIndex = -1;
     $this->_householdNameIndex = -1;
     $this->_organizationNameIndex = -1;
     $this->_externalIdentifierIndex = -1;
     $index = 0;
     foreach ($this->_mapperKeys as $key) {
         if (substr($key, 0, 5) == 'email' && substr($key, 0, 14) != 'email_greeting') {
             $this->_emailIndex = $index;
             $this->_allEmails = array();
         }
         if (substr($key, 0, 5) == 'phone') {
             $this->_phoneIndex = $index;
         }
         if ($key == 'first_name') {
             $this->_firstNameIndex = $index;
         }
         if ($key == 'last_name') {
             $this->_lastNameIndex = $index;
         }
         if ($key == 'household_name') {
             $this->_householdNameIndex = $index;
         }
         if ($key == 'organization_name') {
             $this->_organizationNameIndex = $index;
         }
         if ($key == 'external_identifier') {
             $this->_externalIdentifierIndex = $index;
             $this->_allExternalIdentifiers = array();
         }
         $index++;
     }
     $this->_updateWithId = FALSE;
     if (in_array('id', $this->_mapperKeys) || $this->_externalIdentifierIndex >= 0 && in_array($this->_onDuplicate, array(CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL))) {
         $this->_updateWithId = TRUE;
     }
     $this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE);
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:95,代码来源:Contact.php


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