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


PHP CRM_Contact_BAO_Contact::getPrimaryLocationType方法代码示例

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


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

示例1: formatCommonData


//.........这里部分代码省略.........
                 case 'Multi-Select':
                     $mulValues = explode(',', $field);
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
                     $formatted[$key] = array();
                     foreach ($mulValues as $v1) {
                         foreach ($customOption as $v2) {
                             if (strtolower($v2['label']) == strtolower(trim($v1)) || strtolower($v2['value']) == strtolower(trim($v1))) {
                                 if ($type == 'CheckBox') {
                                     $formatted[$key][$v2['value']] = 1;
                                 } else {
                                     $formatted[$key][] = $v2['value'];
                                 }
                             }
                         }
                     }
                     break;
                 case 'Select':
                 case 'Radio':
                     $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
                     foreach ($customOption as $v2) {
                         if (strtolower($v2['label']) == strtolower(trim($field)) || strtolower($v2['value']) == strtolower(trim($field))) {
                             $formatted[$key] = $v2['value'];
                         }
                     }
                     break;
                 case 'Multi-Select State/Province':
                     $mulValues = explode(',', $field);
                     $stateAbbr = CRM_Core_PseudoConstant::stateProvinceAbbreviation();
                     $stateName = CRM_Core_PseudoConstant::stateProvince();
                     $formatted[$key] = $stateValues = array();
                     foreach ($mulValues as $values) {
                         if ($val = CRM_Utils_Array::key($values, $stateAbbr)) {
                             $formatted[$key][] = $val;
                         } else {
                             if ($val = CRM_Utils_Array::key($values, $stateName)) {
                                 $formatted[$key][] = $val;
                             }
                         }
                     }
                     break;
                 case 'Multi-Select Country':
                     $config =& CRM_Core_Config::singleton();
                     $limitCodes = $config->countryLimit();
                     $mulValues = explode(',', $field);
                     $formatted[$key] = array();
                     CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', true, 'name', 'is_active');
                     CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', true, 'iso_code');
                     foreach ($mulValues as $values) {
                         if ($val = CRM_Utils_Array::key($values, $countryNames)) {
                             $formatted[$key][] = $val;
                         } else {
                             if ($val = CRM_Utils_Array::key($values, $countryIsoCodes)) {
                                 $formatted[$key][] = $val;
                             } else {
                                 if ($val = CRM_Utils_Array::key($values, $limitCodes)) {
                                     $formatted[$key][] = $val;
                                 }
                             }
                         }
                     }
                     break;
             }
         }
     }
     // check for primary location type, whether it is already present for the contact or not, CRM-4423
     if (CRM_Utils_Array::value('id', $formatted) && isset($formatted['location'])) {
         $primaryLocationTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($formatted['id'], true);
         if (isset($primaryLocationTypeId)) {
             foreach ($formatted['location'] as $loc => $details) {
                 if ($primaryLocationTypeId == CRM_Utils_Array::value('location_type_id', $details)) {
                     $formatted['location'][$loc]['is_primary'] = 1;
                     break;
                 } else {
                     $formatted['location'][$loc]['is_primary'] = 0;
                 }
             }
         }
     }
     // parse street address, CRM-5450
     if ($this->_parseStreetAddress) {
         require_once 'CRM/Core/BAO/Address.php';
         if (array_key_exists('address', $formatted) && is_array($formatted['address'])) {
             foreach ($formatted['address'] as $instance => &$address) {
                 $streetAddress = CRM_Utils_Array::value('street_address', $address);
                 if (empty($streetAddress)) {
                     continue;
                 }
                 // parse address field.
                 $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($streetAddress);
                 //street address consider to be parsed properly,
                 //If we get street_name and street_number.
                 if (!CRM_Utils_Array::value('street_name', $parsedFields) || !CRM_Utils_Array::value('street_number', $parsedFields)) {
                     $parsedFields = array_fill_keys(array_keys($parsedFields), '');
                 }
                 // merge parse address w/ main address block.
                 $address = array_merge($address, $parsedFields);
             }
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Contact.php

示例2: setProfileDefaults


//.........这里部分代码省略.........
                                                                     }
                                                                 } else {
                                                                     $label = CRM_Core_BAO_CustomOption::getOptionLabel($customFieldId, $details[$name]);
                                                                     $defaults[$fldName . '_id'] = $details[$name];
                                                                     $defaults[$fldName] = $label;
                                                                 }
                                                                 break;
                                                             case 'Select Date':
                                                                 list($defaults[$fldName], $defaults[substr($fldName, 0, -1) . '_time]']) = CRM_Utils_Date::setDateDefaults($details[$name]);
                                                                 break;
                                                             default:
                                                                 $defaults[$fldName] = $details[$name];
                                                                 break;
                                                         }
                                                     } else {
                                                         $defaults[$fldName] = $details[$name];
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $name, 3);
                 if (is_array($details)) {
                     foreach ($details as $key => $value) {
                         // when we fixed CRM-5319 - get primary loc
                         // type as per loc field and removed below code.
                         if ($locTypeId == 'Primary') {
                             $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId);
                         }
                         if (is_numeric($locTypeId)) {
                             //fixed for CRM-665
                             if ($locTypeId == CRM_Utils_Array::value('location_type_id', $value)) {
                                 if (CRM_Utils_Array::value($fieldName, $value)) {
                                     //to handle stateprovince and country
                                     if ($fieldName == 'state_province') {
                                         $defaults[$fldName] = $value['state_province_id'];
                                     } else {
                                         if ($fieldName == 'county') {
                                             $defaults[$fldName] = $value['county_id'];
                                         } else {
                                             if ($fieldName == 'country') {
                                                 $defaults[$fldName] = $value['country_id'];
                                                 if (!isset($value['country_id']) || !$value['country_id']) {
                                                     $config =& CRM_Core_Config::singleton();
                                                     if ($config->defaultContactCountry) {
                                                         $defaults[$fldName] = $config->defaultContactCountry;
                                                     }
                                                 }
                                             } else {
                                                 if ($fieldName == 'phone') {
                                                     if ($phoneTypeId) {
                                                         if ($value['phone'][$phoneTypeId]) {
                                                             $defaults[$fldName] = $value['phone'][$phoneTypeId];
                                                         }
                                                     } else {
                                                         $defaults[$fldName] = $value['phone'];
                                                     }
                                                 } else {
                                                     if ($fieldName == 'email') {
                                                         //adding the first email (currently we don't support multiple emails of same location type)
开发者ID:bhirsch,项目名称:voipdev,代码行数:67,代码来源:UFGroup.php

示例3: setProfileDefaults


//.........这里部分代码省略.........
                             if (!empty($customFields[$customFieldId]['date_format'])) {
                                 $dateFormat = $customFields[$customFieldId]['date_format'];
                             }
                             if (empty($customFields[$customFieldId]['time_format'])) {
                                 list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL, $dateFormat);
                             } else {
                                 $timeElement = $fldName . '_time';
                                 if (substr($fldName, -1) == ']') {
                                     $timeElement = substr($fldName, 0, -1) . '_time]';
                                 }
                                 list($defaults[$fldName], $defaults[$timeElement]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL, $dateFormat, $customFields[$customFieldId]['time_format']);
                             }
                             break;
                         default:
                             $defaults[$fldName] = $details[$name];
                             break;
                     }
                 } else {
                     $defaults[$fldName] = $details[$name];
                 }
             } else {
                 $blocks = array('email', 'phone', 'im', 'openid');
                 list($fieldName, $locTypeId, $phoneTypeId) = CRM_Utils_System::explode('-', $name, 3);
                 if (!in_array($fieldName, $multipleFields)) {
                     if (is_array($details)) {
                         foreach ($details as $key => $value) {
                             // when we fixed CRM-5319 - get primary loc
                             // type as per loc field and removed below code.
                             $primaryLocationType = FALSE;
                             if ($locTypeId == 'Primary') {
                                 if (is_array($value) && array_key_exists($fieldName, $value)) {
                                     $primaryLocationType = TRUE;
                                     if (in_array($fieldName, $blocks)) {
                                         $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId, FALSE, $fieldName);
                                     } else {
                                         $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId, FALSE, 'address');
                                     }
                                 }
                             }
                             // fixed for CRM-665
                             if (is_numeric($locTypeId)) {
                                 if ($primaryLocationType || $locTypeId == CRM_Utils_Array::value('location_type_id', $value)) {
                                     if (!empty($value[$fieldName])) {
                                         //to handle stateprovince and country
                                         if ($fieldName == 'state_province') {
                                             $defaults[$fldName] = $value['state_province_id'];
                                         } elseif ($fieldName == 'county') {
                                             $defaults[$fldName] = $value['county_id'];
                                         } elseif ($fieldName == 'country') {
                                             if (!isset($value['country_id']) || !$value['country_id']) {
                                                 $config = CRM_Core_Config::singleton();
                                                 if ($config->defaultContactCountry) {
                                                     $defaults[$fldName] = $config->defaultContactCountry;
                                                 }
                                             } else {
                                                 $defaults[$fldName] = $value['country_id'];
                                             }
                                         } elseif ($fieldName == 'phone') {
                                             if ($phoneTypeId) {
                                                 if (isset($value['phone'][$phoneTypeId])) {
                                                     $defaults[$fldName] = $value['phone'][$phoneTypeId];
                                                 }
                                                 if (isset($value['phone_ext'][$phoneTypeId])) {
                                                     $defaults[str_replace('phone', 'phone_ext', $fldName)] = $value['phone_ext'][$phoneTypeId];
                                                 }
                                             } else {
开发者ID:rollox,项目名称:civicrm-core,代码行数:67,代码来源:UFGroup.php

示例4: postProcess

 /**
  * Process the user submitted custom data values.
  *
  * @access public
  * @return void
  */
 function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $data = array();
     $data['contact_type'] = 'Individual';
     //get the custom fields for the contact
     $customFields = CRM_Core_BAO_CustomField::getFields($data['contact_type']);
     $locationType = array();
     $count = 1;
     if ($this->_id) {
         $primaryLocationType = CRM_Contact_BAO_Contact::getPrimaryLocationType($this->_id);
     }
     $phoneLoc = 0;
     foreach ($params as $key => $value) {
         $keyValue = explode('-', $key);
         if (is_numeric($keyValue[1])) {
             if (!in_array($keyValue[1], $locationType)) {
                 $locationType[$count] = $keyValue[1];
                 $count++;
             }
             require_once 'CRM/Utils/Array.php';
             $loc = CRM_Utils_Array::key($keyValue[1], $locationType);
             $data['location'][$loc]['location_type_id'] = $keyValue[1];
             if ($this->_id) {
                 //get the primary location type
                 if ($keyValue[1] == $primaryLocationType) {
                     $data['location'][$loc]['is_primary'] = 1;
                 }
             } else {
                 if ($loc == 1) {
                     $data['location'][$loc]['is_primary'] = 1;
                 }
             }
             if ($keyValue[0] == 'name') {
                 $data['location'][$loc]['name'] = $value;
             } else {
                 if ($keyValue[0] == 'phone') {
                     $phoneLoc++;
                     if ($keyValue[2]) {
                         $data['location'][$loc]['phone'][$phoneLoc]['phone_type'] = $keyValue[2];
                     } else {
                         $data['location'][$loc]['phone'][$phoneLoc]['phone_type'] = '';
                         $data['location'][$loc]['phone'][$phoneLoc]['is_primary'] = 1;
                     }
                     $data['location'][$loc]['phone'][$phoneLoc]['phone'] = $value;
                 } else {
                     if ($keyValue[0] == 'email') {
                         $data['location'][$loc]['email'][1]['email'] = $value;
                         $data['location'][$loc]['email'][1]['is_primary'] = 1;
                     } else {
                         if ($keyValue[0] == 'im') {
                             $data['location'][$loc]['im'][1]['name'] = $value;
                             $data['location'][$loc]['im'][1]['is_primary'] = 1;
                         } else {
                             if ($keyValue[0] === 'state_province') {
                                 $data['location'][$loc]['address']['state_province_id'] = $value;
                             } else {
                                 if ($keyValue[0] === 'country') {
                                     $data['location'][$loc]['address']['country_id'] = $value;
                                 } else {
                                     $data['location'][$loc]['address'][$keyValue[0]] = $value;
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if ($key === 'individual_suffix') {
                 $data['suffix_id'] = $value;
             } else {
                 if ($key === 'individual_prefix') {
                     $data['prefix_id'] = $value;
                 } else {
                     if ($key === 'gender') {
                         $data['gender_id'] = $value;
                     } else {
                         if (substr($key, 0, 6) === 'custom') {
                             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
                                 //fix checkbox
                                 if ($customFields[$customFieldID][3] == 'CheckBox') {
                                     $value = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, array_keys($value));
                                 }
                                 if ($customFields[$customFieldID][3] == 'Multi-Select') {
                                     $value = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $value);
                                 }
                                 // fix the date field
                                 if ($customFields[$customFieldID][2] == 'Date') {
                                     $date = CRM_Utils_Date::format($value);
                                     if (!$date) {
                                         $date = '';
                                     }
                                     $value = $date;
                                 }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:101,代码来源:Form.php


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