本文整理汇总了PHP中CRM_Contribute_Form_Task::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_Form_Task::getVar方法的具体用法?PHP CRM_Contribute_Form_Task::getVar怎么用?PHP CRM_Contribute_Form_Task::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_Form_Task
的用法示例。
在下文中一共展示了CRM_Contribute_Form_Task::getVar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form after the input has been submitted and validated.
*
* @param CRM_Contribute_Form_Task $form
*/
public static function postProcess(&$form)
{
$formValues = $form->controller->exportValues($form->getName());
list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues);
$isPDF = FALSE;
$emailParams = array();
if (!empty($formValues['email_options'])) {
$returnProperties['email'] = $returnProperties['on_hold'] = $returnProperties['is_deceased'] = $returnProperties['do_not_email'] = 1;
$emailParams = array('subject' => $formValues['subject']);
// We need display_name for emailLetter() so add to returnProperties here
$returnProperties['display_name'] = 1;
if (stristr($formValues['email_options'], 'pdfemail')) {
$isPDF = TRUE;
}
}
// update dates ?
$receipt_update = isset($formValues['receipt_update']) ? $formValues['receipt_update'] : FALSE;
$thankyou_update = isset($formValues['thankyou_update']) ? $formValues['thankyou_update'] : FALSE;
$nowDate = date('YmdHis');
$receipts = $thanks = $emailed = 0;
$updateStatus = '';
$task = 'CRM_Contribution_Form_Task_PDFLetterCommon';
$realSeparator = ', ';
$tableSeparators = array('td' => '</td><td>', 'tr' => '</td></tr><tr><td>');
//the original thinking was mutliple options - but we are going with only 2 (comma & td) for now in case
// there are security (& UI) issues we need to think through
if (isset($formValues['group_by_separator'])) {
if (in_array($formValues['group_by_separator'], array('td', 'tr'))) {
$realSeparator = $tableSeparators[$formValues['group_by_separator']];
} elseif ($formValues['group_by_separator'] == 'br') {
$realSeparator = "<br />";
}
}
$separator = '****~~~~';
// a placeholder in case the separator is common in the string - e.g ', '
$validated = FALSE;
$groupBy = $formValues['group_by'];
// skip some contacts ?
$skipOnHold = isset($form->skipOnHold) ? $form->skipOnHold : FALSE;
$skipDeceased = isset($form->skipDeceased) ? $form->skipDeceased : TRUE;
$contributionIDs = $form->getVar('_contributionIds');
if ($form->_includesSoftCredits) {
//@todo - comment on what is stored there
$contributionIDs = $form->getVar('_contributionContactIds');
}
list($contributions, $contacts) = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->_includesSoftCredits);
$html = array();
foreach ($contributions as $contributionId => $contribution) {
$contact =& $contacts[$contribution['contact_id']];
$grouped = $groupByID = 0;
if ($groupBy) {
$groupByID = empty($contribution[$groupBy]) ? 0 : $contribution[$groupBy];
$contribution = $contact['combined'][$groupBy][$groupByID];
$grouped = TRUE;
}
self::assignCombinedContributionValues($contact, $contributions, $groupBy, $groupByID);
if (empty($groupBy) || empty($contact['is_sent'][$groupBy][$groupByID])) {
if (!$validated && in_array($realSeparator, $tableSeparators) && !self::isValidHTMLWithTableSeparator($messageToken, $html_message)) {
$realSeparator = ', ';
CRM_Core_Session::setStatus(ts('You have selected the table cell separator, but one or more token fields are not placed inside a table cell. This would result in invalid HTML, so comma separators have been used instead.'));
}
$validated = TRUE;
$html[$contributionId] = str_replace($separator, $realSeparator, self::resolveTokens($html_message, $contact, $contribution, $messageToken, $categories, $grouped, $separator));
$contact['is_sent'][$groupBy][$groupByID] = TRUE;
if (!empty($formValues['email_options'])) {
if (self::emailLetter($contact, $html[$contributionId], $isPDF, $formValues, $emailParams)) {
$emailed++;
if (!stristr($formValues['email_options'], 'both')) {
unset($html[$contributionId]);
}
}
}
}
// update dates (do it for each contribution including grouped recurring contribution)
//@todo - the 2 calls below bypass all hooks. Using the api would possibly be slower than one call but not than 2
if ($receipt_update) {
$result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'receipt_date', $nowDate);
if ($result) {
$receipts++;
}
}
if ($thankyou_update) {
$result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'thankyou_date', $nowDate);
if ($result) {
$thanks++;
}
}
}
//createActivities requires both $form->_contactIds and $contacts -
//@todo - figure out why
$form->_contactIds = array_keys($contacts);
self::createActivities($form, $html_message, $form->_contactIds);
if (!empty($html)) {
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
}
//.........这里部分代码省略.........
示例2: buildContributionArray
/**
* Generate the contribution array from the form, we fill in the contact details and determine any aggregation
* around contact_id of contribution_recur_id
*
* @param string $groupBy
* @param CRM_Contribute_Form_Task $form
* @param array $returnProperties
* @param bool $skipOnHold
* @param bool $skipDeceased
* @param array $messageToken
* @param string $task
* @param string $separator
*
* @return array
*/
public static function buildContributionArray($groupBy, $form, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator)
{
$contributions = $contacts = $notSent = array();
$contributionIDs = $form->getVar('_contributionIds');
if ($form->_includesSoftCredits) {
//@todo - comment on what is stored there
$contributionIDs = $form->getVar('_contributionContactIds');
}
foreach ($contributionIDs as $item => $contributionId) {
// get contribution information
$contribution = CRM_Utils_Token::getContributionTokenDetails(array('contribution_id' => $contributionId), $returnProperties, NULL, $messageToken, $task);
$contribution = $contributions[$contributionId] = $contribution[$contributionId];
if ($form->_includesSoftCredits) {
//@todo find out why this happens & add comments
list($contactID) = explode('-', $item);
$contactID = (int) $contactID;
} else {
$contactID = $contribution['contact_id'];
}
if (!isset($contacts[$contactID])) {
list($contact) = CRM_Utils_Token::getTokenDetails(array('contact_id' => $contactID), $returnProperties, $skipOnHold, $skipDeceased, NULL, $messageToken, $task);
$contacts[$contactID] = $contact[$contactID];
$contacts[$contactID]['contact_aggregate'] = 0;
$contacts[$contactID]['combined'] = $contacts[$contactID]['contribution_ids'] = array();
}
$contacts[$contactID]['contact_aggregate'] += $contribution['total_amount'];
$groupByID = empty($contribution[$groupBy]) ? 0 : $contribution[$groupBy];
$contacts[$contactID]['contribution_ids'][$groupBy][$groupByID][$contributionId] = TRUE;
if (!isset($contacts[$contactID]['combined'][$groupBy]) || !isset($contacts[$contactID]['combined'][$groupBy][$groupByID])) {
$contacts[$contactID]['combined'][$groupBy][$groupByID] = $contribution;
$contacts[$contactID]['aggregates'][$groupBy][$groupByID] = $contribution['total_amount'];
} else {
$contacts[$contactID]['combined'][$groupBy][$groupByID] = self::combineContributions($contacts[$contactID]['combined'][$groupBy][$groupByID], $contribution, $separator);
$contacts[$contactID]['aggregates'][$groupBy][$groupByID] += $contribution['total_amount'];
}
}
return array($contributions, $contacts);
}