Merge pull request #7258 from yashodha/CRM-15306
[civicrm-core.git] / CRM / Mailing / Page / Event.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
7e9e8871 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035
TO
32 */
33
34/**
bf8648e1 35 * This implements the profile page for all contacts.
36 *
37 * It uses a selector object to do the actual display. The fields displayed are controlled by
6a488035
TO
38 * the admin
39 */
40class CRM_Mailing_Page_Event extends CRM_Core_Page {
41
42 /**
fe482240 43 * All the fields that are listings related.
6a488035
TO
44 *
45 * @var array
6a488035
TO
46 */
47 protected $_fields;
48
49 /**
100fef9d 50 * Run this page (figure out the action needed and perform it).
6a488035 51 */
00be9182 52 public function run() {
bf8648e1 53 $selector = new CRM_Mailing_Selector_Event(
6a488035
TO
54 CRM_Utils_Request::retrieve('event', 'String', $this),
55 CRM_Utils_Request::retrieve('distinct', 'Boolean', $this),
56 CRM_Utils_Request::retrieve('mid', 'Positive', $this),
57 CRM_Utils_Request::retrieve('jid', 'Positive', $this),
58 CRM_Utils_Request::retrieve('uid', 'Positive', $this)
59 );
60
61 $mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
62
01c22255
KJ
63 $context = CRM_Utils_Request::retrieve('context', 'String', $this);
64
5a99d240
KJ
65 if ($context == 'activitySelector') {
66 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
67 $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
68 $backUrlTitle = ts('Back to Activities');
69 }
70 elseif ($context == 'mailing') {
01c22255
KJ
71 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
72 $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
73 $backUrlTitle = ts('Back to Mailing');
74 }
05381a97
TO
75 elseif ($context == 'angPage') {
76 $angPage = CRM_Utils_Request::retrieve('angPage', 'String', $this);
77 if (!preg_match(':^[a-zA-Z0-9\-_/]+$:', $angPage)) {
78 CRM_Core_Error::fatal('Malformed return URL');
79 }
80 $backUrl = CRM_Utils_System::url('civicrm/a/#/' . $angPage);
81 $backUrlTitle = ts('Back to Report');
82 }
01c22255 83 else {
9afae995 84 $backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}");
01c22255
KJ
85 $backUrlTitle = ts('Back to Report');
86 }
87
88 $this->assign('backUrl', $backUrl);
89 $this->assign('backUrlTitle', $backUrlTitle);
90
6a488035
TO
91 CRM_Utils_System::setTitle($selector->getTitle());
92 $this->assign('title', $selector->getTitle());
93 $this->assign('mailing_id', $mailing_id);
94
95 $sortID = NULL;
96 if ($this->get(CRM_Utils_Sort::SORT_ID)) {
97 $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
98 $this->get(CRM_Utils_Sort::SORT_DIRECTION)
99 );
100 }
101
102 $controller = new CRM_Core_Selector_Controller(
103 $selector,
104 $this->get(CRM_Utils_Pager::PAGE_ID),
105 $sortID,
106 CRM_Core_Action::VIEW,
107 $this,
108 CRM_Core_Selector_Controller::TEMPLATE
109 );
110
111 $controller->setEmbedded(TRUE);
112 $controller->run();
113
114 return parent::run();
115 }
96025800 116
6a488035 117}