本文整理汇总了PHP中CRM_Activity_BAO_Activity::getTokens方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::getTokens方法的具体用法?PHP CRM_Activity_BAO_Activity::getTokens怎么用?PHP CRM_Activity_BAO_Activity::getTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::getTokens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
static function postProcess(&$form)
{
$formValues = $form->controller->exportValues($form->getName());
// process message template
require_once 'CRM/Core/BAO/MessageTemplates.php';
if (CRM_Utils_Array::value('saveTemplate', $formValues) || CRM_Utils_Array::value('updateTemplate', $formValues)) {
$messageTemplate = array('msg_text' => NULL, 'msg_html' => $formValues['html_message'], 'msg_subject' => NULL, 'is_active' => true);
if ($formValues['saveTemplate']) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
if ($formValues['template'] && $formValues['updateTemplate']) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
}
require_once 'dompdf/dompdf_config.inc.php';
$html = '<html><head><style>body { margin: 56px; }</style></head><body>';
require_once 'api/v2/Contact.php';
require_once 'CRM/Utils/Token.php';
$tokens = array();
CRM_Utils_Hook::tokens($tokens);
$categories = array_keys($tokens);
$html_message = $formValues['html_message'];
//time being hack to strip ' '
//from particular letter line, CRM-6798
self::formatMessage($html_message);
require_once 'CRM/Activity/BAO/Activity.php';
$messageToken = CRM_Activity_BAO_Activity::getTokens($html_message);
$returnProperties = array();
if (isset($messageToken['contact'])) {
foreach ($messageToken['contact'] as $key => $value) {
$returnProperties[$value] = 1;
}
}
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = new CRM_Mailing_BAO_Mailing();
if (defined('CIVICRM_MAIL_SMARTY')) {
require_once 'CRM/Core/Smarty/resources/String.php';
civicrm_smarty_register_string_resource();
}
$first = TRUE;
foreach ($form->_contactIds as $item => $contactId) {
$params = array('contact_id' => $contactId);
list($contact) = $mailing->getDetails($params, $returnProperties, false);
if (civicrm_error($contact)) {
$notSent[] = $contactId;
continue;
}
$tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], true, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact[$contactId], $categories, true);
if (defined('CIVICRM_MAIL_SMARTY')) {
$smarty = CRM_Core_Smarty::singleton();
// also add the contact tokens to the template
$smarty->assign_by_ref('contact', $contact);
$tokenHtml = $smarty->fetch("string:{$tokenHtml}");
}
if ($first == TRUE) {
$first = FALSE;
$html .= $tokenHtml;
} else {
$html .= "<div STYLE='page-break-after: always'></div>{$tokenHtml}";
}
}
$html .= '</body></html>';
require_once 'CRM/Activity/BAO/Activity.php';
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
if ($form->_activityId) {
$activityParams += array('id' => $form->_activityId);
}
if ($form->_cid) {
$activity = CRM_Activity_BAO_Activity::create($activityParams);
} else {
// create Print PDF activity for each selected contact. CRM-6886
$activityIds = array();
foreach ($form->_contactIds as $contactId) {
$activityID = CRM_Activity_BAO_Activity::create($activityParams);
$activityIds[$contactId] = $activityID->id;
}
}
foreach ($form->_contactIds as $contactId) {
$activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'target_contact_id' => $contactId);
CRM_Activity_BAO_Activity::createActivityTarget($activityTargetParams);
}
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", 'portrait', 'letter');
// we need to call the hook manually here since we redirect and never
// go back to CRM/Core/Form.php
CRM_Utils_Hook::postProcess(get_class($form), $form);
CRM_Utils_System::civiExit(1);
//.........这里部分代码省略.........
示例2: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
static function postProcess(&$form)
{
$formValues = $form->controller->exportValues($form->getName());
// process message template
require_once 'CRM/Core/BAO/MessageTemplates.php';
if (CRM_Utils_Array::value('saveTemplate', $formValues) || CRM_Utils_Array::value('updateTemplate', $formValues)) {
$messageTemplate = array('msg_text' => NULL, 'msg_html' => $formValues['html_message'], 'msg_subject' => NULL, 'is_active' => true);
if ($formValues['saveTemplate']) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
if ($formValues['template'] && $formValues['updateTemplate']) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
}
require_once 'dompdf/dompdf_config.inc.php';
$html = '<html><head><style>body { margin: 56px; }</style></head><body>';
require_once 'api/v2/Contact.php';
require_once 'CRM/Utils/Token.php';
$tokens = array();
CRM_Utils_Hook::tokens($tokens);
$categories = array_keys($tokens);
$html_message = $formValues['html_message'];
require_once 'CRM/Activity/BAO/Activity.php';
$messageToken = CRM_Activity_BAO_Activity::getTokens($html_message);
$returnProperties = array();
if (isset($messageToken['contact'])) {
foreach ($messageToken['contact'] as $key => $value) {
$returnProperties[$value] = 1;
}
}
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing =& new CRM_Mailing_BAO_Mailing();
$first = TRUE;
foreach ($form->_contactIds as $item => $contactId) {
$params = array('contact_id' => $contactId);
list($contact) = $mailing->getDetails($params, $returnProperties, false);
if (civicrm_error($contact)) {
$notSent[] = $contactId;
continue;
}
$tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], true, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact[$contactId], $categories, true);
if ($first == TRUE) {
$first = FALSE;
$html .= $tokenHtml;
} else {
$html .= "<div STYLE='page-break-after: always'></div>{$tokenHtml}";
}
}
$html .= '</body></html>';
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", 'portrait');
exit(1);
}