本文整理汇总了PHP中CRM_Contribute_BAO_ContributionPage::setValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionPage::setValues方法的具体用法?PHP CRM_Contribute_BAO_ContributionPage::setValues怎么用?PHP CRM_Contribute_BAO_ContributionPage::setValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionPage
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionPage::setValues方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetValues
/**
* Test setValues() method
*/
public function testSetValues()
{
$params = array('title' => 'Test Contribution Page', 'financial_type_id' => $this->_financialTypeID, 'is_active' => 1);
$contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
$id = $contributionpage->id;
$values = array();
$setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, $values);
$this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
$this->assertEquals($this->_financialTypeID, $values['financial_type_id'], 'Verify financial types id.');
$this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
ContributionPage::delete($contributionpage->id);
}
示例2: testsetValues
/**
* test setValues() method
*/
function testsetValues()
{
$params = array('title' => 'Test Cotribution Page', 'contribution_type_id' => $this->_contributionTypeID, 'is_active' => 1);
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$contributionpage = CRM_Contribute_BAO_ContributionPage::create($params, $ids);
$id = $contributionpage->id;
$values = array();
$setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, &$values);
//CRM_Core_Error::debug( '$setValues',$values );
$this->assertEquals($Values->title, 'Test Cotribution Page', 'Verify contribution title.');
$this->assertEquals($Values->contribution_type_id, $this->_contributionTypeID, 'Verify contribution types id.');
$this->assertEquals($Values->is_active, 0, 'Verify contribution is_active value.');
}
示例3: completeTransaction
function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE)
{
$contribution =& $objects['contribution'];
$primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
$memberships =& $objects['membership'];
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
}
$participant =& $objects['participant'];
$event =& $objects['event'];
$changeToday = CRM_Utils_Array::value('trxn_date', $input, self::$_now);
$recurContrib =& $objects['contributionRecur'];
$values = array();
if (isset($input['is_email_receipt'])) {
$values['is_email_receipt'] = $input['is_email_receipt'];
}
$source = NULL;
if ($input['component'] == 'contribute') {
if ($contribution->contribution_page_id) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
$source = ts('Online Contribution') . ': ' . $values['title'];
} elseif ($recurContrib && $recurContrib->id) {
$contribution->contribution_page_id = NULL;
$values['amount'] = $recurContrib->amount;
$values['financial_type_id'] = $objects['contributionType']->id;
$values['title'] = $source = ts('Offline Recurring Contribution');
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$values['receipt_from_name'] = $domainValues[0];
$values['receipt_from_email'] = $domainValues[1];
}
if ($recurContrib && $recurContrib->id && !isset($input['is_email_receipt'])) {
//CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
// but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
$contribution->source = $source;
if (CRM_Utils_Array::value('is_email_receipt', $values)) {
$contribution->receipt_date = self::$_now;
}
if (!empty($memberships)) {
$membershipsUpdate = array();
foreach ($memberships as $membershipTypeIdKey => $membership) {
if ($membership) {
$format = '%Y%m%d';
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
// CRM-8141 update the membership type with the value recorded in log when membership created/renewed
// this picks up membership type changes during renewals
$sql = "\nSELECT membership_type_id\nFROM civicrm_membership_log\nWHERE membership_id={$membership->id}\nORDER BY id DESC\nLIMIT 1;";
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
$membership->membership_type_id = $dao->membership_type_id;
$membership->save();
}
// else fall back to using current membership type
}
// else fall back to using current membership type
$dao->free();
$num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id, $primaryContributionID);
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
* In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
* when Contribution mode is notify and membership is for renewal )
*/
CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
// @todo - we should pass membership_type_id instead of null here but not
// adding as not sure of testing
$dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday, NULL, $num_terms);
$dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
} else {
$dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $num_terms);
}
//get the status for membership.
$calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membership->membership_type_id, (array) $membership);
$formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format));
//we might be renewing membership,
//so make status override false.
$formatedParams['is_override'] = FALSE;
$membership->copyValues($formatedParams);
$membership->save();
//updating the membership log
$membershipLog = array();
$membershipLog = $formatedParams;
$logStartDate = $formatedParams['start_date'];
if (CRM_Utils_Array::value('log_start_date', $dates)) {
$logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
$logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
}
$membershipLog['start_date'] = $logStartDate;
$membershipLog['membership_id'] = $membership->id;
$membershipLog['modified_id'] = $membership->contact_id;
$membershipLog['modified_date'] = date('Ymd');
$membershipLog['membership_type_id'] = $membership->membership_type_id;
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
//update related Memberships.
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
//update the membership type key of membership relatedObjects array
//if it has changed after membership update
//.........这里部分代码省略.........
示例4: 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
//.........这里部分代码省略.........
示例5: completeTransaction
function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE)
{
$contribution =& $objects['contribution'];
$memberships =& $objects['membership'];
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
}
$participant =& $objects['participant'];
$event =& $objects['event'];
$changeToday = CRM_Utils_Array::value('trxn_date', $input, self::$_now);
$recurContrib =& $objects['contributionRecur'];
$values = array();
if ($input['component'] == 'contribute') {
if ($contribution->contribution_page_id) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
$source = ts('Online Contribution') . ': ' . $values['title'];
} elseif ($recurContrib->id) {
$contribution->contribution_page_id = NULL;
$values['amount'] = $recurContrib->amount;
$values['contribution_type_id'] = $objects['contributionType']->id;
$values['title'] = $source = ts('Offline Recurring Contribution');
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$values['receipt_from_name'] = $domainValues[0];
$values['receipt_from_email'] = $domainValues[1];
}
$contribution->source = $source;
if (CRM_Utils_Array::value('is_email_receipt', $values)) {
$contribution->receipt_date = self::$_now;
}
if (!empty($memberships)) {
foreach ($memberships as $membershipTypeIdKey => $membership) {
if ($membership) {
$format = '%Y%m%d';
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
// CRM-8141 update the membership type with the value recorded in log when membership created/renewed
// this picks up membership type changes during renewals
$sql = "\nSELECT membership_type_id\nFROM civicrm_membership_log\nWHERE membership_id={$membership->id}\nORDER BY id DESC\nLIMIT 1;";
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
$membership->membership_type_id = $dao->membership_type_id;
$membership->save();
}
// else fall back to using current membership type
}
// else fall back to using current membership type
$dao->free();
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
* In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
* when Contribution mode is notify and membership is for renewal )
*/
CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
$dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday);
$dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
} else {
$dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id);
}
//get the status for membership.
$calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE);
$formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format), 'reminder_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('reminder_date', $dates), $format));
//we might be renewing membership,
//so make status override false.
$formatedParams['is_override'] = FALSE;
$membership->copyValues($formatedParams);
$membership->save();
//updating the membership log
$membershipLog = array();
$membershipLog = $formatedParams;
$logStartDate = $formatedParams['start_date'];
if (CRM_Utils_Array::value('log_start_date', $dates)) {
$logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
$logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
}
$membershipLog['start_date'] = $logStartDate;
$membershipLog['membership_id'] = $membership->id;
$membershipLog['modified_id'] = $membership->contact_id;
$membershipLog['modified_date'] = date('Ymd');
$membershipLog['membership_type_id'] = $membership->membership_type_id;
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
//update related Memberships.
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
//update the membership type key of membership relatedObjects array
//if it has changed after membership update
if ($membershipTypeIdKey != $membership->membership_type_id) {
$memberships[$membership->membership_type_id] = $membership;
$contribution->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
unset($contribution->_relatedObjects['membership'][$membershipTypeIdKey]);
unset($memberships[$membershipTypeIdKey]);
}
}
}
}
} else {
// event
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
//.........这里部分代码省略.........
示例6: completeOrder
/**
* Complete an order.
*
* Do not call this directly - use the contribution.completetransaction api as this function is being refactored.
*
* Currently overloaded to complete a transaction & repeat a transaction - fix!
*
* Moving it out of the BaseIPN class is just the first step.
*
* @param array $input
* @param array $ids
* @param array $objects
* @param CRM_Core_Transaction $transaction
* @param int $recur
* @param CRM_Contribute_BAO_Contribution $contribution
* @param bool $isRecurring
* Duplication of param needs review. Only used by AuthorizeNetIPN
* @param int $isFirstOrLastRecurringPayment
* Deprecated param only used by AuthorizeNetIPN.
*/
public static function completeOrder(&$input, &$ids, $objects, $transaction, $recur, $contribution, $isRecurring, $isFirstOrLastRecurringPayment)
{
$primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
// The previous details are used when calculating line items so keep it before any code that 'does something'
if (!empty($contribution->id)) {
$input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contribution->id), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
}
$inputContributionWhiteList = array('fee_amount', 'net_amount', 'trxn_id', 'check_number', 'payment_instrument_id', 'is_test', 'campaign_id', 'receive_date');
$contributionParams = array_merge(array('contribution_status_id' => 'Completed'), array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)));
$participant = CRM_Utils_Array::value('participant', $objects);
$memberships = CRM_Utils_Array::value('membership', $objects);
$recurContrib = CRM_Utils_Array::value('contributionRecur', $objects);
if (!empty($recurContrib->id)) {
$contributionParams['contribution_recur_id'] = $recurContrib->id;
}
self::repeatTransaction($contribution, $input, $contributionParams);
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
}
$changeDate = CRM_Utils_Array::value('trxn_date', $input, date('YmdHis'));
$values = array();
if (isset($input['is_email_receipt'])) {
$values['is_email_receipt'] = $input['is_email_receipt'];
}
if ($input['component'] == 'contribute') {
if ($contribution->contribution_page_id) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
$contributionParams['source'] = ts('Online Contribution') . ': ' . $values['title'];
} elseif ($recurContrib && $recurContrib->id) {
$contributionParams['contribution_page_id'] = NULL;
$values['amount'] = $recurContrib->amount;
$values['financial_type_id'] = $objects['contributionType']->id;
$values['title'] = $source = ts('Offline Recurring Contribution');
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$values['receipt_from_name'] = $domainValues[0];
$values['receipt_from_email'] = $domainValues[1];
}
if ($recurContrib && $recurContrib->id && !isset($input['is_email_receipt'])) {
//CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
// but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
if (!empty($values['is_email_receipt'])) {
$contributionParams['receipt_date'] = $changeDate;
}
if (!empty($memberships)) {
foreach ($memberships as $membershipTypeIdKey => $membership) {
if ($membership) {
$membershipParams = array('id' => $membership->id, 'contact_id' => $membership->contact_id, 'is_test' => $membership->is_test, 'membership_type_id' => $membership->membership_type_id);
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'], $membershipParams['membership_type_id'], $membershipParams['is_test'], $membershipParams['id']);
// CRM-8141 update the membership type with the value recorded in log when membership created/renewed
// this picks up membership type changes during renewals
$sql = "\nSELECT membership_type_id\nFROM civicrm_membership_log\nWHERE membership_id={$membershipParams['id']}\nORDER BY id DESC\nLIMIT 1;";
$dao = CRM_Core_DAO::executeQuery($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
$membershipParams['membership_type_id'] = $dao->membership_type_id;
}
}
$dao->free();
$membershipParams['num_terms'] = $contribution->getNumTermsByContributionAndMembershipType($membershipParams['membership_type_id'], $primaryContributionID);
$dates = array_fill_keys(array('join_date', 'start_date', 'end_date'), NULL);
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
* In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
* when Contribution mode is notify and membership is for renewal )
*/
CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeDate);
// @todo - we should pass membership_type_id instead of null here but not
// adding as not sure of testing
$dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membershipParams['id'], $changeDate, NULL, $membershipParams['num_terms']);
$dates['join_date'] = $currentMembership['join_date'];
}
//get the status for membership.
$calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membershipParams['membership_type_id'], $membershipParams);
$membershipParams['status_id'] = CRM_Utils_Array::value('id', $calcStatus, 'New');
//we might be renewing membership,
//so make status override false.
$membershipParams['is_override'] = FALSE;
//.........这里部分代码省略.........
示例7: submit
/**
* Submit function.
*
* @param array $params
*
* @throws CiviCRM_API3_Exception
*/
public static function submit($params)
{
$form = new CRM_Contribute_Form_Contribution_Confirm();
$form->_id = $params['id'];
CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values);
$form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id);
//this way the mocked up controller ignores the session stuff
$_SERVER['REQUEST_METHOD'] = 'GET';
$form->controller = new CRM_Contribute_Controller_Contribution();
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
$form->_amount = $params['amount'];
// hack these in for test support.
$form->_fields['billing_first_name'] = 1;
$form->_fields['billing_last_name'] = 1;
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
$priceSetFields = reset($priceFields);
$form->_values['fee'] = $priceSetFields['fields'];
$form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
if (!empty($params['payment_processor_id'])) {
$form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor_id']));
// The concept of contributeMode is deprecated as is the billing_mode concept.
if ($form->_paymentProcessor['billing_mode'] == 1) {
$form->_contributeMode = 'direct';
} else {
$form->_contributeMode = 'notify';
}
} else {
$form->_params['payment_processor_id'] = 0;
}
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');
$form->_lineItem = array($priceSetID => $lineItems);
$form->processFormSubmission(CRM_Utils_Array::value('contact_id', $params));
}
示例8: _gatherMessageValues
/**
* Gather values for contribution mail - this function has been created
* as part of CRM-9996 refactoring as a step towards simplifying the composeMessage function
* Values related to the contribution in question are gathered
*
* @param array $input
* Input into function (probably from payment processor).
* @param array $values
* @param array $ids
* The set of ids related to the input.
*
* @return array
*/
public function _gatherMessageValues($input, &$values, $ids = array())
{
// set display address of contributor
if ($this->address_id) {
$addressParams = array('id' => $this->address_id);
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['address'] = $addressDetails[0]['display'];
}
if ($this->_component == 'contribute') {
if (isset($this->contribution_page_id)) {
CRM_Contribute_BAO_ContributionPage::setValues($this->contribution_page_id, $values);
if ($this->contribution_page_id) {
// CRM-8254 - override default currency if applicable
$config = CRM_Core_Config::singleton();
$config->defaultCurrency = CRM_Utils_Array::value('currency', $values, $config->defaultCurrency);
}
} else {
// Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
$values['is_email_receipt'] = 1;
$values['title'] = 'Contribution';
}
// set lineItem for contribution
if ($this->id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->id, 'contribution', 1);
if (!empty($lineItem)) {
$itemId = key($lineItem);
foreach ($lineItem as &$eachItem) {
if (array_key_exists($eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
$eachItem['join_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->join_date);
$eachItem['start_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->start_date);
$eachItem['end_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->end_date);
}
}
$values['lineItem'][0] = $lineItem;
$values['priceSetID'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItem[$itemId]['price_field_id'], 'price_set_id');
}
}
$relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($this->id, $this->contact_id);
// if this is onbehalf of contribution then set related contact
if (!empty($relatedContact['individual_id'])) {
$values['related_contact'] = $ids['related_contact'] = $relatedContact['individual_id'];
}
} else {
// event
$eventParams = array('id' => $this->_relatedObjects['event']->id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $this->_relatedObjects['event']->id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$values['custom_pre_id'] = $custom_pre_id;
$values['custom_post_id'] = $custom_post_ids;
// set lineItem for event contribution
if ($this->id) {
$participantIds = CRM_Event_BAO_Participant::getParticipantIds($this->id);
if (!empty($participantIds)) {
foreach ($participantIds as $pIDs) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($pIDs);
if (!CRM_Utils_System::isNull($lineItem)) {
$values['lineItem'][] = $lineItem;
}
}
}
}
}
return $values;
}
示例9: sendMail
function sendMail(&$input, &$ids, &$objects, &$values, $recur = false, $returnMessageText = false)
{
$contribution =& $objects['contribution'];
$membership =& $objects['membership'];
$participant =& $objects['participant'];
$event =& $objects['event'];
if (empty($values)) {
$values = array();
if ($input['component'] == 'contribute') {
require_once 'CRM/Contribute/BAO/ContributionPage.php';
if (isset($contribution->contribution_page_id)) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
} else {
// Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
$values['is_email_receipt'] = 1;
$values['title'] = 'Contribution';
}
} else {
// event
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
require_once 'CRM/Event/Form/ManageEvent/Location.php';
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'weight' => 1);
$values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
$ufJoinParams['weight'] = 2;
$values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
}
}
$template =& CRM_Core_Smarty::singleton();
// CRM_Core_Error::debug('tpl',$template);
//assign honor infomation to receiptmessage
if ($honarID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'honor_contact_id')) {
$honorDefault = array();
$honorIds = array();
$honorIds['contribution'] = $contribution->id;
$idParams = array('id' => $honarID, 'contact_id' => $honarID);
require_once "CRM/Contact/BAO/Contact.php";
CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds);
require_once "CRM/Core/PseudoConstant.php";
$honorType = CRM_Core_PseudoConstant::honor();
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$template->assign('honor_block_is_active', 1);
$template->assign('honor_prefix', $prefix[$honorDefault["prefix_id"]]);
$template->assign('honor_first_name', CRM_Utils_Array::value("first_name", $honorDefault));
$template->assign('honor_last_name', CRM_Utils_Array::value("last_name", $honorDefault));
$template->assign('honor_email', CRM_Utils_Array::value("email", $honorDefault["email"][1]));
$template->assign('honor_type', $honorType[$contribution->honor_type_id]);
}
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $contribution->id;
if ($dao->find(true)) {
$premiumId = $dao->product_id;
$template->assign('option', $dao->product_option);
require_once 'CRM/Contribute/DAO/Product.php';
$productDAO =& new CRM_Contribute_DAO_Product();
$productDAO->id = $premiumId;
$productDAO->find(true);
$template->assign('selectPremium', true);
$template->assign('product_name', $productDAO->name);
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
// add the new contribution values
if ($input['component'] == 'contribute') {
$template->assign('title', $values['title']);
$template->assign('amount', $input['amount']);
//PCP Info
require_once 'CRM/Contribute/DAO/ContributionSoft.php';
$softDAO =& new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $contribution->id;
if ($softDAO->find(true)) {
$template->assign('pcpBlock', true);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
require_once 'CRM/Contribute/DAO/PCP.php';
$pcpDAO =& new CRM_Contribute_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(true)) {
$template->assign('title', $pcpDAO->title);
}
}
} else {
$template->assign('title', $values['event']['title']);
$template->assign('totalAmount', $input['amount']);
}
$template->assign('trxn_id', $contribution->trxn_id);
//.........这里部分代码省略.........
示例10: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
// current contribution page id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'REQUEST');
$this->assign('contributionPageID', $this->_id);
// get the requested action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
// setting title and 3rd level breadcrumb for html page if contrib page exists
if ($this->_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->_single = TRUE;
}
}
// CRM-16776 - show edit/copy/create buttons on Profiles Tab if user has required permission.
if (CRM_Core_Permission::check('administer CiviCRM')) {
$this->assign('perm', TRUE);
}
// set up tabs
CRM_Contribute_Form_ContributionPage_TabHeader::build($this);
if ($this->_action == CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Configure Page - %1', array(1 => $title)));
} elseif ($this->_action == CRM_Core_Action::VIEW) {
CRM_Utils_System::setTitle(ts('Preview Page - %1', array(1 => $title)));
} elseif ($this->_action == CRM_Core_Action::DELETE) {
CRM_Utils_System::setTitle(ts('Delete Page - %1', array(1 => $title)));
}
//cache values.
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if (isset($this->_id) && $this->_id) {
$params = array('id' => $this->_id);
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values);
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
}
$this->set('values', $this->_values);
}
// Check permission to edit contribution page
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && $this->_action & CRM_Core_Action::UPDATE) {
$financialTypeID = CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']);
if (!CRM_Core_Permission::check('edit contributions of type ' . $financialTypeID)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
}
// Preload libraries required by the "Profiles" tab
$schemas = array('IndividualModel', 'OrganizationModel', 'ContributionModel');
if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) {
$schemas[] = 'MembershipModel';
}
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas($schemas);
}
示例11: 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) {
$pastContributionID = $session->get('pastContributionID');
if (!$pastContributionID) {
CRM_Core_Error::fatal(ts('We can\'t load the requested web page due to an incomplete link. This can be caused by using your browser\'s Back button or by using an incomplete or invalid link.'));
} else {
CRM_Core_Error::fatal(ts('This contribution has already been submitted. Click <a href=\'%1\'>here</a> if you want to make another contribution.', array(1 => CRM_Utils_System::url('civicrm/contribute/transact', 'reset=1&id=' . $pastContributionID))));
}
} else {
$session->set('pastContributionID', $this->_id);
}
$this->_userID = $session->get('userID');
$this->_mid = null;
if ($this->_userID) {
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
if ($this->_mid) {
require_once 'CRM/Member/DAO/Membership.php';
$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->_userID) {
require_once 'CRM/Contact/BAO/Relationship.php';
$employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
if (array_key_exists($membership->contact_id, $employers)) {
$this->_membershipContactID = $membership->contact_id;
$this->assign('membershipContactID', $this->_membershipContactID);
$this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
} 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."));
}
}
} 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."));
}
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();
require_once 'CRM/Contribute/BAO/ContributionPage.php';
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
// check if form is active
if (!$this->_values['is_active']) {
// 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::locationType();
$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);
if ($isMonetary && (!$isPayLater || CRM_Utils_Array::value('payment_processor_id', $this->_values))) {
$ppID = CRM_Utils_Array::value('payment_processor_id', $this->_values);
if (!$ppID) {
CRM_Core_Error::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
}
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
// check selected payment processor is active
if (empty($this->_paymentProcessor)) {
CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
// ensure that processor has a valid config
$this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
//.........这里部分代码省略.........
示例12: submit
/**
* Static submit function allowing tests (& api access although this is being built slowly)
* @param $params
*/
static function submit($params)
{
$form = new CRM_Contribute_Form_Contribution_Confirm();
$form->_id = $params['id'];
CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values);
$form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id);
//this way the mocked up controller ignores the session stuff
$_SERVER['REQUEST_METHOD'] = 'GET';
$form->controller = new CRM_Contribute_Controller_Contribution();
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
$form->_amount = $params['amount'];
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
$priceSetFields = reset($priceFields);
$form->_values['fee'] = $priceSetFields['fields'];
$form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
if (!empty($params['payment_processor'])) {
$form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor']));
}
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');
$form->_lineItem = array($priceSetID => $lineItems);
$form->postProcess();
}
示例13: addContributionPageValuesToValuesHeavyHandedly
/**
* ContributionPage values were being imposed onto values.
*
* I have made this explicit and removed the couple (is_recur, is_pay_later) we
* REALLY didn't want superimposed. The rest are left there in their overkill out
* of cautiousness.
*
* The rationale for making this explicit is that it was a case of carefully set values being
* seemingly randonly overwritten without much care. In general I think array randomly setting
* variables en mass is risky.
*
* @param array $values
*
* @return array
*/
protected function addContributionPageValuesToValuesHeavyHandedly(&$values)
{
$contributionPageValues = array();
CRM_Contribute_BAO_ContributionPage::setValues($this->contribution_page_id, $contributionPageValues);
$valuesToCopy = array('id', 'title', 'is_email_receipt', 'pay_later_receipt', 'pay_later_text', 'receipt_from_email', 'receipt_from_name', 'receipt_text', 'custom_pre_id', 'custom_post_id', 'honoree_profile_id', 'onbehalf_profile_id', 'honor_block_is_active', 'campaign_id', 'currency', 'intro_text', 'payment_processor', 'financial_type_id', 'amount_block_is_active', 'bcc_receipt', 'cc_receipt', 'created_date', 'created_id', 'default_amount_id', 'end_date', 'footer_text', 'goal_amount', 'initial_amount_help_text', 'initial_amount_label', 'intro_text', 'is_allow_other_amount', 'is_billing_required', 'is_confirm_enabled', 'is_credit_card_only', 'is_monetary', 'is_partial_payment', 'is_recur_installments', 'is_recur_interval', 'is_share', 'max_amount', 'min_amount', 'min_initial_amount', 'recur_frequency_unit', 'start_date', 'thankyou_footer', 'thankyou_text', 'thankyou_title');
foreach ($valuesToCopy as $valueToCopy) {
if (isset($contributionPageValues[$valueToCopy])) {
$values[$valueToCopy] = $contributionPageValues[$valueToCopy];
}
}
return $values;
}