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


PHP CRM_Member_BAO_Membership类代码示例

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


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

示例1: civicrm_membership_delete

/**
 * Deletes an existing contact membership
 * 
 * This API is used for deleting a contact membership
 * 
 * @param  Int  $membershipID   Id of the contact membership to be deleted
 * 
 * @return null if successfull, object of CRM_Core_Error otherwise
 * @access public
 */
function civicrm_membership_delete(&$membershipID)
{
    _civicrm_initialize();
    if (empty($membershipID)) {
        return civicrm_create_error('Membership ID cannot be empty.');
    }
    require_once 'CRM/Member/BAO/Membership.php';
    CRM_Member_BAO_Membership::deleteRelatedMemberships($membershipID);
    $membership = new CRM_Member_BAO_Membership();
    $result = $membership->deleteMembership($membershipID);
    return $result ? civicrm_create_success() : civicrm_create_error('Error while deleting Membership');
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:22,代码来源:Membership.php

示例2: listMemberships

 /**
  * Function to list memberships for the UF user
  *
  * return null
  * @access public
  */
 function listMemberships()
 {
     $membership = array();
     $dao = new CRM_Member_DAO_Membership();
     $dao->contact_id = $this->_contactId;
     $dao->is_test = 0;
     $dao->find();
     while ($dao->fetch()) {
         $membership[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
         //get the membership status and type values.
         $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
         foreach (array('status', 'membership_type') as $fld) {
             $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
         }
         if (!empty($statusANDType[$dao->id]['is_current_member'])) {
             $membership[$dao->id]['active'] = TRUE;
         }
         $membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
         if (!$membership[$dao->id]['renewPageId']) {
             // Membership payment was not done via online contribution page or free membership. Check for default membership renewal page from CiviMember Settings
             $defaultRenewPageId = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME, 'default_renewal_contribution_page');
             if ($defaultRenewPageId) {
                 $membership[$dao->id]['renewPageId'] = $defaultRenewPageId;
             }
         }
     }
     $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
     $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
     $this->assign('activeMembers', $activeMembers);
     $this->assign('inActiveMembers', $inActiveMembers);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:38,代码来源:UserDashboard.php

示例3: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // Register 'contact_1' model
     $entities = array();
     $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
     $allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
     $allowSubTypes = array();
     // Register 'contribution_1'
     $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'financial_type_id');
     $allowCoreTypes[] = 'Contribution';
     //CRM-15427
     $allowSubTypes['ContributionType'] = array($financialTypeId);
     $entities[] = array('entity_name' => 'contribution_1', 'entity_type' => 'ContributionModel', 'entity_sub_type' => '*');
     // If applicable, register 'membership_1'
     $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     if ($member && $member['is_active']) {
         //CRM-15427
         $entities[] = array('entity_name' => 'membership_1', 'entity_type' => 'MembershipModel', 'entity_sub_type' => '*');
         $allowCoreTypes[] = 'Membership';
         $allowSubTypes['MembershipType'] = explode(',', $member['membership_types']);
     }
     //CRM-15427
     $this->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
     $this->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id);
     parent::buildQuickForm();
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:32,代码来源:Custom.php

示例4: setDefaultValues

 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  * @return void
  */
 function setDefaultValues()
 {
     //parent::setDefaultValues();
     $defaults = array();
     if (isset($this->_id)) {
         $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     }
     // for membership_types
     if (isset($defaults['membership_types'])) {
         $membershipType = explode(',', $defaults['membership_types']);
         $newMembershipType = array();
         foreach ($membershipType as $k => $v) {
             $newMembershipType[$v] = 1;
             $defaults["auto_renew_{$v}"] = $defaults['auto_renew'][$v];
         }
         $defaults['membership_type'] = $newMembershipType;
     }
     // Set Display Minimum Fee default to true if we are adding a new membership block
     if (!isset($defaults['id'])) {
         $defaults['display_min_fee'] = 1;
     } else {
         $this->assign('membershipBlockId', $defaults['id']);
     }
     return $defaults;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:MembershipBlock.php

示例5: listMemberships

 /**
  * Function to list memberships for the UF user
  * 
  * return null
  * @access public
  */
 function listMemberships()
 {
     $idList = array('membership_type' => 'MembershipType', 'status' => 'MembershipStatus');
     $membership = array();
     require_once "CRM/Member/BAO/Membership.php";
     $dao =& new CRM_Member_DAO_Membership();
     $dao->contact_id = $this->_contactId;
     $dao->is_test = 0;
     $dao->find();
     while ($dao->fetch()) {
         $membership[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
         foreach ($idList as $name => $file) {
             if ($membership[$dao->id][$name . '_id']) {
                 $membership[$dao->id][$name] = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_{$file}", $membership[$dao->id][$name . '_id']);
             }
         }
         if ($dao->status_id) {
             $active = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $dao->status_id, 'is_current_member');
             if ($active) {
                 $membership[$dao->id]['active'] = $active;
             }
         }
         $membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
     }
     $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
     $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
     $this->assign('activeMembers', $activeMembers);
     $this->assign('inActiveMembers', $inActiveMembers);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:36,代码来源:UserDashboard.php

示例6: listMemberships

 /**
  * Function to list memberships for the UF user
  * 
  * return null
  * @access public
  */
 function listMemberships()
 {
     $membership = array();
     require_once "CRM/Member/BAO/Membership.php";
     $dao = new CRM_Member_DAO_Membership();
     $dao->contact_id = $this->_contactId;
     $dao->is_test = 0;
     $dao->find();
     while ($dao->fetch()) {
         $membership[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
         //get the membership status and type values.
         $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeVaues($dao->id);
         foreach (array('status', 'membership_type') as $fld) {
             $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
         }
         if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id])) {
             $membership[$dao->id]['active'] = true;
         }
         $membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
     }
     $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
     $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
     $this->assign('activeMembers', $activeMembers);
     $this->assign('inActiveMembers', $inActiveMembers);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:UserDashboard.php

示例7: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $deletedMembers = 0;
     foreach ($this->_memberIds as $memberId) {
         if (CRM_Member_BAO_Membership::del($memberId)) {
             $deletedMembers++;
         }
     }
     CRM_Core_Session::setStatus($deletedMembers, ts('Deleted Member(s)'), 'success');
     CRM_Core_Session::setStatus(ts('Total Selected Membership(s): %1', array(1 => count($this->_memberIds))), '', 'info');
 }
开发者ID:hguru,项目名称:224Civi,代码行数:18,代码来源:Delete.php

示例8: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $deletedMemberss = 0;
     foreach ($this->_memberIds as $memberId) {
         if (CRM_Member_BAO_Membership::deleteMembership($memberId)) {
             $deletedMemberss++;
         }
     }
     $status = array(ts('Deleted Member(s): %1', array(1 => $deletedMembers)), ts('Total Selected Membership(s): %1', array(1 => count($this->_memberIds))));
     CRM_Core_Session::setStatus($status);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:17,代码来源:Delete.php

示例9: setDefaultValues

 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     //parent::setDefaultValues();
     $defaults = array();
     if (isset($this->_id)) {
         $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     }
     $defaults['member_is_active'] = $defaults['is_active'];
     // Set Display Minimum Fee default to true if we are adding a new membership block
     if (!isset($defaults['id'])) {
         $defaults['display_min_fee'] = 1;
     } else {
         $this->assign('membershipBlockId', $defaults['id']);
     }
     if ($this->_id && ($priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3, 1))) {
         $defaults['member_price_set_id'] = $priceSetId;
         $this->_memPriceSetId = $priceSetId;
     } else {
         // for membership_types
         // if ( isset( $defaults['membership_types'] ) ) {
         $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3);
         $this->assign('isQuick', 1);
         $this->_memPriceSetId = $priceSetId;
         $pFIDs = array();
         if ($priceSetId) {
             CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = array('html_type', 'name', 'label'));
             foreach ($pFIDs as $pid => $pValue) {
                 if ($pValue['html_type'] == 'Radio' && $pValue['name'] == 'membership_amount') {
                     $defaults['mem_price_field_id'] = $pValue['id'];
                     $defaults['membership_type_label'] = $pValue['label'];
                 }
             }
             if (!empty($defaults['mem_price_field_id'])) {
                 $options = array();
                 $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($defaults['mem_price_field_id'], $options, 'id', 1);
                 foreach ($options as $k => $v) {
                     $newMembershipType[$v['membership_type_id']] = 1;
                     if (!empty($defaults['auto_renew'])) {
                         $defaults["auto_renew_" . $v['membership_type_id']] = $defaults['auto_renew'][$v['membership_type_id']];
                     }
                 }
                 $defaults['membership_type'] = $newMembershipType;
             }
         }
     }
     return $defaults;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:54,代码来源:MembershipBlock.php

示例10: postProcess

 /**
  * Process the form after the input has been submitted and validated.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     $deleted = $failed = 0;
     foreach ($this->_memberIds as $memberId) {
         if (CRM_Member_BAO_Membership::del($memberId)) {
             $deleted++;
         } else {
             $failed++;
         }
     }
     if ($deleted) {
         $msg = ts('%count membership deleted.', array('plural' => '%count memberships deleted.', 'count' => $deleted));
         CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
     }
     if ($failed) {
         CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:24,代码来源:Delete.php

示例11: preProcess

 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     require_once 'CRM/Member/BAO/Membership.php';
     require_once 'CRM/Member/BAO/MembershipType.php';
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $values = array();
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     // Make sure context is assigned to template for condition where we come here view civicrm/membership/view
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $context);
     if ($id) {
         $params = array('id' => $id);
         CRM_Member_BAO_Membership::retrieve($params, $values);
         // build associated contributions
         require_once 'CRM/Member/Page/Tab.php';
         CRM_Member_Page_Tab::associatedContribution($values['contact_id'], $id);
         //Provide information about membership source when it is the result of a relationship (CRM-1901)
         $values['owner_membership_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $id, 'owner_membership_id');
         if (isset($values['owner_membership_id'])) {
             $values['owner_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $values['owner_membership_id'], 'contact_id', 'id');
             $values['owner_display_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['owner_contact_id'], 'display_name', 'id');
             $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
             $direction = strrev($membershipType['relationship_direction']);
             $values['relationship'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $membershipType['relationship_type_id'], "name_{$direction}", 'id');
         }
         $displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
         $this->assign('displayName', $displayName);
         // add viewed membership to recent items list
         require_once 'CRM/Utils/Recent.php';
         $url = CRM_Utils_System::url('civicrm/contact/view/membership', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}");
         $title = $displayName . ' - ' . ts('Membership Type:') . ' ' . $values['membership_type'];
         CRM_Utils_Recent::add($title, $url, $values['id'], 'Membership', $values['contact_id'], null);
         CRM_Member_Page_Tab::setContext($values['contact_id']);
         $memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $id, "membership_type_id");
         $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $id, 0, $memType);
         CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     }
     if ($values['is_test']) {
         $values['membership_type'] .= ' (test) ';
     }
     $this->assign($values);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:48,代码来源:MembershipView.php

示例12: setDefaultValues

 /**
  * Set default values for the form. MobileProvider that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return array
  *   defaults
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Member_BAO_Membership::retrieve($params, $defaults);
         if (isset($defaults['minimum_fee'])) {
             $defaults['minimum_fee'] = CRM_Utils_Money::format($defaults['minimum_fee'], NULL, '%a');
         }
         if (isset($defaults['status'])) {
             $this->assign('membershipStatus', $defaults['status']);
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $defaults['is_active'] = 1;
     }
     if (isset($defaults['member_of_contact_id']) && $defaults['member_of_contact_id']) {
         $defaults['member_org'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $defaults['member_of_contact_id'], 'display_name');
     }
     return $defaults;
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:29,代码来源:Form.php

示例13: listMemberships

 /**
  * List memberships for the UF user.
  *
  */
 public function listMemberships()
 {
     $membership = array();
     $dao = new CRM_Member_DAO_Membership();
     $dao->contact_id = $this->_contactId;
     $dao->is_test = 0;
     $dao->find();
     while ($dao->fetch()) {
         $membership[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
         //get the membership status and type values.
         $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
         foreach (array('status', 'membership_type') as $fld) {
             $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
         }
         if (!empty($statusANDType[$dao->id]['is_current_member'])) {
             $membership[$dao->id]['active'] = TRUE;
         }
         $membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id);
         if (!$membership[$dao->id]['renewPageId']) {
             // Membership payment was not done via online contribution page or free membership. Check for default membership renewal page from CiviMember Settings
             $defaultRenewPageId = Civi::settings()->get('default_renewal_contribution_page');
             if ($defaultRenewPageId) {
                 //CRM-14831 - check if membership type is present in contrib page
                 $memBlock = CRM_Member_BAO_Membership::getMembershipBlock($defaultRenewPageId);
                 if (!empty($memBlock['membership_types'])) {
                     $memTypes = explode(',', $memBlock['membership_types']);
                     if (in_array($dao->membership_type_id, $memTypes)) {
                         $membership[$dao->id]['renewPageId'] = $defaultRenewPageId;
                     }
                 }
             }
         }
     }
     $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
     $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
     $this->assign('activeMembers', $activeMembers);
     $this->assign('inActiveMembers', $inActiveMembers);
 }
开发者ID:sarehag,项目名称:civicrm-core,代码行数:43,代码来源:UserDashboard.php

示例14: postProcess

 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Member_BAO_Membership::del($this->_id);
         return;
     }
     $allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
     $allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
     $isTest = $this->_mode == 'test' ? 1 : 0;
     $lineItems = NULL;
     if (!empty($this->_lineItem)) {
         $lineItems = $this->_lineItem;
     }
     $config = CRM_Core_Config::singleton();
     // get the submitted form values.
     $this->_params = $formValues = $this->controller->exportValues($this->_name);
     $this->convertDateFieldsToMySQL($formValues);
     $params = $softParams = $ids = array();
     $membershipTypeValues = array();
     foreach ($this->_memTypeSelected as $memType) {
         $membershipTypeValues[$memType]['membership_type_id'] = $memType;
     }
     //take the required membership recur values.
     if ($this->_mode && !empty($this->_params['auto_renew'])) {
         $params['is_recur'] = $this->_params['is_recur'] = $formValues['is_recur'] = TRUE;
         $mapping = array('frequency_interval' => 'duration_interval', 'frequency_unit' => 'duration_unit');
         $count = 0;
         foreach ($this->_memTypeSelected as $memType) {
             $recurMembershipTypeValues = CRM_Utils_Array::value($memType, $this->_recurMembershipTypes, array());
             foreach ($mapping as $mapVal => $mapParam) {
                 $membershipTypeValues[$memType][$mapVal] = CRM_Utils_Array::value($mapParam, $recurMembershipTypeValues);
                 if (!$count) {
                     $this->_params[$mapVal] = $formValues[$mapVal] = CRM_Utils_Array::value($mapParam, $recurMembershipTypeValues);
                 }
             }
             $count++;
         }
     }
     // process price set and get total amount and line items.
     $lineItem = array();
     $priceSetId = NULL;
     if (!($priceSetId = CRM_Utils_Array::value('price_set_id', $formValues))) {
         CRM_Member_BAO_Membership::createLineItems($this, $formValues['membership_type_id'], $priceSetId);
     }
     $isQuickConfig = 0;
     if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
         $isQuickConfig = 1;
     }
     $termsByType = array();
     if ($priceSetId) {
         CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$priceSetId]);
         if (CRM_Utils_Array::value('tax_amount', $this->_params)) {
             $params['tax_amount'] = $this->_params['tax_amount'];
         }
         $params['total_amount'] = CRM_Utils_Array::value('amount', $this->_params);
         $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
         if (!empty($lineItem[$priceSetId])) {
             foreach ($lineItem[$priceSetId] as &$li) {
                 if (!empty($li['membership_type_id'])) {
                     if (!empty($li['membership_num_terms'])) {
                         $termsByType[$li['membership_type_id']] = $li['membership_num_terms'];
                     }
                 }
                 ///CRM-11529 for quick config backoffice transactions
                 //when financial_type_id is passed in form, update the
                 //lineitems with the financial type selected in form
                 if ($isQuickConfig && $submittedFinancialType) {
                     $li['financial_type_id'] = $submittedFinancialType;
                 }
             }
         }
     }
     $this->storeContactFields($formValues);
     $params['contact_id'] = $this->_contactID;
     $fields = array('status_id', 'source', 'is_override', 'campaign_id');
     foreach ($fields as $f) {
         $params[$f] = CRM_Utils_Array::value($f, $formValues);
     }
     // fix for CRM-3724
     // when is_override false ignore is_admin statuses during membership
     // status calculation. similarly we did fix for import in CRM-3570.
     if (empty($params['is_override'])) {
         $params['exclude_is_admin'] = TRUE;
     }
     // process date params to mysql date format.
     $dateTypes = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
     foreach ($dateTypes as $dateField => $dateVariable) {
         ${$dateVariable} = CRM_Utils_Date::processDate($formValues[$dateField]);
     }
     $memTypeNumTerms = empty($termsByType) ? CRM_Utils_Array::value('num_terms', $formValues) : NULL;
     $calcDates = array();
     foreach ($this->_memTypeSelected as $memType) {
         if (empty($memTypeNumTerms)) {
             $memTypeNumTerms = CRM_Utils_Array::value($memType, $termsByType, 1);
//.........这里部分代码省略.........
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:Membership.php

示例15: preProcess

 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     // current contribution page id
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!$this->_id) {
         // seems like the session is corrupted and/or we lost the id trail
         // lets just bump this to a regular session error and redirect user to main page
         $this->controller->invalidKeyRedirect();
     }
     // this was used prior to the cleverer this_>getContactID - unsure now
     $this->_userID = $session->get('userID');
     $this->_contactID = $this->_membershipContactID = $this->getContactID();
     $this->_mid = NULL;
     if ($this->_contactID) {
         $this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
         if ($this->_mid) {
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $this->_mid;
             if ($membership->find(TRUE)) {
                 $this->_defaultMemTypeId = $membership->membership_type_id;
                 if ($membership->contact_id != $this->_contactID) {
                     $validMembership = FALSE;
                     $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
                     if (!empty($employers) && array_key_exists($membership->contact_id, $employers)) {
                         $this->_membershipContactID = $membership->contact_id;
                         $this->assign('membershipContactID', $this->_membershipContactID);
                         $this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
                         $validMembership = TRUE;
                     } else {
                         $membershipType = new CRM_Member_BAO_MembershipType();
                         $membershipType->id = $membership->membership_type_id;
                         if ($membershipType->find(TRUE)) {
                             // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
                             // Convert to commma separated list.
                             $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
                             $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
                             if (array_key_exists($membership->contact_id, $permContacts)) {
                                 $this->_membershipContactID = $membership->contact_id;
                                 $validMembership = TRUE;
                             }
                         }
                     }
                     if (!$validMembership) {
                         CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
                     }
                 }
             } else {
                 CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
             }
             unset($membership);
         }
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', FALSE);
     // Contribution page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->assign('action', $this->_action);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     if (!$this->_values) {
         // get all the values from the dao object
         $this->_values = array();
         $this->_fields = array();
         CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
         // check if form is active
         if (!CRM_Utils_Array::value('is_active', $this->_values)) {
             // form is inactive, die a fatal death
             CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
         }
         // also check for billing informatin
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
         $isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
         //FIXME: to support multiple payment processors
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:ContributionBase.php


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