本文整理匯總了PHP中CRM_Contribute_BAO_Contribution::getOnbehalfIds方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Contribute_BAO_Contribution::getOnbehalfIds方法的具體用法?PHP CRM_Contribute_BAO_Contribution::getOnbehalfIds怎麽用?PHP CRM_Contribute_BAO_Contribution::getOnbehalfIds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::getOnbehalfIds方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _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 (is_array($this->_relatedObjects['membership']) && 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']);
// add custom fields for event
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this->_relatedObjects['event'], $this->_relatedObjects['event']->id);
$eventCustomGroup = array();
foreach ($eventGroupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$eventCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['event']['customGroup'] = $eventCustomGroup;
//get participant details
$participantParams = array('id' => $this->_relatedObjects['participant']->id);
$values['participant'] = array();
CRM_Event_BAO_Participant::getValues($participantParams, $values['participant'], $participantIds);
// add custom fields for event
$participantGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this->_relatedObjects['participant'], $this->_relatedObjects['participant']->id);
$participantCustomGroup = array();
foreach ($participantGroupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$participantCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['participant']['customGroup'] = $participantCustomGroup;
//get location details
//.........這裏部分代碼省略.........
示例2: 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();
$contribID = $ids['contribution'];
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';
}
// set lineItem for contribution
require_once 'CRM/Price/BAO/Set.php';
if ($contribID && ($pId = CRM_Price_BAO_Set::getFor('civicrm_contribution', $contribID))) {
require_once 'CRM/Price/BAO/LineItem.php';
$values['lineItem'][0] = CRM_Price_BAO_LineItem::getLineItems($contribID, 'contribution');
$values['priceSetID'] = $pId;
}
require_once 'CRM/Contribute/BAO/Contribution.php';
$relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($contribID, $contribution->contact_id);
// if this is onbehalf of contribution then set related contact
if ($relatedContactId = $relatedContact['individual_id']) {
$values['related_contact'] = $ids['related_contact'] = $relatedContactId;
}
} 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']);
//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);
// set lineItem for event contribution
if ($contribID) {
require_once 'CRM/Event/BAO/Participant.php';
$participantIds = CRM_Event_BAO_Participant::getParticipantIds($contribID);
require_once 'CRM/Price/BAO/LineItem.php';
if (!empty($participantIds)) {
foreach ($participantIds as $pIDs) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($pIDs);
if (!CRM_Utils_System::isNull($lineItem)) {
$values['lineItem'][] = $lineItem;
}
}
}
}
}
// set receipt from e-mail and name in value
if (!$returnMessageText) {
require_once 'CRM/Contact/BAO/Contact/Location.php';
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
$values['receipt_from_email'] = $userEmail;
$values['receipt_from_name'] = $userName;
}
// set display address of contributor
if ($contribution->address_id) {
require_once 'CRM/Core/BAO/Address.php';
$addressParams = array('id' => $contribution->address_id);
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, false, 'id');
$addressDetails = array_values($addressDetails);
$values['address'] = $addressDetails[0]['display'];
}
}
$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]);
}
//.........這裏部分代碼省略.........