quickfix for crash if civigrant not enabled and have admin rights
[civicrm-core.git] / CRM / Mailing / Page / Event.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This implements the profile page for all contacts.
20 *
21 * It uses a selector object to do the actual display. The fields displayed are controlled by
22 * the admin
23 */
24 class CRM_Mailing_Page_Event extends CRM_Core_Page {
25
26 /**
27 * All the fields that are listings related.
28 *
29 * @var array
30 */
31 protected $_fields;
32
33 /**
34 * Run this page (figure out the action needed and perform it).
35 */
36 public function run() {
37 $selector = new CRM_Mailing_Selector_Event(
38 CRM_Utils_Request::retrieve('event', 'String', $this),
39 CRM_Utils_Request::retrieve('distinct', 'Boolean', $this),
40 CRM_Utils_Request::retrieve('mid', 'Positive', $this),
41 CRM_Utils_Request::retrieve('jid', 'Positive', $this),
42 CRM_Utils_Request::retrieve('uid', 'Positive', $this)
43 );
44
45 $mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
46
47 // check that the user has permission to access mailing id
48 CRM_Mailing_BAO_Mailing::checkPermission($mailing_id);
49
50 $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
51
52 if ($context == 'activitySelector') {
53 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
54 $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
55 $backUrlTitle = ts('Back to Activities');
56 }
57 elseif ($context == 'mailing') {
58 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
59 $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
60 $backUrlTitle = ts('Back to Mailing');
61 }
62 elseif ($context == 'angPage') {
63 $angPage = CRM_Utils_Request::retrieve('angPage', 'String', $this);
64 if (!preg_match(':^[a-zA-Z0-9\-_/]+$:', $angPage)) {
65 throw new CRM_Core_Exception('Malformed return URL');
66 }
67 $backUrl = CRM_Utils_System::url('civicrm/a/#/' . $angPage);
68 $backUrlTitle = ts('Back to Report');
69 }
70 else {
71 $backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}");
72 $backUrlTitle = ts('Back to Report');
73 }
74
75 $this->assign('backUrl', $backUrl);
76 $this->assign('backUrlTitle', $backUrlTitle);
77
78 CRM_Utils_System::setTitle($selector->getTitle());
79 $this->assign('title', $selector->getTitle());
80 $this->assign('mailing_id', $mailing_id);
81
82 $sortID = NULL;
83 if ($this->get(CRM_Utils_Sort::SORT_ID)) {
84 $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
85 $this->get(CRM_Utils_Sort::SORT_DIRECTION)
86 );
87 }
88
89 $controller = new CRM_Core_Selector_Controller(
90 $selector,
91 $this->get(CRM_Utils_Pager::PAGE_ID),
92 $sortID,
93 CRM_Core_Action::VIEW,
94 $this,
95 CRM_Core_Selector_Controller::TEMPLATE
96 );
97
98 $controller->setEmbedded(TRUE);
99 $controller->run();
100
101 return parent::run();
102 }
103
104 }