本文整理汇总了PHP中CRM_Utils_Token::getAnonymousTokenDetails方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Token::getAnonymousTokenDetails方法的具体用法?PHP CRM_Utils_Token::getAnonymousTokenDetails怎么用?PHP CRM_Utils_Token::getAnonymousTokenDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Token
的用法示例。
在下文中一共展示了CRM_Utils_Token::getAnonymousTokenDetails方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run this page (figure out the action needed and perform it).
*
* @param int $id
* @param int $contactID
* @param bool $print
* @param bool $allowID
*/
public function run($id = NULL, $contactID = NULL, $print = TRUE, $allowID = FALSE)
{
if (is_numeric($id)) {
$this->_mailingID = $id;
} else {
$print = TRUE;
$this->_mailingID = CRM_Utils_Request::retrieve('id', 'String', CRM_Core_DAO::$_nullObject, TRUE);
}
// # CRM-7651
// override contactID from the function level if passed in
if (isset($contactID) && is_numeric($contactID)) {
$this->_contactID = $contactID;
} else {
$session = CRM_Core_Session::singleton();
$this->_contactID = $session->get('userID');
}
// mailing key check
if (Civi::settings()->get('hash_mailing_url')) {
$this->_mailing = new CRM_Mailing_BAO_Mailing();
if (!is_numeric($this->_mailingID)) {
$this->_mailing->hash = $this->_mailingID;
} elseif (is_numeric($this->_mailingID)) {
$this->_mailing->id = $this->_mailingID;
// if mailing is present and associated hash is present
// while 'hash' is not been used for mailing view : throw 'permissionDenied'
if ($this->_mailing->find() && CRM_Core_DAO::getFieldValue('CRM_Mailing_BAO_Mailing', $this->_mailingID, 'hash', 'id') && !$allowID) {
CRM_Utils_System::permissionDenied();
return;
}
}
} else {
$this->_mailing = new CRM_Mailing_BAO_Mailing();
$this->_mailing->id = $this->_mailingID;
}
if (!$this->_mailing->find(TRUE) || !$this->checkPermission()) {
CRM_Utils_System::permissionDenied();
return;
}
CRM_Mailing_BAO_Mailing::tokenReplace($this->_mailing);
// get and format attachments
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $this->_mailing->id);
// get contact detail and compose if contact id exists
$returnProperties = $this->_mailing->getReturnProperties();
if (isset($this->_contactID)) {
// get details of contact with token value including Custom Field Token Values.CRM-3734
$params = array('contact_id' => $this->_contactID);
$details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, FALSE, TRUE, NULL, $this->_mailing->getFlattenedTokens(), get_class($this));
$details = $details[0][$this->_contactID];
$contactId = $this->_contactID;
} else {
// get tokens that are not contact specific resolved
$params = array('contact_id' => 0);
$details = CRM_Utils_Token::getAnonymousTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, $this->_mailing->getFlattenedTokens(), get_class($this));
$details = CRM_Utils_Array::value(0, $details[0]);
$contactId = 0;
}
$mime =& $this->_mailing->compose(NULL, NULL, NULL, $contactId, $this->_mailing->from_email, $this->_mailing->from_email, TRUE, $details, $attachments);
$title = NULL;
if (isset($this->_mailing->body_html) && empty($_GET['text'])) {
$header = 'text/html; charset=utf-8';
$content = $mime->getHTMLBody();
if (strpos($content, '<head>') === FALSE && strpos($content, '<title>') === FALSE) {
$title = '<head><title>' . $this->_mailing->subject . '</title></head>';
}
} else {
$header = 'text/plain; charset=utf-8';
$content = $mime->getTXTBody();
}
CRM_Utils_System::setTitle($this->_mailing->subject);
if (CRM_Utils_Array::value('snippet', $_GET) === 'json') {
CRM_Core_Page_AJAX::returnJsonResponse($content);
}
if ($print) {
CRM_Utils_System::setHttpHeader('Content-Type', $header);
print $title;
print $content;
CRM_Utils_System::civiExit();
} else {
return $content;
}
}
示例2: run
/**
* run this page (figure out the action needed and perform it).
*
* @return void
*/
function run($id = NULL, $contactID = NULL, $print = TRUE)
{
if (is_numeric($id)) {
$this->_mailingID = $id;
} else {
$print = TRUE;
$this->_mailingID = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE);
}
// # CRM-7651
// override contactID from the function level if passed in
if (isset($contactID) && is_numeric($contactID)) {
$this->_contactID = $contactID;
} else {
$session = CRM_Core_Session::singleton();
$this->_contactID = $session->get('userID');
}
$this->_mailing = new CRM_Mailing_BAO_Mailing();
$this->_mailing->id = $this->_mailingID;
if (!$this->_mailing->find(TRUE) || !$this->checkPermission()) {
CRM_Utils_System::permissionDenied();
return;
}
CRM_Mailing_BAO_Mailing::tokenReplace($this->_mailing);
// get and format attachments
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $this->_mailing->id);
// get contact detail and compose if contact id exists
if (isset($this->_contactID)) {
//get details of contact with token value including Custom Field Token Values.CRM-3734
$returnProperties = $this->_mailing->getReturnProperties();
$params = array('contact_id' => $this->_contactID);
$details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, FALSE, TRUE, NULL, $this->_mailing->getFlattenedTokens(), get_class($this));
$details = $details[0][$this->_contactID];
$contactId = $this->_contactID;
} else {
$details = array('test');
//get tokens that are not contact specific resolved
$params = array('contact_id' => 0);
$details = CRM_Utils_Token::getAnonymousTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, $this->_mailing->getFlattenedTokens(), get_class($this));
$details = $details[0][0];
$contactId = 0;
}
$mime =& $this->_mailing->compose(NULL, NULL, NULL, $contactId, $this->_mailing->from_email, $this->_mailing->from_email, TRUE, $details, $attachments);
$title = NULL;
if (isset($this->_mailing->body_html)) {
$header = 'Content-Type: text/html; charset=utf-8';
$content = $mime->getHTMLBody();
if (strpos($content, '<head>') === FALSE && strpos($content, '<title>') === FALSE) {
$title = '<head><title>' . $this->_mailing->subject . '</title></head>';
}
} else {
$header = 'Content-Type: text/plain; charset=utf-8';
$content = $mime->getTXTBody();
}
if ($print) {
header($header);
print $title;
print $content;
CRM_Utils_System::civiExit();
} else {
return $content;
}
}