本文整理汇总了PHP中CRM_Core_BAO_UFField::getAvailableFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFField::getAvailableFields方法的具体用法?PHP CRM_Core_BAO_UFField::getAvailableFields怎么用?PHP CRM_Core_BAO_UFField::getAvailableFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFField
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFField::getAvailableFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAvailable_full
/**
* When omitting a GID, return a list of all fields.
*/
public function testGetAvailable_full()
{
$fields = CRM_Core_BAO_UFField::getAvailableFields();
// Make sure that each entity appears with at least one field
$this->assertEquals('do_not_sms', $fields['Contact']['do_not_sms']['name']);
$this->assertEquals('city', $fields['Contact']['city']['name']);
$this->assertEquals('first_name', $fields['Individual']['first_name']['name']);
$this->assertEquals('birth_date', $fields['Individual']['birth_date']['name']);
$this->assertEquals('organization_name', $fields['Organization']['organization_name']['name']);
$this->assertEquals('legal_name', $fields['Organization']['legal_name']['name']);
$this->assertEquals('amount_level', $fields['Contribution']['amount_level']['name']);
$this->assertEquals('cancel_reason', $fields['Contribution']['cancel_reason']['name']);
$this->assertEquals('participant_note', $fields['Participant']['participant_note']['name']);
$this->assertEquals('participant_role', $fields['Participant']['participant_role']['name']);
$this->assertEquals('join_date', $fields['Membership']['join_date']['name']);
$this->assertEquals('end_date', $fields['Membership']['membership_end_date']['name']);
$this->assertEquals('activity_date_time', $fields['Activity']['activity_date_time']['name']);
$this->assertEquals('subject', $fields['Activity']['activity_subject']['name']);
// Make sure that some of the blacklisted fields don't appear
$this->assertFalse(isset($fields['Contribution']['is_pay_later']));
$this->assertFalse(isset($fields['Participant']['participant_role_id']));
$this->assertFalse(isset($fields['Membership']['membership_type_id']));
// This behavior is not necessarily desirable, but it's the status quo
$this->assertEquals('first_name', $fields['Staff']['first_name']['name']);
}
示例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'])) {
//.........这里部分代码省略.........