當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Utils_Token::replaceContributionTokens方法代碼示例

本文整理匯總了PHP中CRM_Utils_Token::replaceContributionTokens方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_Token::replaceContributionTokens方法的具體用法?PHP CRM_Utils_Token::replaceContributionTokens怎麽用?PHP CRM_Utils_Token::replaceContributionTokens使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Utils_Token的用法示例。


在下文中一共展示了CRM_Utils_Token::replaceContributionTokens方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: resolveTokens

 /**
  *
  * @param string $html_message
  * @param array $contact
  * @param array $contribution
  * @param array $messageToken
  * @param array $categories
  * @param bool $grouped
  *   Does this letter represent more than one contribution.
  * @param string $separator
  *   What is the preferred letter separator.
  * @return string
  */
 private static function resolveTokens($html_message, $contact, $contribution, $messageToken, $categories, $grouped, $separator)
 {
     $tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact, TRUE, $messageToken);
     if ($grouped) {
         $tokenHtml = CRM_Utils_Token::replaceMultipleContributionTokens($separator, $tokenHtml, $contribution, TRUE, $messageToken);
     } else {
         // no change to normal behaviour to avoid risk of breakage
         $tokenHtml = CRM_Utils_Token::replaceContributionTokens($tokenHtml, $contribution, TRUE, $messageToken);
     }
     $tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact, $categories, TRUE);
     if (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY) {
         $smarty = CRM_Core_Smarty::singleton();
         // also add the tokens to the template
         $smarty->assign_by_ref('contact', $contact);
         $tokenHtml = $smarty->fetch("string:{$tokenHtml}");
     }
     return $tokenHtml;
 }
開發者ID:nielosz,項目名稱:civicrm-core,代碼行數:31,代碼來源:PDFLetterCommon.php

示例2: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return void
  */
 static function postProcess(&$form)
 {
     list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($form);
     // 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 = 0;
     $thanks = 0;
     $updateStatus = '';
     // skip some contacts ?
     $skipOnHold = isset($form->skipOnHold) ? $form->skipOnHold : FALSE;
     $skipDeceased = isset($form->skipDeceased) ? $form->skipDeceased : TRUE;
     foreach ($form->getVar('_contributionIds') as $item => $contributionId) {
         // get contact information
         $contactId = civicrm_api("Contribution", "getvalue", array('version' => '3', 'id' => $contributionId, 'return' => 'contact_id'));
         $params = array('contact_id' => $contactId);
         list($contact) = CRM_Utils_Token::getTokenDetails($params, $returnProperties, $skipOnHold, $skipDeceased, NULL, $messageToken, 'CRM_Contribution_Form_Task_PDFLetterCommon');
         if (civicrm_error($contact)) {
             $notSent[] = $contributionId;
             continue;
         }
         // get contribution information
         $params = array('contribution_id' => $contributionId);
         $contribution = CRM_Utils_Token::getContributionTokenDetails($params, $returnProperties, NULL, $messageToken, 'CRM_Contribution_Form_Task_PDFLetterCommon');
         if (civicrm_error($contribution)) {
             $notSent[] = $contributionId;
             continue;
         }
         $tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], TRUE, $messageToken);
         $tokenHtml = CRM_Utils_Token::replaceContributionTokens($tokenHtml, $contribution[$contributionId], TRUE, $messageToken);
         $tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact[$contactId], $categories, TRUE);
         if (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY) {
             $smarty = CRM_Core_Smarty::singleton();
             // also add the tokens to the template
             $smarty->assign_by_ref('contact', $contact);
             $tokenHtml = $smarty->fetch("string:{$tokenHtml}");
         }
         $html[] = $tokenHtml;
         // update dates (do it for each contribution including grouped recurring contribution)
         if ($receipt_update) {
             $result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'receipt_date', $nowDate);
             // We can't use CRM_Core_Error::fatal here because the api error elevates the exception level. FIXME. dgg
             if ($result) {
                 $receipts++;
             }
         }
         if ($thankyou_update) {
             $result = CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'thankyou_date', $nowDate);
             // We can't use CRM_Core_Error::fatal here because the api error elevates the exception level. FIXME. dgg
             if ($result) {
                 $thanks++;
             }
         }
     }
     self::createActivities($form, $html_message, $form->_contactIds);
     CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
     $form->postProcessHook();
     if ($receipts) {
         $updateStatus = ts('Receipt date has been updated for %1 contributions.', array(1 => $receipts));
     }
     if ($thanks) {
         $updateStatus .= ' ' . ts('Thank-you date has been updated for %1 contributions.', array(1 => $thanks));
     }
     if ($updateStatus) {
         CRM_Core_Session::setStatus($updateStatus);
     }
     CRM_Utils_System::civiExit(1);
 }
開發者ID:archcidburnziso,項目名稱:civicrm-core,代碼行數:76,代碼來源:PDFLetterCommon.php


注:本文中的CRM_Utils_Token::replaceContributionTokens方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。