本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getFields方法的具体用法?PHP CRM_Core_BAO_UFGroup::getFields怎么用?PHP CRM_Core_BAO_UFGroup::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* pre processing work done here.
*
* gets session variables for group or field id
*
* @param
*
* @return void
*
* @access public
*
*/
function preProcess()
{
// Inline forms don't get menu-level permission checks
if (!CRM_Core_Permission::check('access CiviCRM')) {
CRM_Core_Error::fatal(ts('Permission denied'));
}
$gid = CRM_Utils_Request::retrieve('id', 'Positive');
$fields = CRM_Core_BAO_UFGroup::getFields($gid);
$this->setProfile($fields);
}
示例2: get_participant_custom_data_fields
function get_participant_custom_data_fields()
{
list($custom_pre_id, $custom_post_id) = self::get_profile_groups($this->participant->event_id);
$pre_fields = $post_fields = array();
if ($custom_pre_id && CRM_Core_BAO_UFGroup::filterUFGroups($custom_pre_id, $this->participant->contact_id)) {
$pre_fields = CRM_Core_BAO_UFGroup::getFields($custom_pre_id, FALSE, CRM_Core_Action::ADD);
}
if ($custom_post_id && CRM_Core_BAO_UFGroup::filterUFGroups($custom_post_id, $this->participant->contact_id)) {
$post_fields = CRM_Core_BAO_UFGroup::getFields($custom_post_id, FALSE, CRM_Core_Action::ADD);
}
return array($pre_fields, $post_fields);
}
示例3: buildQuickForm
function buildQuickForm()
{
$this->add('text', 'email', ts('Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'email'), true);
$fields = CRM_Core_BAO_UFGroup::getFields($this->_profileID, false, CRM_Core_Action::ADD, null, null, false, null, true);
$this->assign('custom', $fields);
require_once 'CRM/Profile/Form.php';
foreach ($fields as $key => $field) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例4: preProcess
/**
* @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register|CRM_Financial_Form_Payment $form
* @param null $type
* @param null $mode
*
* @throws Exception
*/
public static function preProcess(&$form, $type = NULL, $mode = NULL)
{
if ($type) {
$form->_type = $type;
} else {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', $form);
}
if ($form->_type) {
$form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode);
}
if (empty($form->_paymentProcessor)) {
// This would happen when hitting the back-button on a multi-page form with a $0 selection in play.
return;
}
$form->set('paymentProcessor', $form->_paymentProcessor);
$form->_paymentObject = System::singleton()->getByProcessor($form->_paymentProcessor);
$form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());
$form->assign('currency', CRM_Utils_Array::value('currency', $form->_values));
// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
$form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(NULL, NULL, 'cancel');
}
if (!empty($form->_values['custom_pre_id'])) {
$profileAddressFields = array();
$fields = CRM_Core_BAO_UFGroup::getFields($form->_values['custom_pre_id'], FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
foreach ((array) $fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $form->_values['custom_pre_id']));
}
if (count($profileAddressFields)) {
$form->set('profileAddressFields', $profileAddressFields);
}
}
//checks after setting $form->_paymentProcessor
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor, CRM_Utils_Request::retrieve('billing_profile_id', 'String'));
$form->assign_by_ref('paymentProcessor', $form->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
//@todo - determine if this is legacy and remove
if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !$form->_paymentObject->supports('MultipleConcurrentPayments'))) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type'])));
}
}
示例5: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
}
$this->_title = ts('Update multiple contacts') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->addDefaultButtons(ts('Save'));
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
// remove file type field and then limit fields
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
$suppressFields = TRUE;
unset($this->_fields[$name]);
}
}
//FIX ME: phone ext field is added at the end and it gets removed because of below code
//$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Contact(s)'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->assign('profileTitle', $this->_title);
$this->assign('componentIds', $this->_contactIds);
// if below fields are missing we should not reset sort name / display name
// CRM-6794
$preserveDefaultsArray = array('first_name', 'last_name', 'middle_name', 'organization_name', 'prefix_id', 'suffix_id', 'household_name');
foreach ($this->_contactIds as $contactId) {
$profileFields = $this->_fields;
CRM_Core_BAO_Address::checkContactSharedAddressFields($profileFields, $contactId);
foreach ($profileFields as $name => $field) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
if (in_array($field['name'], $preserveDefaultsArray)) {
$this->_preserveDefault = FALSE;
}
}
}
$this->assign('fields', $this->_fields);
// don't set the status message when form is submitted.
$buttonName = $this->controller->getButtonName('submit');
if ($suppressFields && $buttonName != '_qf_BatchUpdateProfile_next') {
CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple contacts."), ts('Some Fields Excluded'), 'info');
}
$this->addDefaultButtons(ts('Update Contacts'));
$this->addFormRule(array('CRM_Contact_Form_Task_Batch', 'formRule'));
}
示例6: buildQuickForm
/**
* Build form for honoree contact / on behalf of organization.
*
* @param CRM_Core_Form $form
*
*/
public static function buildQuickForm(&$form)
{
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $form->_honoreeProfileId;
if (!$ufGroup->find(TRUE)) {
CRM_Core_Error::fatal(ts('Chosen honoree profile for this contribution is disabled'));
}
$prefix = 'honor';
$honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields($form->_honoreeProfileId, FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::CREATE);
$form->addElement('hidden', 'honoree_profile_id', $form->_honoreeProfileId);
$form->assign('honoreeProfileFields', $honoreeProfileFields);
// add the form elements
foreach ($honoreeProfileFields as $name => $field) {
// If soft credit type is not chosen then make omit requiredness from honoree profile fields
if (count($form->_submitValues) && empty($form->_submitValues['soft_credit_type_id']) && !empty($field['is_required'])) {
$field['is_required'] = FALSE;
}
CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, $prefix);
}
}
示例7: preProcess
/**
* pre processing work done here.
*
* gets session variables for group or field id
*
* @param
* @return void
*
* @access public
*
*/
function preProcess()
{
require_once 'CRM/Core/BAO/UFGroup.php';
$flag = false;
$field = CRM_Utils_Request::retrieve('field', $this, true, 0);
$fid = $this->get('fieldId');
$this->_gid = $this->get('id');
if ($field) {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, null, null, null, true);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid);
}
// preview for field
if ($field) {
$fieldDAO =& new CRM_Core_DAO_UFField();
$fieldDAO->id = $fid;
$fieldDAO->find(true);
$name = $fieldDAO->field_name;
if ($fieldDAO->location_type_id) {
$name .= '-' . $fieldDAO->location_type_id;
}
if ($fieldDAO->phone_type) {
$name .= '-' . $fieldDAO->phone_type;
}
$fieldArray[$name] = $this->_fields[$name];
$this->_fields = $fieldArray;
if (!is_array($this->_fields[$name])) {
$flag = true;
}
$this->assign('previewField', true);
}
if ($flag) {
$this->assign('viewOnly', false);
} else {
$this->assign('viewOnly', true);
}
$this->set('fieldId', null);
$this->assign("fields", $this->_fields);
}
示例8: buildQuickForm
/**
* Build the form
*
* @access public
*
* @return void
*/
function buildQuickForm()
{
$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
}
$this->_title = ts('Batch Update for Activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->addDefaultButtons(ts('Save'));
$this->_fields = array();
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
// remove file type field and then limit fields
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
$suppressFields = TRUE;
unset($this->_fields[$name]);
}
//fix to reduce size as we are using this field in grid
if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
//shrink class to "form-text-medium"
$this->_fields[$name]['attributes']['size'] = 19;
}
}
$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Activities'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->assign('profileTitle', $this->_title);
$this->assign('componentIds', $this->_activityHolderIds);
$fileFieldExists = FALSE;
//load all campaigns.
if (array_key_exists('activity_campaign_id', $this->_fields)) {
$this->_componentCampaigns = array();
CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Activity_DAO_Activity', TRUE, 'campaign_id', 'id', ' id IN (' . implode(' , ', array_values($this->_activityHolderIds)) . ' ) ');
}
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
foreach ($this->_activityHolderIds as $activityId) {
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$customValue = CRM_Utils_Array::value($customFieldID, $customFields);
if (!empty($customValue['extends_entity_column_value'])) {
$entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value']);
}
if (!empty($entityColumnValue[$typeId]) || CRM_Utils_System::isNull($entityColumnValue[$typeId])) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
} else {
// handle non custom fields
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
}
}
$this->assign('fields', $this->_fields);
// don't set the status message when form is submitted.
// $buttonName = $this->controller->getButtonName('submit');
if ($suppressFields) {
CRM_Core_Session::setStatus(ts("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update."), ts("Some fields have been excluded"), "info");
}
$this->addDefaultButtons(ts('Update Activities'));
}
示例9: buildCustom
/**
* Function to add the custom fields
*
* @return None
* @access public
*/
function buildCustom($id, $name, $viewOnly = FALSE, $onBehalf = FALSE, $fieldTypes = NULL)
{
$stateCountryMap = array();
if ($id) {
$contactID = $this->getContactID();
// we don't allow conflicting fields to be
// configured via profile - CRM 2100
$fieldsToIgnore = array('receive_date' => 1, 'trxn_id' => 1, 'invoice_id' => 1, 'net_amount' => 1, 'fee_amount' => 1, 'non_deductible_amount' => 1, 'total_amount' => 1, 'amount_level' => 1, 'contribution_status_id' => 1, 'payment_instrument' => 1, 'check_number' => 1, 'financial_type' => 1);
$fields = NULL;
if ($contactID && CRM_Core_BAO_UFGroup::filterUFGroups($id, $contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
} else {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
}
if ($fields) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
if (substr($fieldName, 0, 6) == 'email-') {
unset($fields[$fieldName]);
}
}
if (array_intersect_key($fields, $fieldsToIgnore)) {
$fields = array_diff_key($fields, $fieldsToIgnore);
CRM_Core_Session::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
}
$fields = array_diff_assoc($fields, $this->_fields);
CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if ($viewOnly && isset($field['data_type']) && $field['data_type'] == 'File' || $viewOnly && $field['name'] == 'image_URL') {
// ignore file upload fields
continue;
}
list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') {
if (!array_key_exists($index, $stateCountryMap)) {
$stateCountryMap[$index] = array();
}
$stateCountryMap[$index][$prefixName] = $key;
}
if ($onBehalf) {
if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
$this->_fields['onbehalf'][$key] = $field;
} else {
unset($fields[$key]);
}
} else {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
$this->_fields[$key] = $field;
}
// CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
if ($field['add_captcha'] && !$this->_userID) {
$addCaptcha = TRUE;
}
}
$this->assign($name, $fields);
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
if ($addCaptcha && !$viewOnly) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
}
}
}
示例10: setDefaultValues
/**
* Set the default values.
*/
public function setDefaultValues()
{
// check if the user is registered and we have a contact ID
$contactID = $this->getContactID();
if (!empty($contactID)) {
$fields = array();
$removeCustomFieldTypes = array('Contribution', 'Membership');
$contribFields = CRM_Contribute_BAO_Contribution::getContributionFields();
// remove component related fields
foreach ($this->_fields as $name => $dontCare) {
//don't set custom data Used for Contribution (CRM-1344)
if (substr($name, 0, 7) == 'custom_') {
$id = substr($name, 7);
if (!CRM_Core_BAO_CustomGroup::checkCustomField($id, $removeCustomFieldTypes)) {
continue;
}
// ignore component fields
} elseif (array_key_exists($name, $contribFields) || substr($name, 0, 11) == 'membership_' || substr($name, 0, 13) == 'contribution_') {
continue;
}
$fields[$name] = 1;
}
if (!empty($fields)) {
CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $this->_defaults);
}
$billingDefaults = $this->getProfileDefaults('Billing', $contactID);
$this->_defaults = array_merge($this->_defaults, $billingDefaults);
}
if (!empty($this->_ccid) && !empty($this->_pendingAmount)) {
$this->_defaults['total_amount'] = CRM_Utils_Money::format($this->_pendingAmount, NULL, '%a');
}
/*
* hack to simplify credit card entry for testing
*
* $this->_defaults['credit_card_type'] = 'Visa';
* $this->_defaults['amount'] = 168;
* $this->_defaults['credit_card_number'] = '4111111111111111';
* $this->_defaults['cvv2'] = '000';
* $this->_defaults['credit_card_exp_date'] = array('Y' => date('Y')+1, 'M' => '05');
* // hack to simplify direct debit entry for testing
* $this->_defaults['account_holder'] = 'Max Müller';
* $this->_defaults['bank_account_number'] = '12345678';
* $this->_defaults['bank_identification_number'] = '12030000';
* $this->_defaults['bank_name'] = 'Bankname';
*/
//build set default for pledge overdue payment.
if (!empty($this->_values['pledge_id'])) {
//used to record completed pledge payment ids used later for honor default
$completedContributionIds = array();
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($this->_values['pledge_id']);
$paymentAmount = 0;
$duePayment = FALSE;
foreach ($pledgePayments as $payId => $value) {
if ($value['status'] == 'Overdue') {
$this->_defaults['pledge_amount'][$payId] = 1;
$paymentAmount += $value['scheduled_amount'];
} elseif (!$duePayment && $value['status'] == 'Pending') {
$this->_defaults['pledge_amount'][$payId] = 1;
$paymentAmount += $value['scheduled_amount'];
$duePayment = TRUE;
} elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
$completedContributionIds[] = $value['contribution_id'];
}
}
$this->_defaults['price_' . $this->_priceSetId] = $paymentAmount;
if (count($completedContributionIds)) {
$softCredit = array();
foreach ($completedContributionIds as $id) {
$softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id);
}
if (isset($softCredit['soft_credit'])) {
$this->_defaults['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
//since honoree profile fieldname of fields are prefixed with 'honor'
//we need to reformat the fieldname to append prefix during setting default values
CRM_Core_BAO_UFGroup::setProfileDefaults($softCredit['soft_credit'][1]['contact_id'], CRM_Core_BAO_UFGroup::getFields($this->_honoreeProfileId), $defaults);
foreach ($defaults as $fieldName => $value) {
$this->_defaults['honor[' . $fieldName . ']'] = $value;
}
}
}
} elseif (!empty($this->_values['pledge_block_id'])) {
//set default to one time contribution.
$this->_defaults['is_pledge'] = 0;
}
// to process Custom data that are appended to URL
$getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
$this->_defaults = array_merge($this->_defaults, $getDefaults);
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (empty($this->_defaults["billing_country_id-{$this->_bltID}"])) {
$this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
// set default state/province from config if no state/province set
if (empty($this->_defaults["billing_state_province_id-{$this->_bltID}"])) {
$this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$entityId = $memtypeID = NULL;
//.........这里部分代码省略.........
示例11: displayProfile
/**
* Function to build the array for display the profile fields
*
* @param array $params key value.
* @param int $gid profile Id
* @param array $groupTitle Profile Group Title.
* @param array $values formatted array of key value
*
* @return None
* @access public
*/
function displayProfile(&$params, $gid, &$groupTitle, &$values)
{
if ($gid) {
require_once 'CRM/Core/BAO/UFGroup.php';
require_once 'CRM/Profile/Form.php';
require_once 'CRM/Event/PseudoConstant.php';
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($contactID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($gid, false, CRM_Core_Action::VIEW);
}
} else {
$fields = CRM_Core_BAO_UFGroup::getFields($gid, false, CRM_Core_Action::ADD);
}
if (is_array($fields)) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
if (substr($fieldName, 0, 6) == 'email-') {
unset($fields[$fieldName]);
}
}
}
foreach ($fields as $v) {
if (CRM_Utils_Array::value('groupTitle', $v)) {
$groupTitle['groupTitle'] = $v["groupTitle"];
break;
}
}
$config = CRM_Core_Config::singleton();
require_once 'CRM/Core/PseudoConstant.php';
$locationTypes = $imProviders = array();
$locationTypes = CRM_Core_PseudoConstant::locationType();
$imProviders = CRM_Core_PseudoConstant::IMProvider();
//start of code to set the default values
foreach ($fields as $name => $field) {
$index = $field['title'];
$customFieldName = null;
if ($name === 'organization_name') {
$values[$index] = $params[$name];
}
if ('state_province' == substr($name, 0, 14)) {
if ($params[$name]) {
$values[$index] = CRM_Core_PseudoConstant::stateProvince($params[$name]);
} else {
$values[$index] = '';
}
} else {
if ('country' == substr($name, 0, 7)) {
if ($params[$name]) {
$values[$index] = CRM_Core_PseudoConstant::country($params[$name]);
} else {
$values[$index] = '';
}
} else {
if ('county' == substr($name, 0, 6)) {
if ($params[$name]) {
$values[$index] = CRM_Core_PseudoConstant::county($params[$name]);
} else {
$values[$index] = '';
}
} else {
if ('gender' == substr($name, 0, 6)) {
$gender = CRM_Core_PseudoConstant::gender();
$values[$index] = $gender[$params[$name]];
} else {
if ('individual_prefix' == substr($name, 0, 17)) {
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$values[$index] = $prefix[$params[$name]];
} else {
if ('individual_suffix' == substr($name, 0, 17)) {
$suffix = CRM_Core_PseudoConstant::individualSuffix();
$values[$index] = $suffix[$params[$name]];
} else {
if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
$filterCondition = array('greeting_type' => $name);
$greeting =& CRM_Core_PseudoConstant::greeting($filterCondition);
$values[$index] = $greeting[$params[$name]];
} else {
if ($name === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::pcm();
$pref = array();
$compref = array();
$pref = $params[$name];
if (is_array($pref)) {
foreach ($pref as $k => $v) {
if ($v) {
$compref[] = $communicationFields[$k];
}
//.........这里部分代码省略.........
示例12: buildCustom
/**
* Function to add the custom fields
*
* @param $id
* @param $name
* @param bool $viewOnly
* @param null $profileContactType
* @param null $fieldTypes
*
* @return void
* @access public
*/
function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL)
{
if ($id) {
$contactID = $this->getContactID();
// we don't allow conflicting fields to be
// configured via profile - CRM 2100
$fieldsToIgnore = array('receive_date' => 1, 'trxn_id' => 1, 'invoice_id' => 1, 'net_amount' => 1, 'fee_amount' => 1, 'non_deductible_amount' => 1, 'total_amount' => 1, 'amount_level' => 1, 'contribution_status_id' => 1, 'payment_instrument' => 1, 'check_number' => 1, 'financial_type' => 1);
$fields = NULL;
if ($contactID && CRM_Core_BAO_UFGroup::filterUFGroups($id, $contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
} else {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
}
if ($fields) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
if (substr($fieldName, 0, 6) == 'email-' && $profileContactType != 'honor') {
unset($fields[$fieldName]);
}
}
if (array_intersect_key($fields, $fieldsToIgnore)) {
$fields = array_diff_key($fields, $fieldsToIgnore);
CRM_Core_Session::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
}
$fields = array_diff_assoc($fields, $this->_fields);
CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if ($viewOnly && isset($field['data_type']) && $field['data_type'] == 'File' || $viewOnly && $field['name'] == 'image_URL') {
// ignore file upload fields
continue;
}
if ($profileContactType) {
//Since we are showing honoree name separately so we are removing it from honoree profile just for display
$honoreeNamefields = array('prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name');
if ($profileContactType == 'honor' && in_array($field['name'], $honoreeNamefields)) {
unset($fields[$field['name']]);
continue;
}
if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE, $profileContactType);
$this->_fields[$profileContactType][$key] = $field;
} else {
unset($fields[$key]);
}
} else {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
$this->_fields[$key] = $field;
}
// CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
if ($field['add_captcha'] && !$this->_userID) {
$addCaptcha = TRUE;
}
}
$this->assign($name, $fields);
if ($addCaptcha && !$viewOnly) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
}
}
}
示例13: civicrm_api3_profile_apply
/**
* Apply profile.
*
* @deprecated - appears to be an internal function - should not be accessible via api
* Provide formatted values for profile fields.
*
* @param array $params
* Array of property name/value.
* pairs to profile field values
*
* @throws API_Exception
* @return array
*
* @todo add example
* @todo add test cases
*/
function civicrm_api3_profile_apply($params)
{
$profileFields = CRM_Core_BAO_UFGroup::getFields($params['profile_id'], FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::EDIT);
list($data, $contactDetails) = CRM_Contact_BAO_Contact::formatProfileContactParams($params, $profileFields, CRM_Utils_Array::value('contact_id', $params), $params['profile_id'], CRM_Utils_Array::value('contact_type', $params), CRM_Utils_Array::value('skip_custom', $params, FALSE));
if (empty($data)) {
throw new API_Exception('Unable to format profile parameters.');
}
return civicrm_api3_create_success($data);
}
示例14: getSurveyResponseFields
/**
* Get the valid survey response fields those.
* are configured with profile and custom fields.
*
* @param int $surveyId
* Survey id.
* @param int $surveyTypeId
* Survey activity type id.
*
* @return array
* an array of valid survey response fields.
*/
public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL)
{
if (empty($surveyId)) {
return array();
}
static $responseFields;
$cacheKey = "{$surveyId}_{$surveyTypeId}";
if (isset($responseFields[$cacheKey])) {
return $responseFields[$cacheKey];
}
$responseFields[$cacheKey] = array();
$profileId = self::getSurveyProfileId($surveyId);
if (!$profileId) {
return $responseFields;
}
if (!$surveyTypeId) {
$surveyTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'activity_type_id');
}
$profileFields = CRM_Core_BAO_UFGroup::getFields($profileId, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, 'field_name', TRUE);
//don't load these fields in grid.
$removeFields = array('File', 'RichTextEditor');
$supportableFieldTypes = self::surveyProfileTypes();
// get custom fields of type survey
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $surveyTypeId);
foreach ($profileFields as $name => $field) {
//get only contact and activity fields.
//later stage we might going to consider contact type also.
if (in_array($field['field_type'], $supportableFieldTypes)) {
// we should allow all supported custom data for survey
// In case of activity, allow normal activity and with subtype survey,
// suppress custom data of other activity types
if (CRM_Core_BAO_CustomField::getKeyID($name)) {
if (!in_array($field['html_type'], $removeFields)) {
if ($field['field_type'] != 'Activity') {
$responseFields[$cacheKey][$name] = $field;
} elseif (array_key_exists(CRM_Core_BAO_CustomField::getKeyID($name), $customFields)) {
$responseFields[$cacheKey][$name] = $field;
}
}
} else {
$responseFields[$cacheKey][$name] = $field;
}
}
}
return $responseFields[$cacheKey];
}
示例15: preProcess
/**
* pre processing work done here.
*
* gets session variables for group or field id
*
* @param
* @return void
*
* @access public
*
*/
function preProcess()
{
$flag = false;
$this->_gid = $this->get('id');
$this->set('gid', $this->_gid);
$field = CRM_Utils_Request::retrieve('field', 'Boolean', $this, true, 0);
if ($field) {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, null, null, null, true);
require_once 'CRM/Core/DAO/UFField.php';
$fieldDAO = new CRM_Core_DAO_UFField();
$fieldDAO->id = $this->get('fieldId');
$fieldDAO->find(true);
if ($fieldDAO->is_active == 0) {
CRM_Core_Error::statusBounce(ts('This field is inactive so it will not be displayed on profile form.'));
} elseif ($fieldDAO->is_view == 1) {
CRM_Core_Error::statusBounce(ts('This field is view only so it will not be displayed on profile form.'));
}
$name = $fieldDAO->field_name;
// preview for field
$specialFields = 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');
if ($fieldDAO->location_type_id) {
$name .= '-' . $fieldDAO->location_type_id;
} else {
if (in_array($name, $specialFields)) {
$name .= '-Primary';
}
}
if (isset($fieldDAO->phone_type)) {
$name .= '-' . $fieldDAO->phone_type;
}
$fieldArray[$name] = $this->_fields[$name];
$this->_fields = $fieldArray;
if (!is_array($this->_fields[$name])) {
$flag = true;
}
$this->assign('previewField', true);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid);
}
if ($flag) {
$this->assign('viewOnly', false);
} else {
$this->assign('viewOnly', true);
}
$this->set('fieldId', null);
$this->assign("fields", $this->_fields);
}