本文整理汇总了PHP中CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext方法的具体用法?PHP CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext怎么用?PHP CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionRecur
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess()
{
$this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->_crid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
}
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
}
if (!$this->_crid && !$this->_coid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
CRM_Core_Error::fatal('Required information missing.');
}
if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) {
CRM_Core_Error::fatal(ts('You cannot update the subscription.'));
}
if (!CRM_Core_Permission::check('edit contributions')) {
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
CRM_Core_Error::fatal(ts('You do not have permission to update subscription.'));
}
$this->_selfService = TRUE;
}
$this->assign('self_service', $this->_selfService);
if (!$this->_paymentProcessorObj->isSupported('changeSubscriptionAmount')) {
$userAlert = "<span class='font-red'>" . ts('Updates made using this form will change the recurring contribution information stored in your CiviCRM database, but will NOT be sent to the payment processor. You must enter the same changes using the payment processor web site.', array(1 => $this->_paymentProcessorObj->_processorName)) . '</span>';
CRM_Core_Session::setStatus($userAlert, ts('Warning'), 'alert');
}
$this->assign('isChangeSupported', $this->_paymentProcessorObj->isSupported('changeSubscriptionAmount'));
$this->assign('paymentProcessor', $this->_paymentProcessor);
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
if ($this->_subscriptionDetails->contact_id) {
list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
}
CRM_Utils_System::setTitle(ts('Update Recurring Contribution'));
// handle context redirection
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
}
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
$this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->_crid) {
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
$this->assign('installments', $this->_subscriptionDetails->installments);
// Are we cancelling a recurring contribution that is linked to an auto-renew membership?
if ($this->_subscriptionDetails->membership_id) {
$this->_mid = $this->_subscriptionDetails->membership_id;
}
}
if ($this->_mid) {
if (CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_mid)) {
CRM_Core_Error::fatal(ts('The auto renewal option for this membership looks to have been cancelled already.'));
}
$this->_mode = 'auto_renew';
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_mid, 'membership');
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
$this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes));
}
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
if ($this->_coid) {
if (CRM_Contribute_BAO_Contribution::isSubscriptionCancelled($this->_coid)) {
CRM_Core_Error::fatal(ts('The recurring contribution looks to have been cancelled already.'));
}
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
$this->assign('installments', $this->_subscriptionDetails->installments);
}
if (!$this->_crid && !$this->_coid && !$this->_mid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
CRM_Core_Error::fatal('Required information missing.');
}
if (!CRM_Core_Permission::check('edit contributions')) {
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
CRM_Core_Error::fatal(ts('You do not have permission to cancel this recurring contribution.'));
}
$this->_selfService = TRUE;
}
$this->assign('self_service', $this->_selfService);
// handle context redirection
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
CRM_Utils_System::setTitle($this->_mid ? ts('Cancel Auto-renewal') : ts('Cancel Recurring Contribution'));
$this->assign('mode', $this->_mode);
if ($this->_subscriptionDetails->contact_id) {
list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
}
}
示例3: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
$this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->_crid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
$this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
// Are we cancelling a recurring contribution that is linked to an auto-renew membership?
if ($this->_subscriptionDetails->membership_id) {
$this->_mid = $this->_subscriptionDetails->membership_id;
}
}
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
$this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
}
if ($this->_mid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'info');
$this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_mid, 'membership');
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
$this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes));
$this->_mode = 'auto_renew';
}
$this->_paymentProcessorObj = CRM_Utils_Array::value('object', $this->_paymentProcessor);
if (!$this->_crid && !$this->_coid && !$this->_mid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
CRM_Core_Error::fatal('Required information missing.');
}
if (!CRM_Core_Permission::check('edit contributions')) {
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
CRM_Core_Error::fatal(ts('You do not have permission to cancel subscription.'));
}
$this->_selfService = TRUE;
}
if (!$this->_paymentProcessor['object']->isSupported('updateSubscriptionBillingInfo')) {
CRM_Core_Error::fatal(ts("%1 processor doesn't support updating subscription billing details.", array(1 => $this->_paymentProcessor['object']->_processorName)));
}
$this->assign('paymentProcessor', $this->_paymentProcessor);
// get the billing location type
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
$this->_bltID = array_search('Billing', $locationTypes);
$this->assign('bltID', $this->_bltID);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
$this->assign('installments', $this->_subscriptionDetails->installments);
$this->assign('mode', $this->_mode);
// handle context redirection
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
}
示例4: preProcess
/**
* Pre-processing for the form.
*
* @throws \Exception
*/
public function preProcess()
{
$this->contributionRecurID = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->contributionRecurID) {
$this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
if (!$this->_paymentProcessor) {
CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
}
$this->_paymentProcessorObj = $this->_paymentProcessor['object'];
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID);
}
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
$this->contributionRecurID = $this->_subscriptionDetails->recur_id;
} elseif ($this->contributionRecurID) {
$this->_coid = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->contributionRecurID, 'id', 'contribution_recur_id');
}
if (!$this->contributionRecurID || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
CRM_Core_Error::fatal('Required information missing.');
}
if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) {
CRM_Core_Error::fatal(ts('You cannot update the subscription.'));
}
if (!CRM_Core_Permission::check('edit contributions')) {
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
CRM_Core_Error::fatal(ts('You do not have permission to update subscription.'));
}
$this->_selfService = TRUE;
}
$this->assign('self_service', $this->_selfService);
$this->editableScheduleFields = $this->_paymentProcessorObj->getEditableRecurringScheduleFields();
$changeHelpText = $this->_paymentProcessorObj->getRecurringScheduleUpdateHelpText();
if (!in_array('amount', $this->editableScheduleFields)) {
// Not sure if this is good behaviour - maintaining this existing behaviour for now.
CRM_Core_Session::setStatus($changeHelpText, ts('Warning'), 'alert');
} else {
$this->assign('changeHelpText', $changeHelpText);
}
$alreadyHardCodedFields = array('amount', 'installments');
foreach ($this->editableScheduleFields as $editableScheduleField) {
if (!in_array($editableScheduleField, $alreadyHardCodedFields)) {
$this->addField($editableScheduleField, array('entity' => 'ContributionRecur'));
}
}
$this->assign('editableScheduleFields', array_diff($this->editableScheduleFields, $alreadyHardCodedFields));
$this->assign('paymentProcessor', $this->_paymentProcessor);
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
if ($this->_subscriptionDetails->contact_id) {
list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
}
CRM_Utils_System::setTitle(ts('Update Recurring Contribution'));
// Handle context redirection.
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
}