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


PHP CRM_Price_BAO_PriceSet::checkMembershipPriceSet方法代码示例

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


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

示例1: formRule

 /**
  * Function for validation
  *
  * @param array $params (ref.) an assoc array of name/value pairs
  *
  * @return mixed true or array of errors
  * @access public
  * @static
  */
 static function formRule($params, $files, $contributionPageId = NULL)
 {
     $errors = array();
     if (CRM_Utils_Array::value('member_price_set_id', $params)) {
         //check if this price set has membership type both auto-renew and non-auto-renew memberships.
         $bothTypes = CRM_Price_BAO_PriceSet::checkMembershipPriceSet($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)) {
                 $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(false, null, 'name');
                 foreach ($paymentProcessorId as $pid) {
                     if ($pid) {
                         $paymentProcessorTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $pid, 'payment_processor_type_id');
                     }
                     if (!($paymentProcessorTypeId == CRM_Utils_Array::key('PayPal', $paymentProcessorType) || $paymentProcessorTypeId == CRM_Utils_Array::key('AuthNet', $paymentProcessorType))) {
                         $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 Fees tab.');
                     }
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('member_is_active', $params)) {
         // 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 ($contributionPageId && CRM_Utils_Array::value('member_price_set_id', $params) && CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'amount_block_is_active')) {
             $errors['member_price_set_id'] = ts('You cannot use Membership Price Sets with the Contribution Amounts section. However, a membership price set may include additional fields for non-membership options that requires an additional fee (e.g. magazine subscription) or an additional voluntary contribution.');
         }
         if (CRM_Utils_Array::value('member_price_set_id', $params)) {
             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']);
             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));
             }
         }
         //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 && CRM_Utils_Array::value('is_separate_payment', $params)) {
                 $errors['is_separate_payment'] = ts('Please enable the contribution amount section to use this option.');
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:78,代码来源:MembershipBlock.php


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