Merge pull request #4607 from samuelsov/CRM-15637
[civicrm-core.git] / CRM / Mailing / Page / Event.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2014
33 * $Id$
34 *
35 */
36
37 /**
38 * This implements the profile page for all contacts. It uses a selector
39 * object to do the actual dispay. The fields displayd are controlled by
40 * the admin
41 */
42 class CRM_Mailing_Page_Event extends CRM_Core_Page {
43
44 /**
45 * All the fields that are listings related
46 *
47 * @var array
48 */
49 protected $_fields;
50
51 /**
52 * Run this page (figure out the action needed and perform it).
53 *
54 * @return void
55 */
56 public function run() {
57 $selector = &new CRM_Mailing_Selector_Event(
58 CRM_Utils_Request::retrieve('event', 'String', $this),
59 CRM_Utils_Request::retrieve('distinct', 'Boolean', $this),
60 CRM_Utils_Request::retrieve('mid', 'Positive', $this),
61 CRM_Utils_Request::retrieve('jid', 'Positive', $this),
62 CRM_Utils_Request::retrieve('uid', 'Positive', $this)
63 );
64
65 $mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
66
67 //assign backurl
68 $context = CRM_Utils_Request::retrieve('context', 'String', $this);
69
70 if ($context == 'activitySelector') {
71 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
72 $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
73 $backUrlTitle = ts('Back to Activities');
74 }
75 elseif ($context == 'mailing') {
76 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
77 $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
78 $backUrlTitle = ts('Back to Mailing');
79 }
80 else {
81 $backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}");
82 $backUrlTitle = ts('Back to Report');
83 }
84
85 $this->assign('backUrl', $backUrl);
86 $this->assign('backUrlTitle', $backUrlTitle);
87
88 CRM_Utils_System::setTitle($selector->getTitle());
89 $this->assign('title', $selector->getTitle());
90 $this->assign('mailing_id', $mailing_id);
91
92 $sortID = NULL;
93 if ($this->get(CRM_Utils_Sort::SORT_ID)) {
94 $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
95 $this->get(CRM_Utils_Sort::SORT_DIRECTION)
96 );
97 }
98
99 $controller = new CRM_Core_Selector_Controller(
100 $selector,
101 $this->get(CRM_Utils_Pager::PAGE_ID),
102 $sortID,
103 CRM_Core_Action::VIEW,
104 $this,
105 CRM_Core_Selector_Controller::TEMPLATE
106 );
107
108 $controller->setEmbedded(TRUE);
109 $controller->run();
110
111 return parent::run();
112 }
113 }