本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getLocationFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getLocationFields方法的具体用法?PHP CRM_Core_BAO_UFGroup::getLocationFields怎么用?PHP CRM_Core_BAO_UFGroup::getLocationFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getLocationFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertCiviModelToBackboneModel
/**
* FIXME: Move to somewhere more useful
* FIXME: Do real mapping of "types"
*
* @param string $extends
* Entity type; note: "Individual" means "Individual|Contact"; "Household" means "Household|Contact".
* @param string $title
* A string to use in section headers.
* @param array $availableFields
* List of fields that are allowed in profiles, e.g. $availableFields['my_field']['field_type'].
* @return array
* with keys 'sections' and 'schema'
* @see js/model/crm.core.js
* @see js/model/crm.mappedcore.js
*/
public static function convertCiviModelToBackboneModel($extends, $title, $availableFields)
{
$locationFields = CRM_Core_BAO_UFGroup::getLocationFields();
$result = array('schema' => array(), 'sections' => array());
// build field list
foreach ($availableFields as $fieldName => $field) {
switch ($extends) {
case 'Individual':
case 'Organization':
case 'Household':
if ($field['field_type'] != $extends && $field['field_type'] != 'Contact' && !in_array($field['field_type'], CRM_Contact_BAO_ContactType::subTypes($extends))) {
continue 2;
}
break;
default:
if ($field['field_type'] != $extends) {
continue 2;
}
}
$result['schema'][$fieldName] = array('type' => 'Text', 'title' => $field['title'], 'civiFieldType' => $field['field_type']);
if (in_array($fieldName, $locationFields)) {
$result['schema'][$fieldName]['civiIsLocation'] = TRUE;
}
if ($fieldName == 'url') {
$result['schema'][$fieldName]['civiIsWebsite'] = TRUE;
}
if (in_array($fieldName, array('phone', 'phone_and_ext'))) {
// FIXME what about phone_ext?
$result['schema'][$fieldName]['civiIsPhone'] = TRUE;
}
}
// build section list
$result['sections']['default'] = array('title' => $title, 'is_addable' => FALSE);
$customGroup = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity($extends);
$customGroup->orderBy('weight');
$customGroup->is_active = 1;
$customGroup->find();
while ($customGroup->fetch()) {
$sectionName = 'cg_' . $customGroup->id;
$section = array('title' => ts('%1: %2', array(1 => $title, 2 => $customGroup->title)), 'is_addable' => $customGroup->is_reserved ? FALSE : TRUE, 'custom_group_id' => $customGroup->id, 'extends_entity_column_id' => $customGroup->extends_entity_column_id, 'extends_entity_column_value' => CRM_Utils_Array::explodePadded($customGroup->extends_entity_column_value), 'is_reserved' => $customGroup->is_reserved ? TRUE : FALSE);
$result['sections'][$sectionName] = $section;
}
// put fields in their sections
$fields = CRM_Core_BAO_CustomField::getFields($extends);
foreach ($fields as $fieldId => $field) {
$sectionName = 'cg_' . $field['custom_group_id'];
$fieldName = 'custom_' . $fieldId;
if (isset($result['schema'][$fieldName])) {
$result['schema'][$fieldName]['section'] = $sectionName;
$result['schema'][$fieldName]['civiIsMultiple'] = (bool) CRM_Core_BAO_CustomField::isMultiRecordField($fieldId);
}
}
return $result;
}
示例2: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_UFField::retrieve($params, $defaults);
// set it to null if so (avoids crappy E_NOTICE errors below
$defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults);
$specialFields = CRM_Core_BAO_UFGroup::getLocationFields();
if (!$defaults['location_type_id'] && $defaults["field_type"] != "Formatting" && in_array($defaults['field_name'], $specialFields)) {
$defaults['location_type_id'] = 0;
}
$defaults['field_name'] = array($defaults['field_type'], $defaults['field_type'] == "Formatting" ? "" : $defaults['field_name'], $defaults['field_name'] == "url" ? $defaults['website_type_id'] : $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults));
$this->_gid = $defaults['uf_group_id'];
} else {
$defaults['is_active'] = 1;
}
$otherModules = array_values(CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid));
$this->assign('otherModules', $otherModules);
if ($this->_action & CRM_Core_Action::ADD) {
$fieldValues = array('uf_group_id' => $this->_gid);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues);
}
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
//hidden field to catch the group id in profile
$this->add('hidden', 'group_id', $this->_gid);
//hidden field to catch the field id in profile
$this->add('hidden', 'field_id', $this->_id);
$fields = CRM_Core_BAO_UFField::getAvailableFields($this->_gid, $defaults);
$noSearchable = $hasWebsiteTypes = array();
$addressCustomFields = array_keys(CRM_Core_BAO_CustomField::getFieldsForImport('Address'));
foreach ($fields as $key => $value) {
foreach ($value as $key1 => $value1) {
//CRM-2676, replacing the conflict for same custom field name from different custom group.
if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key1)) {
$customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldId, 'custom_group_id');
$customGroupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'title');
$this->_mapperFields[$key][$key1] = $value1['title'] . ' :: ' . $customGroupName;
if (in_array($key1, $addressCustomFields)) {
$noSearchable[] = $value1['title'] . ' :: ' . $customGroupName;
}
} else {
$this->_mapperFields[$key][$key1] = $value1['title'];
}
$hasLocationTypes[$key][$key1] = CRM_Utils_Array::value('hasLocationType', $value1);
$hasWebsiteTypes[$key][$key1] = CRM_Utils_Array::value('hasWebsiteType', $value1);
// hide the 'is searchable' field for 'File' custom data
if (isset($value1['data_type']) && isset($value1['html_type']) && ($value1['data_type'] == 'File' && $value1['html_type'] == 'File' || $value1['data_type'] == 'Link' && $value1['html_type'] == 'Link')) {
if (!in_array($value1['title'], $noSearchable)) {
$noSearchable[] = $value1['title'];
}
}
}
}
$this->assign('noSearchable', $noSearchable);
$this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$this->_website_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
/**
* FIXME: dirty hack to make the default option show up first. This
* avoids a mozilla browser bug with defaults on dynamically constructed
* selector widgets.
*/
if ($defaultLocationType) {
$defaultLocation = $this->_location_types[$defaultLocationType->id];
unset($this->_location_types[$defaultLocationType->id]);
$this->_location_types = array($defaultLocationType->id => $defaultLocation) + $this->_location_types;
}
$this->_location_types = array('Primary') + $this->_location_types;
// since we need a hierarchical list to display contact types & subtypes,
// this is what we going to display in first selector
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
unset($contactTypes['']);
$contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
$sel1 = array('' => '- select -') + $contactTypes;
if (!empty($fields['Activity'])) {
$sel1['Activity'] = 'Activity';
}
if (CRM_Core_Permission::access('CiviEvent')) {
$sel1['Participant'] = 'Participants';
}
if (!empty($fields['Contribution'])) {
$sel1['Contribution'] = 'Contributions';
}
if (!empty($fields['Membership'])) {
$sel1['Membership'] = 'Membership';
}
if (!empty($fields['Case'])) {
$sel1['Case'] = 'Case';
}
if (!empty($fields['Formatting'])) {
//.........这里部分代码省略.........