Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
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 | /** | |
44 | * Get BAO Name | |
45 | * | |
46 | * @return string Classname of BAO | |
47 | */ | |
48 | function getBAOName() { | |
49 | return 'CRM_Mailing_BAO_Mailing'; | |
50 | } | |
51 | ||
e0ef6999 EM |
52 | /** |
53 | * @return null | |
54 | */ | |
6a488035 TO |
55 | function &links() { |
56 | return CRM_Core_DAO::$_nullObject; | |
57 | } | |
58 | ||
e0ef6999 EM |
59 | /** |
60 | * @return null | |
61 | */ | |
6a488035 TO |
62 | function editForm() { |
63 | return NULL; | |
64 | } | |
65 | ||
e0ef6999 EM |
66 | /** |
67 | * @return string | |
68 | */ | |
6a488035 TO |
69 | function editName() { |
70 | return 'CiviMail Report'; | |
71 | } | |
72 | ||
73 | /** | |
74 | * Get user context. | |
75 | * | |
6c8f6e67 EM |
76 | * @param null $mode |
77 | * | |
6a488035 TO |
78 | * @return string user context. |
79 | */ | |
80 | function userContext($mode = NULL) { | |
81 | return 'civicrm/mailing/report'; | |
82 | } | |
83 | ||
e0ef6999 EM |
84 | /** |
85 | * @param null $mode | |
86 | * | |
87 | * @return string | |
88 | */ | |
6a488035 TO |
89 | function userContextParams($mode = NULL) { |
90 | return 'reset=1&mid=' . $this->_mailing_id; | |
91 | } | |
92 | ||
e0ef6999 EM |
93 | /** |
94 | * @return string | |
95 | */ | |
6a488035 TO |
96 | function run() { |
97 | $this->_mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this); | |
98 | ||
99 | // check that the user has permission to access mailing id | |
100 | CRM_Mailing_BAO_Mailing::checkPermission($this->_mailing_id); | |
101 | ||
102 | $report = CRM_Mailing_BAO_Mailing::report($this->_mailing_id); | |
103 | ||
104 | //get contents of mailing | |
105 | CRM_Mailing_BAO_Mailing::getMailingContent($report, $this); | |
106 | ||
107 | //assign backurl | |
108 | $context = CRM_Utils_Request::retrieve('context', 'String', $this); | |
109 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); | |
110 | ||
111 | if ($context == 'activitySelector') { | |
112 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); | |
113 | $backUrlTitle = ts('Back to Activities'); | |
114 | } | |
115 | elseif ($context == 'activity') { | |
116 | $atype = CRM_Utils_Request::retrieve('atype', 'Positive', $this); | |
117 | $aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); | |
118 | ||
119 | $backUrl = CRM_Utils_System::url('civicrm/activity/view', | |
120 | "atype={$atype}&action=view&reset=1&id={$aid}&cid={$cid}&context=activity" | |
121 | ); | |
122 | $backUrlTitle = ts('Back to Activity'); | |
123 | } | |
b99698e5 KJ |
124 | elseif ($context == 'mailing') { |
125 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing"); | |
126 | $backUrlTitle = ts('Back to Mailing'); | |
127 | } | |
6a488035 TO |
128 | else { |
129 | $backUrl = CRM_Utils_System::url('civicrm/mailing', 'reset=1'); | |
130 | $backUrlTitle = ts('Back to CiviMail'); | |
131 | } | |
132 | $this->assign('backUrl', $backUrl); | |
133 | $this->assign('backUrlTitle', $backUrlTitle); | |
134 | ||
135 | $this->assign('report', $report); | |
136 | CRM_Utils_System::setTitle(ts('CiviMail Report: %1', | |
137 | array(1 => $report['mailing']['name']) | |
138 | )); | |
139 | ||
6ce3caf7 | 140 | return CRM_Core_Page::run(); |
6a488035 TO |
141 | } |
142 | } | |
143 |