本文整理汇总了PHP中CRM_Price_BAO_PriceSet::initSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::initSet方法的具体用法?PHP CRM_Price_BAO_PriceSet::initSet怎么用?PHP CRM_Price_BAO_PriceSet::initSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Price_BAO_PriceSet
的用法示例。
在下文中一共展示了CRM_Price_BAO_PriceSet::initSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
//.........这里部分代码省略.........
$ppIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ppID);
$this->_paymentProcessors = CRM_Financial_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_Financial_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_PriceSet::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.
示例2: initEventFee
/**
* Initiate event fee.
*
* @param CRM_Core_Form $form
* @param int $eventID
*
* @throws Exception
*/
public static function initEventFee(&$form, $eventID)
{
// get price info
// retrive all active price set fields.
$discountId = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if (property_exists($form, '_discountId') && $form->_discountId) {
$discountId = $form->_discountId;
}
//CRM-16456 get all price field including expired one.
$getAllPriceField = TRUE;
$className = CRM_Utils_System::getClassName($form);
if ($className == 'CRM_Event_Form_ParticipantFeeSelection' && $form->_action == CRM_Core_Action::UPDATE) {
$getAllPriceField = FALSE;
}
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
$price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', $getAllPriceField, $priceSetId);
} else {
$price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', $getAllPriceField);
}
if (property_exists($form, '_context') && ($form->_context == 'standalone' || $form->_context == 'participant')) {
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, 'civicrm_event');
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $priceSetId) {
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$form->_values['discount'][$key] = CRM_Utils_Array::value('fields', $priceSet);
$fieldID = key($form->_values['discount'][$key]);
$form->_values['discount'][$key][$fieldID]['name'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'title');
}
}
}
$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 (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !empty($form->_values['fee'])) {
foreach ($form->_values['fee'] as $k => $fees) {
foreach ($fees['options'] as $options) {
if (!CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($options['financial_type_id']))) {
unset($form->_values['fee'][$k]);
}
}
}
}
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))));
}
}
}
示例3: initEventFee
/**
* @param $form
* @param $eventID
*
* @throws Exception
*/
static function initEventFee(&$form, $eventID)
{
// get price info
// retrive all active price set fields.
$discountId = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event');
if (property_exists($form, '_discountId') && $form->_discountId) {
$discountId = $form->_discountId;
}
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
$price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', TRUE, $priceSetId);
} else {
$price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', TRUE);
}
if (property_exists($form, '_context') && ($form->_context == 'standalone' || $form->_context == 'participant')) {
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, 'civicrm_event');
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $priceSetId) {
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$form->_values['discount'][$key] = CRM_Utils_Array::value('fields', $priceSet);
$fieldID = key($form->_values['discount'][$key]);
$form->_values['discount'][$key][$fieldID]['name'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'title');
}
}
}
$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))));
}
}
}