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


PHP CRM_Member_BAO_MembershipStatus::find方法代码示例

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


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

示例2: array

/**
 * Update an existing membership status
 *
 * This api is used for updating an existing membership status.
 * Required parrmeters : id of a membership status
 *
 * @param  Array   $params  an associative array of name/value property values of civicrm_membership_status
 * @deprecated - should just use create
 *
 * @return array of updated membership status property values
 * @access public
 */
function &civicrm_api3_membership_status_update($params)
{
    civicrm_api3_verify_mandatory($params, NULL, array('id'));
    //don't allow duplicate names.
    $name = CRM_Utils_Array::value('name', $params);
    if ($name) {
        require_once 'CRM/Member/DAO/MembershipStatus.php';
        $status = new CRM_Member_DAO_MembershipStatus();
        $status->name = $params['name'];
        if ($status->find(TRUE) && $status->id != $params['id']) {
            return civicrm_api3_create_error(ts('A membership status with this name already exists.'));
        }
    }
    require_once 'CRM/Member/BAO/MembershipStatus.php';
    $membershipStatusBAO = new CRM_Member_BAO_MembershipStatus();
    $membershipStatusBAO->id = $params['id'];
    if ($membershipStatusBAO->find(TRUE)) {
        $fields = $membershipStatusBAO->fields();
        foreach ($fields as $name => $field) {
            if (array_key_exists($name, $params)) {
                $membershipStatusBAO->{$name} = $params[$name];
            }
        }
        $membershipStatusBAO->save();
    }
    $membershipStatus = array();
    _civicrm_api3_object_to_array(clone $membershipStatusBAO, $membershipStatus);
    $membershipStatus['is_error'] = 0;
    return $membershipStatus;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:42,代码来源:MembershipStatus.php

示例3: civicrm_membership_status_get

/**
 * Get a membership status.
 * 
 * This api is used for finding an existing membership status.
 * 
 * @param  array $params  an associative array of name/value property values of civicrm_membership_status
 *
 * @return  Array of all found membership status property values.
 * @access public
 */
function civicrm_membership_status_get(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Params is not an array.');
    }
    require_once 'CRM/Member/BAO/MembershipStatus.php';
    $membershipStatusBAO = new CRM_Member_BAO_MembershipStatus();
    $properties = array_keys($membershipStatusBAO->fields());
    foreach ($properties as $name) {
        if (array_key_exists($name, $params)) {
            $membershipStatusBAO->{$name} = $params[$name];
        }
    }
    if ($membershipStatusBAO->find()) {
        $membershipStatus = array();
        while ($membershipStatusBAO->fetch()) {
            _civicrm_object_to_array(clone $membershipStatusBAO, $membershipStatus);
            $membershipStatuses[$membershipStatusBAO->id] = $membershipStatus;
        }
    } else {
        return civicrm_create_error('Exact match not found');
    }
    return $membershipStatuses;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:35,代码来源:MembershipStatus.php

示例4: 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('is_active', $params)) {
         // don't allow price set w/ membership signup, CRM-5095
         require_once 'CRM/Price/BAO/Set.php';
         if ($contributionPageId && CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $contributionPageId)) {
             $errors['is_active'] = ts('You cannot enable both Membership Signup and Price Set on the same online contribution page.');
             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.');
             }
         }
         //for CRM-1302
         //if Membership status is not present, then display an error message
         require_once 'CRM/Member/BAO/MembershipStatus.php';
         $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 (isset($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) {
             require_once "CRM/Contribute/DAO/ContributionPage.php";
             $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:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:48,代码来源:MembershipBlock.php

示例5: 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

示例6: foreach

/**
 * Update an existing membership status
 *
 * This api is used for updating an existing membership status.
 * Required parrmeters : id of a membership status
 *
 * @param  Array   $params  an associative array of name/value property values of civicrm_membership_status
 *
 * @return array of updated membership status property values
 * @access public
 */
function &civicrm_membership_status_update(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Params is not an array');
    }
    if (!isset($params['id'])) {
        return civicrm_create_error('Required parameter missing');
    }
    //don't allow duplicate names.
    $name = CRM_Utils_Array::value('name', $params);
    if ($name) {
        require_once 'CRM/Member/DAO/MembershipStatus.php';
        $status = new CRM_Member_DAO_MembershipStatus();
        $status->name = $params['name'];
        if ($status->find(TRUE) && $status->id != $params['id']) {
            return civicrm_create_error(ts('A membership status with this name already exists.'));
        }
    }
    require_once 'CRM/Member/BAO/MembershipStatus.php';
    $membershipStatusBAO = new CRM_Member_BAO_MembershipStatus();
    $membershipStatusBAO->id = $params['id'];
    if ($membershipStatusBAO->find(TRUE)) {
        $fields = $membershipStatusBAO->fields();
        foreach ($fields as $name => $field) {
            if (array_key_exists($name, $params)) {
                $membershipStatusBAO->{$name} = $params[$name];
            }
        }
        $membershipStatusBAO->save();
    }
    $membershipStatus = array();
    _civicrm_object_to_array(clone $membershipStatusBAO, $membershipStatus);
    $membershipStatus['is_error'] = 0;
    return $membershipStatus;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:47,代码来源:MembershipStatus.php

示例7: 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_is_active', $params)) {
         // don't allow price set w/ membership signup, CRM-5095
         if ($contributionPageId && ($setID = CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $contributionPageId, NULL, 1))) {
             $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $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.');
             }
         }
         //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 (isset($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:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:54,代码来源:MembershipBlock.php


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