Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * This class contains all the function that are called using AJAX | |
20 | */ | |
21 | class CRM_Mailing_Page_AJAX { | |
22 | ||
23 | /** | |
100fef9d | 24 | * Fetch the template text/html messages |
6a488035 | 25 | */ |
7c006637 | 26 | public static function template() { |
6a488035 TO |
27 | $templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer'); |
28 | ||
c6327d7d | 29 | $messageTemplate = new CRM_Core_DAO_MessageTemplate(); |
6a488035 TO |
30 | $messageTemplate->id = $templateId; |
31 | $messageTemplate->selectAdd(); | |
32 | $messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id'); | |
33 | $messageTemplate->find(TRUE); | |
be2fb01f | 34 | $messages = [ |
6a488035 TO |
35 | 'subject' => $messageTemplate->msg_subject, |
36 | 'msg_text' => $messageTemplate->msg_text, | |
37 | 'msg_html' => $messageTemplate->msg_html, | |
38 | 'pdf_format_id' => $messageTemplate->pdf_format_id, | |
be2fb01f | 39 | ]; |
6a488035 | 40 | |
90a73810 | 41 | $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $templateId); |
42 | foreach ((array) $documentInfo as $info) { | |
00eb08cf | 43 | list($messages['document_body']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']); |
90a73810 | 44 | } |
45 | ||
ecdef330 | 46 | CRM_Utils_JSON::output($messages); |
6a488035 | 47 | } |
553f116a KJ |
48 | |
49 | /** | |
fe482240 | 50 | * Retrieve contact mailings. |
553f116a | 51 | */ |
7c006637 | 52 | public static function getContactMailings() { |
9c3f979f | 53 | $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); |
be2fb01f | 54 | $params += CRM_Core_Page_AJAX::validateParams(['contact_id' => 'Integer']); |
553f116a KJ |
55 | |
56 | // get the contact mailings | |
57 | $mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params); | |
58 | ||
41348d61 | 59 | CRM_Utils_JSON::output($mailings); |
553f116a | 60 | } |
96025800 | 61 | |
6a488035 | 62 | } |