本文整理汇总了PHP中CRM_Core_BAO_CustomField::getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::getDefaultValue方法的具体用法?PHP CRM_Core_BAO_CustomField::getDefaultValue怎么用?PHP CRM_Core_BAO_CustomField::getDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::getDefaultValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
function setDefaultValues()
{
// check if the user is registered and we have a contact ID
$session =& CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($contactID) {
$options = array();
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$fields['state_province'] = $fields['country'] = $fields['email'] = 1;
$contact =& CRM_Contact_BAO_Contact::contactDetails($contactID, $options, $fields);
foreach ($fields as $name => $dontCare) {
if ($contact->{$name}) {
if (substr($name, 0, 7) == 'custom_') {
$id = substr($name, 7);
$this->_defaults[$name] = CRM_Core_BAO_CustomField::getDefaultValue($contact->{$name}, $id, $options);
} else {
$this->_defaults[$name] = $contact->{$name};
}
}
}
}
// hack to simplify credit card entry for testing
/**
$this->_defaults['credit_card_type'] = 'Visa';
$this->_defaults['credit_card_number'] = '4807731747657838';
$this->_defaults['cvv2'] = '000';
$this->_defaults['credit_card_exp_date'] = array( 'Y' => '2008', 'M' => '01' );
**/
return $this->_defaults;
}
示例2: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
$this->assignToTemplate();
$productID = $this->get('productID');
$option = $this->get('option');
$membershipTypeID = $this->get('membershipTypeID');
$this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
if ($productID) {
require_once 'CRM/Contribute/BAO/Premium.php';
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, false, $productID, $option);
}
$this->assign('lineItem', $this->_lineItem);
$this->assign('priceSetID', $this->_priceSetId);
$params = $this->_params;
$honor_block_is_active = $this->get('honor_block_is_active');
if ($honor_block_is_active && (!empty($params["honor_first_name"]) && !empty($params["honor_last_name"]) || !empty($params["honor_email"]))) {
$this->assign('honor_block_is_active', $honor_block_is_active);
$this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
require_once "CRM/Core/PseudoConstant.php";
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$honor = CRM_Core_PseudoConstant::honor();
$this->assign('honor_type', $honor[$params["honor_type_id"]]);
$this->assign('honor_prefix', $params["honor_prefix_id"] ? $prefix[$params["honor_prefix_id"]] : ' ');
$this->assign('honor_first_name', $params["honor_first_name"]);
$this->assign('honor_last_name', $params["honor_last_name"]);
$this->assign('honor_email', $params["honor_email"]);
}
//pcp elements
if ($this->_pcpId) {
$this->assign('pcpBlock', true);
foreach (array('pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note') as $val) {
if (CRM_Utils_Array::value($val, $this->_params)) {
$this->assign($val, $this->_params[$val]);
}
}
}
if ($membershipTypeID) {
$transactionID = $this->get('membership_trx_id');
$membershipAmount = $this->get('membership_amount');
$renewalMode = $this->get('renewal_mode');
$this->assign('membership_trx_id', $transactionID);
$this->assign('membership_amount', $membershipAmount);
$this->assign('renewal_mode', $renewalMode);
CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, false, $membershipTypeID, true, null, $this->_membershipContactID);
}
$this->_separateMembershipPayment = $this->get('separateMembershipPayment');
$this->assign("is_separate_payment", $this->_separateMembershipPayment);
$this->buildCustom($this->_values['custom_pre_id'], 'customPre', true);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', true);
$this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $this->_params));
$this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params)));
$defaults = array();
$options = array();
$fields = array();
require_once "CRM/Core/BAO/CustomGroup.php";
$removeCustomFieldTypes = array('Contribution');
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$fields['state_province'] = $fields['country'] = $fields['email'] = 1;
$contact = $this->_params = $this->controller->exportValues('Main');
foreach ($fields as $name => $dontCare) {
if (isset($contact[$name])) {
if (substr($name, 0, 7) == 'custom_') {
$id = substr($name, 7);
$defaults[$name] = CRM_Core_BAO_CustomField::getDefaultValue($contact[$name], $id, $options);
} else {
$defaults[$name] = $contact[$name];
if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $contact)) {
$defaults[$name . '_custom'] = $contact[$name . '_custom'];
}
}
}
}
$this->setDefaults($defaults);
require_once 'CRM/Friend/BAO/Friend.php';
$values['entity_id'] = $this->_id;
$values['entity_table'] = 'civicrm_contribution_page';
CRM_Friend_BAO_Friend::retrieve($values, $data);
$tellAFriend = false;
if ($this->_pcpId) {
if ($this->_pcpBlock['is_tellfriend_enabled']) {
$this->assign('friendText', ts('Tell a Friend'));
$subUrl = "eid={$this->_pcpId}&blockId={$this->_pcpBlock['id']}&page=pcp";
$tellAFriend = true;
}
} else {
if (CRM_Utils_Array::value('is_active', $data)) {
$friendText = $data['title'];
$this->assign('friendText', $friendText);
$subUrl = "eid={$this->_id}&page=contribution";
$tellAFriend = true;
}
}
//.........这里部分代码省略.........
示例3: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
$this->assignToTemplate();
require_once 'CRM/Contribute/BAO/Premium.php';
$params = $this->_params;
$honor_block_is_active = $this->get('honor_block_is_active');
// make sure we have values for it
if ($honor_block_is_active && (!empty($params["honor_first_name"]) && !empty($params["honor_last_name"]) || !empty($params["honor_email"]))) {
$this->assign('honor_block_is_active', $honor_block_is_active);
$this->assign("honor_block_title", CRM_Utils_Array::value('honor_block_title', $this->_values));
require_once "CRM/Core/PseudoConstant.php";
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$honor = CRM_Core_PseudoConstant::honor();
$this->assign("honor_type", CRM_Utils_Array::value($params["honor_type_id"], $honor));
$this->assign("honor_prefix", CRM_Utils_Array::value($params["honor_prefix_id"], $prefix));
$this->assign("honor_first_name", $params["honor_first_name"]);
$this->assign("honor_last_name", $params["honor_last_name"]);
$this->assign("honor_email", $params["honor_email"]);
}
$this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
$amount_block_is_active = $this->get('amount_block_is_active');
$this->assign('amount_block_is_active', $amount_block_is_active);
if (CRM_Utils_Array::value('selectProduct', $params) && $params['selectProduct'] != 'no_thanks') {
$option = CRM_Utils_Array::value('options_' . $params['selectProduct'], $params);
$productID = $params['selectProduct'];
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, false, $productID, $option);
$this->set('productID', $productID);
$this->set('option', $option);
}
$config =& CRM_Core_Config::singleton();
if (in_array("CiviMember", $config->enableComponents)) {
if (isset($params['selectMembership']) && $params['selectMembership'] != 'no_thanks') {
CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, false, $params['selectMembership'], false, null, $this->_membershipContactID);
} else {
$this->assign('membershipBlock', false);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre', true);
$this->buildCustom($this->_values['custom_post_id'], 'customPost', true);
$this->_separateMembershipPayment = $this->get('separateMembershipPayment');
$this->assign("is_separate_payment", $this->_separateMembershipPayment);
$this->assign('lineItem', $this->_lineItem);
$this->assign('priceSetID', $this->_priceSetId);
if ($this->_paymentProcessor['payment_processor_type'] == 'Google_Checkout' && !$this->_params['is_pay_later']) {
$this->_checkoutButtonName = $this->getButtonName('next', 'checkout');
$this->add('image', $this->_checkoutButtonName, $this->_paymentProcessor['url_button'], array('class' => 'form-submit'));
$this->addButtons(array(array('type' => 'back', 'name' => ts('<< Go Back'))));
} else {
if ($this->_contributeMode == 'notify' || !$this->_values['is_monetary'] || $this->_amount <= 0.0 || $this->_params['is_pay_later'] || $this->_separateMembershipPayment && $this->_amount <= 0.0) {
$contribButton = ts('Continue >>');
} else {
$contribButton = ts('Make Contribution');
}
$this->addButtons(array(array('type' => 'next', 'name' => $contribButton, 'spacing' => ' ', 'isDefault' => true, 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');")), array('type' => 'back', 'name' => ts('<< Go Back'))));
}
$defaults = array();
$options = array();
$fields = array();
require_once "CRM/Core/BAO/CustomGroup.php";
$removeCustomFieldTypes = array('Contribution');
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$fields["billing_state_province-{$this->_bltID}"] = $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1;
$contact = $this->_params;
foreach ($fields as $name => $dontCare) {
if (isset($contact[$name])) {
if (substr($name, 0, 7) == 'custom_') {
$id = substr($name, 7);
$defaults[$name] = CRM_Core_BAO_CustomField::getDefaultValue($contact[$name], $id, $options);
} else {
$defaults[$name] = $contact[$name];
if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $contact)) {
$defaults[$name . '_custom'] = $contact[$name . '_custom'];
}
}
}
}
// now fix all state country selectors
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
$this->setDefaults($defaults);
$this->freeze();
}