本文整理汇总了PHP中CRM_Price_BAO_Set::initSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_Set::initSet方法的具体用法?PHP CRM_Price_BAO_Set::initSet怎么用?PHP CRM_Price_BAO_Set::initSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_Set
的用法示例。
在下文中一共展示了CRM_Price_BAO_Set::initSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
//.........这里部分代码省略.........
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
// check for is_monetary status
$isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
$isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
if ($isMonetary && (!$isPayLater || CRM_Utils_Array::value('payment_processor_id', $this->_values))) {
$ppID = CRM_Utils_Array::value('payment_processor_id', $this->_values);
if (!$ppID) {
CRM_Core_Error::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
}
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
// check selected payment processor is active
if (empty($this->_paymentProcessor)) {
CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
// ensure that processor has a valid config
$this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$error = $this->_paymentObject->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
$this->_paymentProcessor['processorName'] = $this->_paymentObject->_processorName;
$this->set('paymentProcessor', $this->_paymentProcessor);
}
// get price info
// CRM-5095
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::initSet($this, $this->_id, 'civicrm_contribution_page');
// this avoids getting E_NOTICE errors in php
$setNullFields = array('amount_block_is_active', 'honor_block_is_active', 'is_allow_other_amount', 'footer_text');
foreach ($setNullFields as $f) {
if (!isset($this->_values[$f])) {
$this->_values[$f] = null;
}
}
//check if Membership Block is enabled, if Membership Fields are included in profile
//get membership section for this contribution page
require_once 'CRM/Member/BAO/Membership.php';
$this->_membershipBlock = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
$this->set('membershipBlock', $this->_membershipBlock);
require_once "CRM/Core/BAO/UFField.php";
if ($this->_values['custom_pre_id']) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_pre_id']);
}
if ($this->_values['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_post_id']);
}
// also set cancel subscription url
if (CRM_Utils_Array::value('is_recur', $this->_paymentProcessor) && CRM_Utils_Array::value('is_recur', $this->_values)) {
$this->_values['cancelSubscriptionUrl'] = $this->_paymentObject->cancelSubscriptionURL();
}
if ((isset($postProfileType) && $postProfileType == 'Membership' || isset($preProfileType) && $preProfileType == 'Membership') && !$this->_membershipBlock['is_active']) {
CRM_Core_Error::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
}
require_once 'CRM/Pledge/BAO/PledgeBlock.php';
$pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id);
if ($pledgeBlock) {
$this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock);
$this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock);
$this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock);
示例2: initPriceSet
static function initPriceSet(&$form, $eventID)
{
// get price info
require_once 'CRM/Price/BAO/Set.php';
$price = CRM_Price_BAO_Set::initSet($form, $eventID, 'civicrm_event');
if ($price == false) {
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventID}", $form->_values['fee'], true);
require_once 'CRM/Core/BAO/Discount.php';
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, "civicrm_event");
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $optionGroupId) {
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId);
CRM_Core_OptionGroup::getAssoc($name, $form->_values['discount'][$key], true);
$form->_values['discount'][$key]["name"] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId, 'label');
}
}
}
return $price;
}
示例3: initEventFee
static function initEventFee(&$form, $eventID)
{
// get price info
require_once 'CRM/Price/BAO/Set.php';
$price = CRM_Price_BAO_Set::initSet($form, $eventID, 'civicrm_event');
if ($price == false) {
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventID}", $form->_values['fee'], true);
require_once 'CRM/Core/BAO/Discount.php';
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, "civicrm_event");
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $optionGroupId) {
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId);
CRM_Core_OptionGroup::getAssoc($name, $form->_values['discount'][$key], true);
$form->_values['discount'][$key]["name"] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId, 'label');
}
}
}
$eventFee = CRM_Utils_Array::value('fee', $form->_values);
if (!is_array($eventFee) || empty($eventFee)) {
$form->_values['fee'] = array();
}
//fix for non-upgraded price sets.CRM-4256.
if (isset($form->_isPaidEvent)) {
$isPaidEvent = $form->_isPaidEvent;
} else {
$isPaidEvent = CRM_Utils_Array::value('is_monetary', $form->_values['event']);
}
if ($isPaidEvent && empty($form->_values['fee'])) {
CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId))));
}
}
示例4: preProcess
//.........这里部分代码省略.........
$ppIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ppID);
$this->_paymentProcessors = CRM_Core_BAO_PaymentProcessor::getPayments($ppIds, $this->_mode);
$this->set('paymentProcessors', $this->_paymentProcessors);
//set default payment processor
if (!empty($this->_paymentProcessors) && empty($this->_paymentProcessor)) {
foreach ($this->_paymentProcessors as $ppId => $values) {
if ($values['is_default'] == 1 || count($this->_paymentProcessors) == 1) {
$defaultProcessorId = $ppId;
break;
}
}
}
if (isset($defaultProcessorId)) {
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode);
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
}
if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
// check selected payment processor is active
if (empty($eachPaymentProcessor)) {
CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
// ensure that processor has a valid config
$this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
$error = $this->_paymentObject->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
}
}
}
// get price info
// CRM-5095
CRM_Price_BAO_Set::initSet($this, $this->_id, 'civicrm_contribution_page');
// this avoids getting E_NOTICE errors in php
$setNullFields = array('amount_block_is_active', 'honor_block_is_active', 'is_allow_other_amount', 'footer_text');
foreach ($setNullFields as $f) {
if (!isset($this->_values[$f])) {
$this->_values[$f] = NULL;
}
}
//check if Membership Block is enabled, if Membership Fields are included in profile
//get membership section for this contribution page
$this->_membershipBlock = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
$this->set('membershipBlock', $this->_membershipBlock);
if ($this->_values['custom_pre_id']) {
$preProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_pre_id']);
}
if ($this->_values['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_post_id']);
}
if ((isset($postProfileType) && $postProfileType == 'Membership' || isset($preProfileType) && $preProfileType == 'Membership') && !$this->_membershipBlock['is_active']) {
CRM_Core_Error::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
}
$pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id);
if ($pledgeBlock) {
$this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock);
$this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock);
$this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock);
$this->_values['additional_reminder_day'] = CRM_Utils_Array::value('additional_reminder_day', $pledgeBlock);
//set pledge id in values
$pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
//authenticate pledge user for pledge payment.
if ($pledgeId) {
$this->_values['pledge_id'] = $pledgeId;
//lets override w/ pledge campaign.
示例5: initEventFee
static function initEventFee(&$form, $eventID)
{
// get price info
// retrive all active price set fields.
$discountId = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'option_group_id');
$price = CRM_Price_BAO_Set::initSet($form, $eventID, 'civicrm_event', TRUE, $priceSetId);
} else {
$price = CRM_Price_BAO_Set::initSet($form, $eventID, 'civicrm_event', TRUE);
}
$eventFee = CRM_Utils_Array::value('fee', $form->_values);
if (!is_array($eventFee) || empty($eventFee)) {
$form->_values['fee'] = array();
}
//fix for non-upgraded price sets.CRM-4256.
if (isset($form->_isPaidEvent)) {
$isPaidEvent = $form->_isPaidEvent;
} else {
$isPaidEvent = CRM_Utils_Array::value('is_monetary', $form->_values['event']);
}
if ($isPaidEvent && empty($form->_values['fee'])) {
if (CRM_Utils_System::getClassName($form) != 'CRM_Event_Form_Participant') {
CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId))));
}
}
}