当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew方法代码示例

本文整理汇总了PHP中CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew方法的具体用法?PHP CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew怎么用?PHP CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Price_BAO_PriceSet的用法示例。


在下文中一共展示了CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: formRule

 /**
  * Validation.
  *
  * @param array $params
  *   (ref.) an assoc array of name/value pairs.
  *
  * @param $files
  * @param int $contributionPageId
  *
  * @return bool|array
  *   mixed true or array of errors
  */
 public static function formRule($params, $files, $contributionPageId = NULL)
 {
     $errors = array();
     if (!empty($params['member_price_set_id'])) {
         //check if this price set has membership type both auto-renew and non-auto-renew memberships.
         $bothTypes = CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew($params['member_price_set_id']);
         //check for supporting payment processors
         //if both auto-renew and non-auto-renew memberships
         if ($bothTypes) {
             $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'payment_processor');
             $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds);
             if (!empty($paymentProcessorId)) {
                 foreach ($paymentProcessorId as $pid) {
                     if ($pid) {
                         $processor = Civi\Payment\System::singleton()->getById($pid);
                         if (!$processor->supports('MultipleConcurrentPayments')) {
                             $errors['member_price_set_id'] = ts('The membership price set associated with this online contribution allows a user to select BOTH an auto-renew AND a non-auto-renew membership. This requires submitting multiple processor transactions, and is not supported for one or more of the payment processors enabled under the Amounts tab.');
                         }
                     }
                 }
             }
         }
     }
     if (!empty($params['member_is_active'])) {
         // don't allow price set w/ membership signup, CRM-5095
         if ($contributionPageId && ($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $contributionPageId, NULL, 1))) {
             $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends');
             if ($extends != CRM_Core_Component::getComponentID('CiviMember')) {
                 $errors['member_is_active'] = ts('You cannot enable both Membership Signup and a Contribution Price Set on the same online contribution page.');
                 return $errors;
             }
         }
         if (!empty($params['member_price_set_id'])) {
             return $errors;
         }
         if (!isset($params['membership_type']) || !is_array($params['membership_type'])) {
             $errors['membership_type'] = ts('Please select at least one Membership Type to include in the Membership section of this page.');
         } else {
             $membershipType = array_values($params['membership_type']);
             $isRecur = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'is_recur');
             if (array_sum($membershipType) == 0) {
                 $errors['membership_type'] = ts('Please select at least one Membership Type to include in the Membership section of this page.');
             } elseif (array_sum($membershipType) > CRM_Price_Form_Field::NUM_OPTION) {
                 // for CRM-13079
                 $errors['membership_type'] = ts('You cannot select more than %1 choices. For more complex functionality, please use a Price Set.', array(1 => CRM_Price_Form_Field::NUM_OPTION));
             } elseif ($isRecur) {
                 if (empty($params['is_separate_payment']) && array_sum($membershipType) != 0) {
                     $errors['is_separate_payment'] = ts('You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution');
                 } elseif (!empty($params['is_separate_payment'])) {
                     foreach ($params['membership_type'] as $mt => $dontCare) {
                         if (!empty($params["auto_renew_{$mt}"])) {
                             $errors["auto_renew_{$mt}"] = ts('You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page');
                             break;
                         }
                     }
                 }
             }
         }
         //for CRM-1302
         //if Membership status is not present, then display an error message
         $dao = new CRM_Member_BAO_MembershipStatus();
         if (!$dao->find()) {
             $errors['_qf_default'] = ts('Add status rules, before configuring membership');
         }
         //give error if default is selected for an unchecked membership type
         if (!empty($params['membership_type_default']) && !$params['membership_type'][$params['membership_type_default']]) {
             $errors['membership_type_default'] = ts('Can\'t set default option for an unchecked membership type.');
         }
         if ($contributionPageId) {
             $amountBlock = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'amount_block_is_active');
             if (!$amountBlock && !empty($params['is_separate_payment'])) {
                 $errors['is_separate_payment'] = ts('Please enable the contribution amount section to use this option.');
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:89,代码来源:MembershipBlock.php


注:本文中的CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。