本文整理汇总了PHP中CRM_Activity_BAO_Activity::getProfileFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::getProfileFields方法的具体用法?PHP CRM_Activity_BAO_Activity::getProfileFields怎么用?PHP CRM_Activity_BAO_Activity::getProfileFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::getProfileFields方法的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: getFields
/**
* get all the fields that belong to the group with the name title
*
* @param mix $id the id of the UF group or ids of ufgroup
* @param int $register are we interested in registration fields
* @param int $action what action are we doing
* @param int $visibility visibility of fields we are interested in
* @param $searchable
* @param boolean $showall
* @param string $restrict should we restrict based on a specified profile type
*
* @return array the fields that belong to this ufgroup(s)
* @static
* @access public
*/
static function getFields($id, $register = FALSE, $action = NULL, $visibility = NULL, $searchable = NULL, $showAll = FALSE, $restrict = NULL, $skipPermission = FALSE, $ctype = NULL, $permissionType = CRM_Core_Permission::CREATE, $orderBy = 'field_name', $orderProfiles = NULL)
{
if (!is_array($id)) {
$id = CRM_Utils_Type::escape($id, 'Positive');
$profileIds = array($id);
} else {
$profileIds = $id;
}
$gids = implode(',', $profileIds);
$params = array();
if ($restrict) {
$query = "SELECT g.* from civicrm_uf_group g, civicrm_uf_join j\n WHERE g.id IN ( {$gids} )\n AND j.uf_group_id IN ( {$gids} )\n AND j.module = %1\n ";
$params = array(1 => array($restrict, 'String'));
} else {
$query = "SELECT g.* from civicrm_uf_group g WHERE g.id IN ( {$gids} ) ";
}
if (!$showAll) {
$query .= " AND g.is_active = 1";
}
// add permissioning for profiles only if not registration
if (!$skipPermission) {
$permissionClause = CRM_Core_Permission::ufGroupClause($permissionType, 'g.');
$query .= " AND {$permissionClause} ";
}
if ($orderProfiles and count($profileIds) > 1) {
$query .= " ORDER BY FIELD( g.id, {$gids} )";
}
$group = CRM_Core_DAO::executeQuery($query, $params);
$fields = array();
$validGroup = FALSE;
while ($group->fetch()) {
$validGroup = TRUE;
$where = " WHERE uf_group_id = {$group->id}";
if ($searchable) {
$where .= " AND is_searchable = 1";
}
if (!$showAll) {
$where .= " AND is_active = 1";
}
if ($visibility) {
$clause = array();
if ($visibility & self::PUBLIC_VISIBILITY) {
$clause[] = 'visibility = "Public Pages"';
}
if ($visibility & self::ADMIN_VISIBILITY) {
$clause[] = 'visibility = "User and User Admin Only"';
}
if ($visibility & self::LISTINGS_VISIBILITY) {
$clause[] = 'visibility = "Public Pages and Listings"';
}
if (!empty($clause)) {
$where .= ' AND ( ' . implode(' OR ', $clause) . ' ) ';
}
}
$query = "SELECT * FROM civicrm_uf_field {$where} ORDER BY weight";
if ($orderBy) {
$query .= ", " . $orderBy;
}
$field = CRM_Core_DAO::executeQuery($query);
if (!$showAll) {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All');
} else {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, TRUE);
}
$profileType = CRM_Core_BAO_UFField::getProfileType($group->id);
$contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($group->id);
if ($profileType == 'Activity' || $contactActivityProfile) {
$componentFields = CRM_Activity_BAO_Activity::getProfileFields();
} else {
$componentFields = CRM_Core_Component::getQueryFields();
}
$importableFields = array_merge($importableFields, $componentFields);
$importableFields['group']['title'] = ts('Group(s)');
$importableFields['group']['where'] = NULL;
$importableFields['tag']['title'] = ts('Tag(s)');
$importableFields['tag']['where'] = NULL;
$locationFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'county', 'phone', 'email', 'im', 'address_name');
//get location type
$locationType = array();
$locationType = CRM_Core_PseudoConstant::locationType();
$customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype);
// hack to add custom data for components
$components = array('Contribution', 'Participant', 'Membership', 'Activity');
foreach ($components as $value) {
$customFields = array_merge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value));
//.........这里部分代码省略.........
示例3: getImportableFields
/**
* @param $showAll
* @param $profileType
* @param $contactActivityProfile
*
* @return array
*/
protected static function getImportableFields($showAll, $profileType, $contactActivityProfile)
{
if (!$showAll) {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, FALSE, FALSE, TRUE, TRUE);
} else {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, TRUE, FALSE, TRUE, TRUE);
}
if ($profileType == 'Activity' || $contactActivityProfile) {
$componentFields = CRM_Activity_BAO_Activity::getProfileFields();
} else {
$componentFields = CRM_Core_Component::getQueryFields();
}
$importableFields = array_merge($importableFields, $componentFields);
$importableFields['group']['title'] = ts('Group(s)');
$importableFields['group']['where'] = NULL;
$importableFields['tag']['title'] = ts('Tag(s)');
$importableFields['tag']['where'] = NULL;
return $importableFields;
}
示例4: buildQuickForm
//.........这里部分代码省略.........
unset($participantFields['participant_contact_id']);
unset($participantFields['participant_role_id']);
unset($participantFields['participant_status_id']);
unset($participantFields['participant_is_test']);
unset($participantFields['participant_fee_level']);
unset($participantFields['participant_id']);
unset($participantFields['participant_is_pay_later']);
if (isset($participantFields['participant_campaign_id'])) {
$participantFields['participant_campaign_id']['title'] = ts('Campaign');
if (isset($participantFields['participant_campaign'])) {
unset($participantFields['participant_campaign']);
}
}
$fields['Participant'] =& $participantFields;
}
}
if (CRM_Core_Permission::access('CiviMember')) {
$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']);
if ($this->_gid && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'name') == 'membership_batch_entry') {
$fields['Membership'] =& array_merge($membershipFields, $this->_memberBatchEntryFields);
} else {
$fields['Membership'] =& $membershipFields;
}
}
$activityFields = CRM_Activity_BAO_Activity::getProfileFields();
if (!empty($activityFields)) {
//unset campaign related fields.
if (isset($activityFields['activity_campaign_id'])) {
$activityFields['activity_campaign_id']['title'] = ts('Campaign');
}
$fields['Activity'] = $activityFields;
}
$formattingFields["format_free_html_" . rand(1000, 9999)] = array("name" => "free_html", "import" => FALSE, "export" => FALSE, "title" => "Free HTML");
$fields["Formatting"] = $formattingFields;
$noSearchable = 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);
// 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'];
}
}
}