本文整理汇总了PHP中CRM_Member_BAO_Membership::postProcessMembership方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::postProcessMembership方法的具体用法?PHP CRM_Member_BAO_Membership::postProcessMembership怎么用?PHP CRM_Member_BAO_Membership::postProcessMembership使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_BAO_Membership::postProcessMembership方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
}
if (!array_key_exists('first_name', $fields)) {
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = true;
}
}
}
// billing email address
$fields["email-{$this->_bltID}"] = 1;
//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
if ($params['is_pay_later']) {
$billingFields = array("billing_first_name", "billing_middle_name", "billing_last_name", "billing_street_address-{$this->_bltID}", "billing_city-{$this->_bltID}", "billing_state_province-{$this->_bltID}", "billing_state_province_id-{$this->_bltID}", "billing_postal_code-{$this->_bltID}", "billing_country-{$this->_bltID}", "billing_country_id-{$this->_bltID}");
foreach ($billingFields as $value) {
unset($params[$value]);
unset($fields[$value]);
}
}
// if onbehalf-of-organization contribution, take out
// organization params in a separate variable, to make sure
// normal behavior is continued. And use that variable to
// process on-behalf-of functionality.
if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
$behalfOrganization = array();
foreach (array('organization_name', 'organization_id', 'org_option') as $fld) {
if (array_key_exists($fld, $params)) {
$behalfOrganization[$fld] = $params[$fld];
unset($params[$fld]);
}
}
if (array_key_exists('onbehalf_location', $params) && is_array($params['onbehalf_location'])) {
foreach ($params['onbehalf_location'] as $block => $vals) {
$behalfOrganization[$block] = $vals;
}
unset($params['onbehalf_location']);
}
}
if (!isset($contactID)) {
require_once 'CRM/Dedupe/Finder.php';
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
// if we find more than one contact, use the first one
$contact_id = CRM_Utils_Array::value(0, $ids);
$contactID =& CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contact_id, $addToGroups);
$this->set('contactID', $contactID);
} else {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type');
$contactID =& CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contactID, $addToGroups, null, $ctype);
}
// If onbehalf-of-organization contribution / signup, add organization
// and it's location.
if (isset($params['is_for_organization']) && isset($behalfOrganization['organization_name'])) {
self::processOnBehalfOrganization($behalfOrganization, $contactID, $this->_values, $this->_params);
}
// lets store the contactID in the session
// for things like tell a friend
$session =& CRM_Core_Session::singleton();
if (!$session->get('userID')) {
$session->set('transaction.userID', $contactID);
} else {
$session->set('transaction.userID', null);
}
// store the fact that this is a membership and membership type is selected
$processMembership = false;
if (CRM_Utils_Array::value('selectMembership', $membershipParams) && $membershipParams['selectMembership'] != 'no_thanks') {
$processMembership = true;
$this->assign('membership_assign', true);
$this->set('membershipTypeID', $this->_params['selectMembership']);
if ($this->_action & CRM_Core_Action::PREVIEW) {
$membershipParams['is_test'] = 1;
}
if ($this->_params['is_pay_later']) {
$membershipParams['is_pay_later'] = 1;
}
}
if ($processMembership) {
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, true);
// added new parameter for cms user contact id, needed to distinguish behaviour for on behalf of sign-ups
if (isset($this->_params['related_contact'])) {
$membershipParams['cms_contactID'] = $this->_params['related_contact'];
} else {
$membershipParams['cms_contactID'] = $contactID;
}
require_once 'CRM/Member/BAO/Membership.php';
CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, $this, $premiumParams);
} else {
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$contributionTypeId = $this->_values['contribution_type_id'];
require_once "CRM/Contribute/BAO/Contribution/Utils.php";
CRM_Contribute_BAO_Contribution_Utils::processConfirm($this, $paymentParams, $premiumParams, $contactID, $contributionTypeId, 'contribution');
}
}
示例2: postProcess
//.........这里部分代码省略.........
$session = CRM_Core_Session::singleton();
if (!$session->get('userID')) {
$session->set('transaction.userID', $contactID);
} else {
$session->set('transaction.userID', NULL);
}
$this->_useForMember = $this->get('useForMember');
// store the fact that this is a membership and membership type is selected
$processMembership = FALSE;
if (!empty($membershipParams['selectMembership']) && $membershipParams['selectMembership'] != 'no_thanks' || $this->_useForMember) {
$processMembership = TRUE;
if (!$this->_useForMember) {
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $this->_params['selectMembership']);
}
if ($this->_action & CRM_Core_Action::PREVIEW) {
$membershipParams['is_test'] = 1;
}
if ($this->_params['is_pay_later']) {
$membershipParams['is_pay_later'] = 1;
}
}
if ($processMembership) {
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE);
// added new parameter for cms user contact id, needed to distinguish behaviour for on behalf of sign-ups
if (isset($this->_params['related_contact'])) {
$membershipParams['cms_contactID'] = $this->_params['related_contact'];
} else {
$membershipParams['cms_contactID'] = $contactID;
}
//inherit campaign from contirb page.
if (!array_key_exists('campaign_id', $membershipParams)) {
$membershipParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
}
if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
$this->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
$customFieldsFormatted = $fieldTypes = array();
if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf'])) {
foreach ($membershipParams['onbehalf'] as $key => $value) {
if (strstr($key, 'custom_')) {
$customFieldId = explode('_', $key);
CRM_Core_BAO_CustomField::formatCustomField($customFieldId[1], $customFieldsFormatted, $value, 'Membership', NULL, $contactID);
}
}
$fieldTypes = array('Contact', 'Organization', 'Membership');
}
$priceFieldIds = $this->get('memberPriceFieldIDS');
if (!empty($priceFieldIds)) {
$contributionTypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id');
unset($priceFieldIds['id']);
$membershipTypeIds = array();
$membershipTypeTerms = array();
foreach ($priceFieldIds as $priceFieldId) {
if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
$membershipTypeIds[] = $id;
$term = 1;
if ($term = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_num_terms')) {
$membershipTypeTerms[$id] = $term > 1 ? $term : 1;
} else {
$membershipTypeTerms[$id] = 1;
}
}
}
$membershipParams['selectMembership'] = $membershipTypeIds;
$membershipParams['financial_type_id'] = $contributionTypeID;
$membershipParams['types_terms'] = $membershipTypeTerms;
}
if (!empty($membershipParams['selectMembership'])) {
// CRM-12233
if ($this->_separateMembershipPayment && $this->_values['amount_block_is_active']) {
foreach ($this->_values['fee'] as $key => $feeValues) {
if ($feeValues['name'] == 'membership_amount') {
$fieldId = $this->_params['price_' . $key];
$this->_memLineItem[$this->_priceSetId][$fieldId] = $this->_lineItem[$this->_priceSetId][$fieldId];
unset($this->_lineItem[$this->_priceSetId][$fieldId]);
break;
}
}
}
CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, $this, $premiumParams, $customFieldsFormatted, $fieldTypes);
}
} else {
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$contributionTypeId = $this->_values['financial_type_id'];
$fieldTypes = array();
if (!empty($paymentParams['onbehalf']) && is_array($paymentParams['onbehalf'])) {
foreach ($paymentParams['onbehalf'] as $key => $value) {
if (strstr($key, 'custom_')) {
$this->_params[$key] = $value;
}
}
$fieldTypes = array('Contact', 'Organization', 'Contribution');
}
CRM_Contribute_BAO_Contribution_Utils::processConfirm($this, $paymentParams, $premiumParams, $contactID, $contributionTypeId, 'contribution', $fieldTypes);
}
}
示例3: processMembership
/**
* @param array $membershipParams
* @param integer $contactID
* @param array $customFieldsFormatted
* @param array $fieldTypes
* @param array $premiumParams
* @param array $membershipLineItems line items specifically relating to memberships
*/
public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems)
{
try {
$membershipTypeIDs = (array) $membershipParams['selectMembership'];
$membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
$membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
$this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
$isPaidMembership = FALSE;
if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
//amount must be greater than zero for
//adding contribution record to contribution table.
//this condition arises when separate membership payment is
//enabled and contribution amount is not selected. fix for CRM-3010
$isPaidMembership = TRUE;
}
$isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']);
if ($this->_values['amount_block_is_active']) {
$contributionTypeId = $this->_values['financial_type_id'];
} else {
$contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
}
CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId, $membershipLineItems);
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $membershipParams['selectMembership']);
} catch (CRM_Core_Exception $e) {
CRM_Core_Session::singleton()->setStatus($e->getMessage());
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}"));
}
}