Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Page to display / edit the header / footer of a mailing | |
38 | * | |
39 | */ | |
40 | class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic { | |
41 | public $_mailing_id; | |
42 | ||
43 | /** | |
fe482240 | 44 | * Get BAO Name. |
6a488035 | 45 | * |
a6c01b45 CW |
46 | * @return string |
47 | * Classname of BAO | |
6a488035 | 48 | */ |
00be9182 | 49 | public function getBAOName() { |
6a488035 TO |
50 | return 'CRM_Mailing_BAO_Mailing'; |
51 | } | |
52 | ||
e0ef6999 EM |
53 | /** |
54 | * @return null | |
55 | */ | |
00be9182 | 56 | public function &links() { |
6a488035 TO |
57 | return CRM_Core_DAO::$_nullObject; |
58 | } | |
59 | ||
e0ef6999 EM |
60 | /** |
61 | * @return null | |
62 | */ | |
00be9182 | 63 | public function editForm() { |
6a488035 TO |
64 | return NULL; |
65 | } | |
66 | ||
e0ef6999 EM |
67 | /** |
68 | * @return string | |
69 | */ | |
00be9182 | 70 | public function editName() { |
6a488035 TO |
71 | return 'CiviMail Report'; |
72 | } | |
73 | ||
74 | /** | |
75 | * Get user context. | |
76 | * | |
6c8f6e67 EM |
77 | * @param null $mode |
78 | * | |
a6c01b45 CW |
79 | * @return string |
80 | * user context. | |
6a488035 | 81 | */ |
00be9182 | 82 | public function userContext($mode = NULL) { |
6a488035 TO |
83 | return 'civicrm/mailing/report'; |
84 | } | |
85 | ||
e0ef6999 EM |
86 | /** |
87 | * @param null $mode | |
88 | * | |
89 | * @return string | |
90 | */ | |
00be9182 | 91 | public function userContextParams($mode = NULL) { |
6a488035 TO |
92 | return 'reset=1&mid=' . $this->_mailing_id; |
93 | } | |
94 | ||
e0ef6999 EM |
95 | /** |
96 | * @return string | |
97 | */ | |
00be9182 | 98 | public function run() { |
6a488035 | 99 | $this->_mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this); |
e81bac46 | 100 | //CRM-15979 - check if abtest exist for mailing then redirect accordingly |
101 | $abtest = CRM_Mailing_BAO_MailingAB::getABTest($this->_mailing_id); | |
102 | if (!empty($abtest) && !empty($abtest->id)) { | |
103 | CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id)); | |
104 | } | |
6a488035 TO |
105 | // check that the user has permission to access mailing id |
106 | CRM_Mailing_BAO_Mailing::checkPermission($this->_mailing_id); | |
107 | ||
108 | $report = CRM_Mailing_BAO_Mailing::report($this->_mailing_id); | |
109 | ||
110 | //get contents of mailing | |
111 | CRM_Mailing_BAO_Mailing::getMailingContent($report, $this); | |
112 | ||
113 | //assign backurl | |
114 | $context = CRM_Utils_Request::retrieve('context', 'String', $this); | |
115 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); | |
116 | ||
117 | if ($context == 'activitySelector') { | |
118 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); | |
119 | $backUrlTitle = ts('Back to Activities'); | |
120 | } | |
121 | elseif ($context == 'activity') { | |
122 | $atype = CRM_Utils_Request::retrieve('atype', 'Positive', $this); | |
123 | $aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); | |
124 | ||
125 | $backUrl = CRM_Utils_System::url('civicrm/activity/view', | |
126 | "atype={$atype}&action=view&reset=1&id={$aid}&cid={$cid}&context=activity" | |
127 | ); | |
128 | $backUrlTitle = ts('Back to Activity'); | |
129 | } | |
b99698e5 KJ |
130 | elseif ($context == 'mailing') { |
131 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing"); | |
132 | $backUrlTitle = ts('Back to Mailing'); | |
133 | } | |
6a488035 TO |
134 | else { |
135 | $backUrl = CRM_Utils_System::url('civicrm/mailing', 'reset=1'); | |
136 | $backUrlTitle = ts('Back to CiviMail'); | |
137 | } | |
138 | $this->assign('backUrl', $backUrl); | |
139 | $this->assign('backUrlTitle', $backUrlTitle); | |
140 | ||
141 | $this->assign('report', $report); | |
142 | CRM_Utils_System::setTitle(ts('CiviMail Report: %1', | |
353ffa53 TO |
143 | array(1 => $report['mailing']['name']) |
144 | )); | |
6a488035 | 145 | |
6ce3caf7 | 146 | return CRM_Core_Page::run(); |
6a488035 | 147 | } |
96025800 | 148 | |
6a488035 | 149 | } |