3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * a page for mailing preview
39 class CRM_Mailing_Page_Preview
extends CRM_Core_Page
{
42 * run this page (figure out the action needed and perform it).
48 $session = CRM_Core_Session
::singleton();
50 $qfKey = CRM_Utils_Request
::retrieve('qfKey', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 'text');
51 $type = CRM_Utils_Request
::retrieve('type', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 'text');
54 $session->getVars($options, "CRM_Mailing_Controller_Send_$qfKey");
56 //get the options if control come from search context, CRM-3711
57 if (empty($options)) {
58 $session->getVars($options, "CRM_Contact_Controller_Search_$qfKey");
61 // FIXME: the below and CRM_Mailing_Form_Test::testMail()
62 // should be refactored
64 $mailing = new CRM_Mailing_BAO_Mailing();
65 if (!empty($options)) {
66 $mailing->id
= $options['mailing_id'];
67 $fromEmail = CRM_Utils_Array
::value('from_email', $options);
72 CRM_Mailing_BAO_Mailing
::tokenReplace($mailing);
74 // get and format attachments
75 $attachments = CRM_Core_BAO_File
::getEntityFile('civicrm_mailing',
79 //get details of contact with token value including Custom Field Token Values.CRM-3734
80 $returnProperties = $mailing->getReturnProperties();
81 $params = array('contact_id' => $session->get('userID'));
83 $details = CRM_Utils_Token
::getTokenDetails($params,
86 $mailing->getFlattenedTokens(),
90 $mime = &$mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail,
91 TRUE, $details[0][$session->get('userID')], $attachments
94 if ($type == 'html') {
95 header('Content-Type: text/html; charset=utf-8');
96 print $mime->getHTMLBody();
99 header('Content-Type: text/plain; charset=utf-8');
100 print $mime->getTXTBody();
102 CRM_Utils_System
::civiExit();