本文整理汇总了PHP中CRM_Core_BAO_CMSUser::buildForm方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CMSUser::buildForm方法的具体用法?PHP CRM_Core_BAO_CMSUser::buildForm怎么用?PHP CRM_Core_BAO_CMSUser::buildForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CMSUser
的用法示例。
在下文中一共展示了CRM_Core_BAO_CMSUser::buildForm方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
//.........这里部分代码省略.........
if ($this->_priceSetId && empty($this->_ccid)) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
//we allow premium for pledge during pledge creation only.
if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
//don't build pledge block when mid is passed
if (!$this->_mid && empty($this->_ccid)) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
//to create an cms user
if (!$this->_contactID && empty($this->_ccid)) {
$createCMSUser = FALSE;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
if (!is_array($this->_values['custom_post_id'])) {
$profileIDs = array($this->_values['custom_post_id']);
} else {
$profileIDs = $this->_values['custom_post_id'];
}
foreach ($profileIDs as $pid) {
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
$profileID = $pid;
$createCMSUser = TRUE;
break;
}
}
}
if ($createCMSUser) {
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
}
}
if ($this->_pcpId && empty($this->_ccid)) {
if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
$pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
// Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute');
if (!empty($text)) {
$pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
}
$this->assign('pcpSupporterText', $pcp_supporter_text);
}
$prms = array('id' => $this->_pcpId);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
if ($pcpInfo['is_honor_roll']) {
$this->assign('isHonor', TRUE);
$this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
$extraOption = array('onclick' => "return pcpAnonymous( );");
$elements = array();
$elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
$elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
$this->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
$this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
$this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
}
}
if (empty($this->_values['fee']) && empty($this->_ccid)) {
CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
}
//we have to load confirm contribution button in template
//when multiple payment processor as the user
//can toggle with payment processor selection
$billingModePaymentProcessors = 0;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $values) {
if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
$billingModePaymentProcessors++;
}
}
}
if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
$allAreBillingModeProcessors = TRUE;
} else {
$allAreBillingModeProcessors = FALSE;
}
if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
$submitButton = array('type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => ' ', 'isDefault' => TRUE);
// Add submit-once behavior when confirm page disabled
if (empty($this->_values['is_confirm_enabled'])) {
$submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
}
//change button name for updating contribution
if (!empty($this->_ccid)) {
$submitButton['name'] = ts('Confirm Payment');
}
$this->addButtons(array($submitButton));
}
$this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
}
示例2: buildQuickForm
//.........这里部分代码省略.........
//lets display status to primary page only.
$this->assign('waitlistMsg', $this->_waitlistMsg);
$this->assign('requireApprovalMsg', $this->_requireApprovalMsg);
$this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
$this->assign('isAdditionalParticipants', $isAdditionalParticipants);
//lets get js on two different qf elements.
$showHidePayfieldName = NULL;
$showHidePaymentInformation = FALSE;
if ($this->_values['event']['is_monetary']) {
self::buildAmount($this);
}
$pps = array();
//@todo this processor adding fn is another one duplicated on contribute - a shared
// common class would make this sort of thing extractable
$onlinePaymentProcessorEnabled = FALSE;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $name) {
if ($name['billing_mode'] == 1) {
$onlinePaymentProcessorEnabled = TRUE;
}
$pps[$key] = $name['name'];
}
}
if ($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) {
//@todo we are blocking for multiple registrations because we haven't tested
$this->addCidZeroOptions($onlinePaymentProcessorEnabled);
}
if (CRM_Utils_Array::value('is_pay_later', $this->_values['event']) && ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist)) {
$pps[0] = $this->_values['event']['pay_later_text'];
}
if ($this->_values['event']['is_monetary']) {
if (count($pps) > 1) {
$this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, " ");
} elseif (!empty($pps)) {
$ppKeys = array_keys($pps);
$currentPP = array_pop($ppKeys);
$this->addElement('hidden', 'payment_processor', $currentPP);
}
}
//lets add some qf element to bypass payment validations, CRM-4320
if ($bypassPayment) {
$this->addElement('hidden', 'bypass_payment', NULL, array('id' => 'bypass_payment'));
}
$this->assign('bypassPayment', $bypassPayment);
$this->assign('showHidePaymentInformation', $showHidePaymentInformation);
$userID = $this->getContactID();
if (!$userID) {
$createCMSUser = FALSE;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
if (!is_array($this->_values['custom_post_id'])) {
$profileIDs = array($this->_values['custom_post_id']);
} else {
$profileIDs = $this->_values['custom_post_id'];
}
foreach ($profileIDs as $pid) {
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
$profileID = $pid;
$createCMSUser = TRUE;
break;
}
}
}
if ($createCMSUser) {
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
}
}
//we have to load confirm contribution button in template
//when multiple payment processor as the user
//can toggle with payment processor selection
$billingModePaymentProcessors = 0;
if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $values) {
if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
$billingModePaymentProcessors++;
}
}
}
if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
$allAreBillingModeProcessors = TRUE;
} else {
$allAreBillingModeProcessors = FALSE;
}
if (!$allAreBillingModeProcessors || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment) {
//freeze button to avoid multiple calls.
$js = NULL;
if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
$js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
}
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE, 'js' => $js)));
}
$this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
// add pcp fields
if ($this->_pcpId) {
CRM_PCP_BAO_PCP::buildPcp($this->_pcpId, $this);
}
}
示例3: buildQuickForm
//.........这里部分代码省略.........
$this->assign('fields', $this->_fields);
$this->assign('fieldset', isset($this->_fieldset) ? $this->_fieldset : "");
// should we restrict what we display
$admin = TRUE;
if ($this->_mode == self::MODE_EDIT) {
$admin = FALSE;
// show all fields that are visibile:
// if we are a admin OR the same user OR acl-user with access to the profile
// or we have checksum access to this contact (i.e. the user without a login) - CRM-5909
if (CRM_Core_Permission::check('administer users') || $this->_id == $this->_currentUserID || $this->_isPermissionedChecksum || in_array($this->_gid, CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id')))) {
$admin = TRUE;
}
}
// if false, user is not logged-in.
$anonUser = FALSE;
if (!$this->_currentUserID) {
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$primaryLocationType = $defaultLocationType->id;
$anonUser = TRUE;
}
$this->assign('anonUser', $anonUser);
$addCaptcha = array();
$emailPresent = FALSE;
// add the form elements
foreach ($this->_fields as $name => $field) {
// make sure that there is enough permission to expose this field
if (!$admin && $field['visibility'] == 'User and User Admin Only') {
unset($this->_fields[$name]);
continue;
}
// since the CMS manages the email field, suppress the email display if in
// register mode which occur within the CMS form
if ($this->_mode == self::MODE_REGISTER && substr($name, 0, 5) == 'email') {
unset($this->_fields[$name]);
continue;
}
list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
if ($field['add_to_group_id']) {
$addToGroupId = $field['add_to_group_id'];
}
//build array for captcha
if ($field['add_captcha']) {
$addCaptcha[$field['group_id']] = $field['add_captcha'];
}
if ($name == 'email-Primary' || ($name == 'email-' . isset($primaryLocationType) ? $primaryLocationType : "")) {
$emailPresent = TRUE;
$this->_mail = $name;
}
}
// add captcha only for create mode.
if ($this->_mode == self::MODE_CREATE) {
// suppress captcha for logged in users only
if ($this->_currentUserID) {
$this->_isAddCaptcha = FALSE;
} elseif (!$this->_isAddCaptcha && !empty($addCaptcha)) {
$this->_isAddCaptcha = TRUE;
}
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
$dao->addSelect();
$dao->addSelect('is_update_dupe');
if ($dao->find(TRUE)) {
if ($dao->is_update_dupe) {
$this->_isUpdateDupe = $dao->is_update_dupe;
}
}
}
} else {
$this->_isAddCaptcha = FALSE;
}
//finally add captcha to form.
if ($this->_isAddCaptcha) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
}
$this->assign("isCaptcha", $this->_isAddCaptcha);
if ($this->_mode != self::MODE_SEARCH) {
if (isset($addToGroupId)) {
$this->_ufGroup['add_to_group_id'] = $addToGroupId;
}
}
//let's do set defaults for the profile
$this->setDefaultsValues();
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL);
if ($this->_mode == self::MODE_CREATE) {
CRM_Core_BAO_CMSUser::buildForm($this, $this->_gid, $emailPresent, $action);
} else {
$this->assign('showCMS', FALSE);
}
$this->assign('groupId', $this->_gid);
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
}
if ($this->_context == 'dialog') {
$this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
}
}
示例4: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$profileID = CRM_Core_DAO::getFieldValue('CRM_Auction_DAO_Auction', $this->_aid, 'donor_profile_id');
if (!$profileID) {
CRM_Core_Error::fatal('Profile not configured for this auction.');
}
require_once 'CRM/Auction/BAO/Item.php';
if (CRM_Auction_BAO_Item::isEmailInProfile($profileID)) {
$this->assign('profileDisplay', TRUE);
}
$fields = NULL;
require_once "CRM/Core/BAO/UFGroup.php";
if ($this->_donorID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($profileID, $this->_donorID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD);
}
$this->addFormRule(array('CRM_Auction_Form_ItemAccount', 'formRule'), $this);
} else {
require_once 'CRM/Core/BAO/CMSUser.php';
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
$fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD);
}
if ($fields) {
$this->assign('fields', $fields);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if (isset($field['data_type']) && $field['data_type'] == 'File') {
// ignore file upload fields
continue;
}
require_once "CRM/Core/BAO/UFGroup.php";
require_once "CRM/Profile/Form.php";
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
if ($field['add_captcha']) {
$addCaptcha = TRUE;
}
}
if ($addCaptcha) {
require_once 'CRM/Utils/ReCAPTCHA.php';
$captcha =& CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign("isCaptcha", TRUE);
}
}
$button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE);
$this->addButtons($button);
}
示例5: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$id = CRM_PCP_BAO_PCP::getSupporterProfileId($this->_pageId, $this->_component);
if (CRM_PCP_BAO_PCP::checkEmailProfile($id)) {
$this->assign('profileDisplay', TRUE);
}
$fields = NULL;
if ($this->_contactID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
}
$this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
} else {
CRM_Core_BAO_CMSUser::buildForm($this, $id, TRUE);
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
}
if ($fields) {
$this->assign('fields', $fields);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if (isset($field['data_type']) && $field['data_type'] == 'File') {
// ignore file upload fields
continue;
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
// CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
if ($field['add_captcha'] && !$this->_contactID) {
$addCaptcha = TRUE;
}
}
if ($addCaptcha) {
$captcha =& CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
}
if ($this->_component == 'contribute') {
$this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
} elseif ($this->_component == 'event') {
$this->assign('campaignName', CRM_Event_PseudoConstant::event($this->_pageId));
}
if ($this->_single) {
$button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
} else {
$button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE);
}
$this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
$this->addButtons($button);
}
示例6: buildQuickForm
//.........这里部分代码省略.........
if (!$userID) {
require_once 'CRM/Core/BAO/LocationType.php';
$defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
$primaryLocationType = $defaultLocationType->id;
$anonUser = true;
$this->assign('anonUser', true);
}
$addCaptcha = array();
$emailPresent = false;
// cache the state country fields. based on the results, we could use our javascript solution
// in create or register mode
$stateCountryMap = array();
// add the form elements
foreach ($this->_fields as $name => $field) {
// make sure that there is enough permission to expose this field
if (!$admin && $field['visibility'] == 'User and User Admin Only' || CRM_Utils_Array::value('is_view', $field)) {
unset($this->_fields[$name]);
continue;
}
// since the CMS manages the email field, suppress the email display if in
// register mode which occur within the CMS form
if ($this->_mode == self::MODE_REGISTER && substr($name, 0, 5) == 'email') {
unset($this->_fields[$name]);
continue;
}
list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
if ($prefixName == 'state_province' || $prefixName == 'country') {
if (!array_key_exists($index, $stateCountryMap)) {
$stateCountryMap[$index] = array();
}
$stateCountryMap[$index][$prefixName] = $name;
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
if ($field['add_to_group_id']) {
$addToGroupId = $field['add_to_group_id'];
}
//build array for captcha
if ($field['add_captcha']) {
$addCaptcha[$field['group_id']] = $field['add_captcha'];
}
if ($name == 'email-Primary' || ($name == 'email-' . isset($primaryLocationType) ? $primaryLocationType : "")) {
$emailPresent = true;
$this->_mail = $name;
}
}
$setCaptcha = false;
// do this only for CiviCRM created forms
if ($this->_mode == self::MODE_CREATE) {
if (!empty($addCaptcha)) {
$setCaptcha = true;
}
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
$dao->addSelect();
$dao->addSelect('add_captcha', 'is_update_dupe');
if ($dao->find(true)) {
if ($dao->add_captcha) {
$setCaptcha = true;
}
if ($dao->is_update_dupe) {
$this->_isUpdateDupe = true;
}
}
}
if ($setCaptcha) {
require_once 'CRM/Utils/ReCAPTCHA.php';
$captcha =& CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign("isCaptcha", true);
}
}
if ($this->_mode != self::MODE_SEARCH) {
if (isset($addToGroupId)) {
$this->add('hidden', "group[{$addToGroupId}]", 1);
$this->_addToGroupID = $addToGroupId;
}
}
// also do state country js
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap, $this->_defaults);
$action = CRM_Utils_Request::retrieve('action', 'String', $this, false, null);
if ($this->_mode == self::MODE_CREATE) {
require_once 'CRM/Core/BAO/CMSUser.php';
CRM_Core_BAO_CMSUser::buildForm($this, $this->_gid, $emailPresent, $action);
} else {
$this->assign('showCMS', false);
}
$this->assign('groupId', $this->_gid);
// now fix all state country selectors
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
}
if ($this->_context == 'dialog') {
$this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
}
}
示例7: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
require_once 'CRM/Contribute/BAO/PCP.php';
$id = CRM_Contribute_BAO_PCP::getSupporterProfileId($this->_pageId);
if (CRM_Contribute_BAO_PCP::checkEmailProfile($id)) {
$this->assign('profileDisplay', true);
}
$fields = null;
require_once "CRM/Core/BAO/UFGroup.php";
if ($this->_contactID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, false, CRM_Core_Action::ADD);
}
$this->addFormRule(array('CRM_Contribute_Form_PCP_PCPAccount', 'formRule'), $this);
} else {
require_once 'CRM/Core/BAO/CMSUser.php';
CRM_Core_BAO_CMSUser::buildForm($this, $id, true);
$fields = CRM_Core_BAO_UFGroup::getFields($id, false, CRM_Core_Action::ADD);
}
if ($fields) {
$this->assign('fields', $fields);
$addCaptcha = false;
foreach ($fields as $key => $field) {
if (isset($field['data_type']) && $field['data_type'] == 'File') {
// ignore file upload fields
continue;
}
require_once "CRM/Core/BAO/UFGroup.php";
require_once "CRM/Profile/Form.php";
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
if ($field['add_captcha']) {
$addCaptcha = true;
}
}
if ($addCaptcha) {
require_once 'CRM/Utils/ReCAPTCHA.php';
$captcha =& CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign("isCaptcha", true);
}
}
require_once "CRM/Contribute/PseudoConstant.php";
$this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
if ($this->_single) {
$button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
} else {
$button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true);
}
$this->addFormRule(array('CRM_Contribute_Form_PCP_PCPAccount', 'formRule'), $this);
$this->addButtons($button);
}
示例8: buildQuickForm
//.........这里部分代码省略.........
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
self::buildRecur($this);
}
} elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
}
if ($this->_priceSetId) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
if (!empty($this->_fields)) {
$profileAddressFields = array();
foreach ($this->_fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
}
$this->set('profileAddressFields', $profileAddressFields);
}
//to create an cms user
if (!$this->_userID) {
$createCMSUser = FALSE;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
if (!is_array($this->_values['custom_post_id'])) {
$profileIDs = array($this->_values['custom_post_id']);
} else {
$profileIDs = $this->_values['custom_post_id'];
}
foreach ($profileIDs as $pid) {
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
$profileID = $pid;
$createCMSUser = TRUE;
break;
}
}
}
if ($createCMSUser) {
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
}
}
if ($this->_pcpId) {
if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
$this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
}
$this->assign('pcp', TRUE);
$this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
$extraOption = array('onclick' => "return pcpAnonymous( );");
$elements = array();
$elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
$elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
$this->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
$this->_defaults['pcp_is_anonymous'] = 0;
$this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
$this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
}
//we have to load confirm contribution button in template
//when multiple payment processor as the user
//can toggle with payment processor selection
$billingModePaymentProcessors = 0;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $values) {
if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
$billingModePaymentProcessors++;
}
}
}
if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
$allAreBillingModeProcessors = TRUE;
} else {
$allAreBillingModeProcessors = FALSE;
}
if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => ' ', 'isDefault' => TRUE)));
}
$this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
}
示例9: buildQuickForm
//.........这里部分代码省略.........
if ((CRM_Utils_Array::value('is_multiple_registrations', $this->_values['event']) || $this->_priceSetId) && !$this->_allowConfirmation && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
$bypassPayment = true;
//case might be group become as a part of waitlist.
//If not waitlist then they require admin approve.
$allowGroupOnWaitlist = true;
$this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations));
if ($this->_requireApproval) {
$this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration(s) have been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
}
}
//case where only approval needed - no waitlist.
if ($this->_requireApproval && !$this->_allowWaitlist && !$bypassPayment) {
$this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
}
//lets display status to primary page only.
$this->assign('waitlistMsg', $this->_waitlistMsg);
$this->assign('requireApprovalMsg', $this->_requireApprovalMsg);
$this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
$this->assign('isAdditionalParticipants', $isAdditionalParticipants);
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
//lets get js on two different qf elements.
$buildExpressPayBlock = false;
$showHidePayfieldName = null;
$showHidePaymentInformation = false;
if ($this->_values['event']['is_monetary']) {
self::buildAmount($this);
$attributes = null;
$freezePayLater = true;
if (is_array($this->_paymentProcessor)) {
$freezePayLater = false;
if (!in_array($this->_paymentProcessor['billing_mode'], array(2, 4))) {
$showHidePayfieldName = 'payment_information';
$attributes = array('onclick' => "showHidePaymentInfo( );");
}
if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal_Express') {
$showHidePayfieldName = 'PayPalExpress';
$attributes = array('onclick' => "showHidePayPalExpressOption();");
}
}
//lets build only when there is no waiting and no required approval.
if ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist) {
if ($this->_values['event']['is_pay_later']) {
$element = $this->addElement('checkbox', 'is_pay_later', $this->_values['event']['pay_later_text'], null, $attributes);
//if payment processor is not available then freeze
//the paylater checkbox with default checked.
if ($freezePayLater) {
$element->freeze();
}
}
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::buildCreditCard($this);
if ($showHidePayfieldName == 'payment_information') {
$showHidePaymentInformation = true;
}
if ($showHidePayfieldName == 'PayPalExpress') {
$buildExpressPayBlock = true;
}
}
}
//lets add some qf element to bypass payment validations, CRM-4320
if ($bypassPayment) {
$attributes = null;
if ($showHidePayfieldName == 'payment_information' && $showHidePaymentInformation) {
$attributes = array('onclick' => "showHidePaymentInfo();");
}
if ($showHidePayfieldName == 'PayPalExpress') {
$attributes = array('onclick' => "showHidePayPalExpressOption();");
}
$this->addElement('hidden', 'bypass_payment', null, array('id' => 'bypass_payment'));
}
$this->assign('bypassPayment', $bypassPayment);
$this->assign('buildExpressPayBlock', $buildExpressPayBlock);
$this->assign('showHidePaymentInformation', $showHidePaymentInformation);
$userID = parent::getContactID();
if (!$userID) {
$createCMSUser = false;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
$profileID = $this->_values['custom_post_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if ($createCMSUser) {
require_once 'CRM/Core/BAO/CMSUser.php';
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true);
}
}
if ($this->_paymentProcessor['billing_mode'] != CRM_Core_Payment::BILLING_MODE_BUTTON || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment || !$buildExpressPayBlock) {
//freeze button to avoid multiple calls.
$js = null;
if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
$js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
}
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true, 'js' => $js)));
}
$this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
}
示例10: buildQuickForm
//.........这里部分代码省略.........
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = 1;
}
if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
$this->_useForMember = 1;
$this->set('useForMember', $this->_useForMember);
}
require_once 'CRM/Member/BAO/Membership.php';
$this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, true, null, false, $isTest, $this->_membershipContactID);
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
$this->assign('useForMember', $this->_useForMember);
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
if (isset($this->_priceSetId) && $this->_priceSetId) {
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::buildPriceSet($this);
} else {
if (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && $this->_paymentProcessor['is_recur']) {
self::buildRecur($this);
}
}
}
if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
$this->buildPayLater();
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
require_once 'CRM/Contribute/BAO/Premium.php';
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, true);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
require_once 'CRM/Pledge/BAO/PledgeBlock.php';
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
// doing this later since the express button type depends if there is an upload or not
if ($this->_values['is_monetary']) {
require_once 'CRM/Core/Payment/Form.php';
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
CRM_Core_Payment_Form::buildDirectDebit($this);
} else {
CRM_Core_Payment_Form::buildCreditCard($this);
}
}
//to create an cms user
if (!$this->_userID) {
$createCMSUser = false;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
$profileID = $this->_values['custom_post_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if ($createCMSUser) {
require_once 'CRM/Core/BAO/CMSUser.php';
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true);
}
}
if ($this->_pcpId) {
require_once 'CRM/Contribute/BAO/PCP.php';
if ($pcpSupporter = CRM_Contribute_BAO_PCP::displayName($this->_pcpId)) {
$this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
}
$this->assign('pcp', true);
$this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), null, null, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
$extraOption = array('onclick' => "return pcpAnonymous( );");
$elements = array();
$elements[] =& $this->createElement('radio', null, '', ts('Include my name and message'), 0, $extraOption);
$elements[] =& $this->createElement('radio', null, '', ts('List my contribution anonymously'), 1, $extraOption);
$this->addGroup($elements, 'pcp_is_anonymous', null, ' ');
$this->_defaults['pcp_is_anonymous'] = 0;
$this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
$this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
}
if (!($this->_paymentProcessor['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON && !$this->_values['is_pay_later'])) {
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => ' ', 'isDefault' => true)));
}
$this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
}