本文整理汇总了PHP中CRM_Member_BAO_Membership::getMembershipFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::getMembershipFields方法的具体用法?PHP CRM_Member_BAO_Membership::getMembershipFields怎么用?PHP CRM_Member_BAO_Membership::getMembershipFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_BAO_Membership::getMembershipFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableFields
/**
* Get a list of fields which can be added to profiles.
*
* @param int $gid : UF group ID
* @param array $defaults : Form defaults
* @return array, multidimensional; e.g. $result['FieldGroup']['field_name']['label']
*/
public static function getAvailableFields($gid = NULL, $defaults = array())
{
$fields = array('Contact' => array(), 'Individual' => CRM_Contact_BAO_Contact::importableFields('Individual', FALSE, FALSE, TRUE, TRUE, TRUE), 'Household' => CRM_Contact_BAO_Contact::importableFields('Household', FALSE, FALSE, TRUE, TRUE, TRUE), 'Organization' => CRM_Contact_BAO_Contact::importableFields('Organization', FALSE, FALSE, TRUE, TRUE, TRUE));
// include hook injected fields
$fields['Contact'] = array_merge($fields['Contact'], CRM_Contact_BAO_Query_Hook::singleton()->getFields());
// add current employer for individuals
$fields['Individual']['current_employer'] = array('name' => 'organization_name', 'title' => ts('Current Employer'));
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
if (!$addressOptions['county']) {
unset($fields['Individual']['county'], $fields['Household']['county'], $fields['Organization']['county']);
}
// break out common contact fields array CRM-3037.
// from a UI perspective this makes very little sense
foreach ($fields['Individual'] as $key => $value) {
if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) {
$fields['Contact'][$key] = $value;
unset($fields['Individual'][$key], $fields['Household'][$key], $fields['Organization'][$key]);
}
}
// Internal field not exposed to forms
unset($fields['Contact']['contact_type']);
unset($fields['Contact']['master_id']);
// convert phone extension in to psedo-field phone + phone extension
//unset extension
unset($fields['Contact']['phone_ext']);
//add psedo field
$fields['Contact']['phone_and_ext'] = array('name' => 'phone_and_ext', 'title' => ts('Phone and Extension'), 'hasLocationType' => 1);
// include Subtypes For Profile
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $name => $val) {
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($name, FALSE, FALSE, FALSE, TRUE, TRUE);
if (array_key_exists($val['parent'], $fields)) {
$fields[$name] = $fields[$val['parent']] + $subTypeFields;
} else {
$fields[$name] = $subTypeFields;
}
}
if (CRM_Core_Permission::access('CiviContribute')) {
$contribFields = CRM_Contribute_BAO_Contribution::getContributionFields(FALSE);
if (!empty($contribFields)) {
unset($contribFields['is_test']);
unset($contribFields['is_pay_later']);
unset($contribFields['contribution_id']);
$contribFields['contribution_note'] = array('name' => 'contribution_note', 'title' => ts('Contribution Note'));
$fields['Contribution'] = array_merge($contribFields, self::getContribBatchEntryFields());
}
}
if (CRM_Core_Permission::access('CiviEvent')) {
$participantFields = CRM_Event_BAO_Query::getParticipantFields();
if ($participantFields) {
// Remove fields not supported by profiles
CRM_Utils_Array::remove($participantFields, 'external_identifier', 'event_id', 'participant_contact_id', 'participant_role_id', 'participant_status_id', 'participant_is_test', 'participant_fee_level', 'participant_id', 'participant_is_pay_later', 'participant_campaign');
if (isset($participantFields['participant_campaign_id'])) {
$participantFields['participant_campaign_id']['title'] = ts('Campaign');
}
$fields['Participant'] = $participantFields;
}
}
if (CRM_Core_Permission::access('CiviMember')) {
$membershipFields = CRM_Member_BAO_Membership::getMembershipFields();
// Remove fields not supported by profiles
CRM_Utils_Array::remove($membershipFields, 'membership_id', 'membership_type_id', 'member_is_test', 'is_override', 'status_id', 'member_is_pay_later');
if ($gid && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gid, 'name') == 'membership_batch_entry') {
$fields['Membership'] = array_merge($membershipFields, self::getMemberBatchEntryFields());
} else {
$fields['Membership'] = $membershipFields;
}
}
if (CRM_Core_Permission::access('CiviCase')) {
$caseFields = CRM_Case_BAO_Query::getFields(TRUE);
$caseFields = array_merge($caseFields, CRM_Core_BAO_CustomField::getFieldsForImport('Case'));
if ($caseFields) {
// Remove fields not supported by profiles
CRM_Utils_Array::remove($caseFields, 'case_id', 'case_type', 'case_start_date', 'case_end_date', 'case_role', 'case_status', 'case_deleted');
}
$fields['Case'] = $caseFields;
}
$activityFields = CRM_Activity_BAO_Activity::getProfileFields();
if ($activityFields) {
// campaign related fields.
if (isset($activityFields['activity_campaign_id'])) {
$activityFields['activity_campaign_id']['title'] = ts('Campaign');
}
$fields['Activity'] = $activityFields;
}
$fields['Formatting']['format_free_html_' . rand(1000, 9999)] = array('name' => 'free_html', 'import' => FALSE, 'export' => FALSE, 'title' => 'Free HTML');
// Sort by title
foreach ($fields as &$values) {
$values = CRM_Utils_Array::crmArraySortByField($values, 'title');
}
//group selected and unwanted fields list
$ufFields = $gid ? CRM_Core_BAO_UFGroup::getFields($gid, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE) : array();
//.........这里部分代码省略.........
示例2: buildMappingForm
//.........这里部分代码省略.........
}
if (array_key_exists('note', $fields['Contact'])) {
$noteTitle = $fields['Contact']['note']['title'];
$fields['Contact']['note']['title'] = $noteTitle . ': ' . ts('Body and Subject');
$fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body');
$fields['Contact']['note_subject'] = array('title' => $noteTitle . ': ' . ts('Subject Only'), 'name' => 'note_subject');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
if (CRM_Core_Permission::access('CiviContribute')) {
$fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields();
foreach (array('contribution_contact_id', 'contribution_soft_credit_name', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', 'contribution_soft_credit_contribution_id') as $element) {
unset($fields['Contribution'][$element]);
}
$compArray['Contribution'] = ts('Contribution');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
if (CRM_Core_Permission::access('CiviEvent')) {
$fields['Participant'] = CRM_Event_BAO_Participant::exportableFields();
//get the component payment fields
if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
$componentPaymentFields = array();
foreach (CRM_Export_BAO_Export::componentPaymentFields() as $payField => $payTitle) {
$componentPaymentFields[$payField] = array('title' => $payTitle);
}
$fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields);
}
$compArray['Participant'] = ts('Participant');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
if (CRM_Core_Permission::access('CiviMember')) {
$fields['Membership'] = CRM_Member_BAO_Membership::getMembershipFields($exportMode);
unset($fields['Membership']['membership_contact_id']);
$compArray['Membership'] = ts('Membership');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
if (CRM_Core_Permission::access('CiviPledge')) {
$fields['Pledge'] = CRM_Pledge_BAO_Pledge::exportableFields();
unset($fields['Pledge']['pledge_contact_id']);
$compArray['Pledge'] = ts('Pledge');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
if (CRM_Core_Permission::access('CiviCase')) {
$fields['Case'] = CRM_Case_BAO_Case::exportableFields();
$compArray['Case'] = ts('Case');
$fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Case');
$compArray['Activity'] = ts('Case Activity');
unset($fields['Case']['case_contact_id']);
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
if (CRM_Core_Permission::access('CiviGrant')) {
$fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
unset($fields['Grant']['grant_contact_id']);
if ($mappingType == 'Search Builder') {
unset($fields['Grant']['grant_type_id']);
}
$compArray['Grant'] = ts('Grant');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
$fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Activity');
示例3: buildQuickForm
//.........这里部分代码省略.........
$fields[$name] = $subTypeFields;
}
}
unset($subTypes);
if (CRM_Core_Permission::access('Quest')) {
require_once 'CRM/Quest/BAO/Student.php';
$fields['Student'] =& CRM_Quest_BAO_Student::exportableFields();
}
if (CRM_Core_Permission::access('CiviContribute')) {
$contribFields =& CRM_Contribute_BAO_Contribution::getContributionFields();
if (!empty($contribFields)) {
unset($contribFields['is_test']);
unset($contribFields['is_pay_later']);
unset($contribFields['contribution_id']);
$fields['Contribution'] =& $contribFields;
}
}
if (CRM_Core_Permission::access('CiviEvent')) {
require_once 'CRM/Event/BAO/Query.php';
$participantFields =& CRM_Event_BAO_Query::getParticipantFields(true);
if (!empty($participantFields)) {
unset($participantFields['external_identifier']);
unset($participantFields['event_id']);
unset($participantFields['participant_contact_id']);
unset($participantFields['participant_is_test']);
unset($participantFields['participant_fee_level']);
unset($participantFields['participant_id']);
unset($participantFields['participant_is_pay_later']);
$fields['Participant'] =& $participantFields;
}
}
if (CRM_Core_Permission::access('CiviMember')) {
require_once 'CRM/Member/BAO/Membership.php';
$membershipFields =& CRM_Member_BAO_Membership::getMembershipFields();
unset($membershipFields['membership_id']);
unset($membershipFields['join_date']);
unset($membershipFields['membership_start_date']);
unset($membershipFields['membership_type_id']);
unset($membershipFields['membership_end_date']);
unset($membershipFields['member_is_test']);
unset($membershipFields['is_override']);
unset($membershipFields['status_id']);
unset($membershipFields['member_is_pay_later']);
$fields['Membership'] =& $membershipFields;
}
$noSearchable = array();
foreach ($fields as $key => $value) {
foreach ($value as $key1 => $value1) {
//CRM-2676, replacing the conflict for same custom field name from different custom group.
require_once 'CRM/Core/BAO/CustomField.php';
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;
} else {
$this->_mapperFields[$key][$key1] = $value1['title'];
}
$hasLocationTypes[$key][$key1] = CRM_Utils_Array::value('hasLocationType', $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'];
}
}
}
}
示例4: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if ($this->_gid) {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'title');
$this->setPageTitle(ts('Profile Field'));
$url = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
$breadCrumb = array(array('title' => ts('CiviCRM Profile Fields'), 'url' => $url));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
$showBestResult = CRM_Utils_Request::retrieve('sbr', 'Positive', CRM_Core_DAO::$_nullArray);
if ($showBestResult) {
$this->assign('showBestResult', $showBestResult);
}
$this->_fields = CRM_Contact_BAO_Contact::importableFields('All', TRUE, TRUE, TRUE, TRUE, TRUE);
$this->_fields = array_merge(CRM_Activity_BAO_Activity::exportableFields('Activity'), $this->_fields);
//unset campaign related fields.
if (isset($this->_fields['activity_campaign_id'])) {
$this->_fields['activity_campaign_id']['title'] = ts('Campaign');
if (isset($this->_fields['activity_campaign'])) {
unset($this->_fields['activity_campaign']);
}
}
if (CRM_Core_Permission::access('CiviContribute')) {
$this->_fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(FALSE), $this->_fields);
$this->_fields = array_merge(CRM_Core_BAO_UFField::getContribBatchEntryFields(), $this->_fields);
}
if (CRM_Core_Permission::access('CiviMember')) {
$this->_fields = array_merge(CRM_Member_BAO_Membership::getMembershipFields(), $this->_fields);
}
if (CRM_Core_Permission::access('CiviEvent')) {
$this->_fields = array_merge(CRM_Event_BAO_Query::getParticipantFields(), $this->_fields);
}
if (CRM_Core_Permission::access('CiviCase')) {
$this->_fields = array_merge(CRM_Case_BAO_Query::getFields(), $this->_fields);
}
$this->_fields = array_merge($this->_fields, CRM_Contact_BAO_Query_Hook::singleton()->getFields());
$this->_selectFields = array();
foreach ($this->_fields as $name => $field) {
// lets skip note for now since we dont support it
if ($name == 'note') {
continue;
}
$this->_selectFields[$name] = $field['title'];
$this->_hasLocationTypes[$name] = CRM_Utils_Array::value('hasLocationType', $field);
}
// lets add group, tag and current_employer to this list
$this->_selectFields['group'] = ts('Group(s)');
$this->_selectFields['tag'] = ts('Tag(s)');
$this->_selectFields['current_employer'] = ts('Current Employer');
$this->_selectFields['phone_and_ext'] = ts('Phone and Extension');
//CRM-4363 check for in selector or searchable fields.
$this->_hasSearchableORInSelector = CRM_Core_BAO_UFField::checkSearchableORInSelector($this->_gid);
$this->assign('fieldId', $this->_id);
if ($this->_id) {
$fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $this->_id, 'label');
$this->assign('fieldTitle', $fieldTitle);
}
}