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 | /** | |
25606795 | 19 | * Page to display / edit the header / footer of a mailing. |
6a488035 TO |
20 | */ |
21 | class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic { | |
22 | public $_mailing_id; | |
23 | ||
24 | /** | |
fe482240 | 25 | * Get BAO Name. |
6a488035 | 26 | * |
a6c01b45 CW |
27 | * @return string |
28 | * Classname of BAO | |
6a488035 | 29 | */ |
00be9182 | 30 | public function getBAOName() { |
6a488035 TO |
31 | return 'CRM_Mailing_BAO_Mailing'; |
32 | } | |
33 | ||
e0ef6999 | 34 | /** |
7535623a | 35 | * An array of action links. |
36 | * | |
e0ef6999 EM |
37 | * @return null |
38 | */ | |
00be9182 | 39 | public function &links() { |
6a488035 TO |
40 | return CRM_Core_DAO::$_nullObject; |
41 | } | |
42 | ||
e0ef6999 EM |
43 | /** |
44 | * @return null | |
45 | */ | |
00be9182 | 46 | public function editForm() { |
6a488035 TO |
47 | return NULL; |
48 | } | |
49 | ||
e0ef6999 EM |
50 | /** |
51 | * @return string | |
52 | */ | |
00be9182 | 53 | public function editName() { |
6a488035 TO |
54 | return 'CiviMail Report'; |
55 | } | |
56 | ||
57 | /** | |
58 | * Get user context. | |
59 | * | |
6c8f6e67 EM |
60 | * @param null $mode |
61 | * | |
a6c01b45 CW |
62 | * @return string |
63 | * user context. | |
6a488035 | 64 | */ |
00be9182 | 65 | public function userContext($mode = NULL) { |
6a488035 TO |
66 | return 'civicrm/mailing/report'; |
67 | } | |
68 | ||
e0ef6999 EM |
69 | /** |
70 | * @param null $mode | |
71 | * | |
72 | * @return string | |
73 | */ | |
00be9182 | 74 | public function userContextParams($mode = NULL) { |
6a488035 TO |
75 | return 'reset=1&mid=' . $this->_mailing_id; |
76 | } | |
77 | ||
e0ef6999 EM |
78 | /** |
79 | * @return string | |
80 | */ | |
00be9182 | 81 | public function run() { |
6a488035 | 82 | $this->_mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this); |
e81bac46 | 83 | //CRM-15979 - check if abtest exist for mailing then redirect accordingly |
84 | $abtest = CRM_Mailing_BAO_MailingAB::getABTest($this->_mailing_id); | |
85 | if (!empty($abtest) && !empty($abtest->id)) { | |
86 | CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id)); | |
87 | } | |
6a488035 TO |
88 | // check that the user has permission to access mailing id |
89 | CRM_Mailing_BAO_Mailing::checkPermission($this->_mailing_id); | |
90 | ||
91 | $report = CRM_Mailing_BAO_Mailing::report($this->_mailing_id); | |
92 | ||
25606795 | 93 | // get contents of mailing |
6a488035 TO |
94 | CRM_Mailing_BAO_Mailing::getMailingContent($report, $this); |
95 | ||
25606795 | 96 | // assign backurl |
edc80cda | 97 | $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); |
6a488035 TO |
98 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); |
99 | ||
100 | if ($context == 'activitySelector') { | |
101 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); | |
102 | $backUrlTitle = ts('Back to Activities'); | |
103 | } | |
104 | elseif ($context == 'activity') { | |
105 | $atype = CRM_Utils_Request::retrieve('atype', 'Positive', $this); | |
106 | $aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); | |
107 | ||
108 | $backUrl = CRM_Utils_System::url('civicrm/activity/view', | |
109 | "atype={$atype}&action=view&reset=1&id={$aid}&cid={$cid}&context=activity" | |
110 | ); | |
111 | $backUrlTitle = ts('Back to Activity'); | |
112 | } | |
b99698e5 KJ |
113 | elseif ($context == 'mailing') { |
114 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing"); | |
115 | $backUrlTitle = ts('Back to Mailing'); | |
116 | } | |
6a488035 TO |
117 | else { |
118 | $backUrl = CRM_Utils_System::url('civicrm/mailing', 'reset=1'); | |
119 | $backUrlTitle = ts('Back to CiviMail'); | |
120 | } | |
121 | $this->assign('backUrl', $backUrl); | |
122 | $this->assign('backUrlTitle', $backUrlTitle); | |
123 | ||
124 | $this->assign('report', $report); | |
125 | CRM_Utils_System::setTitle(ts('CiviMail Report: %1', | |
be2fb01f | 126 | [1 => $report['mailing']['name']] |
353ffa53 | 127 | )); |
7535623a | 128 | $this->assign('public_url', CRM_Mailing_BAO_Mailing::getPublicViewUrl($this->_mailing_id)); |
6a488035 | 129 | |
6ce3caf7 | 130 | return CRM_Core_Page::run(); |
6a488035 | 131 | } |
96025800 | 132 | |
6a488035 | 133 | } |