| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 5 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
| 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 |
| 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
| 32 | */ |
| 33 | |
| 34 | /** |
| 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 |
| 38 | * the admin |
| 39 | */ |
| 40 | class CRM_Mailing_Page_Event extends CRM_Core_Page { |
| 41 | |
| 42 | /** |
| 43 | * All the fields that are listings related. |
| 44 | * |
| 45 | * @var array |
| 46 | */ |
| 47 | protected $_fields; |
| 48 | |
| 49 | /** |
| 50 | * Run this page (figure out the action needed and perform it). |
| 51 | */ |
| 52 | public function run() { |
| 53 | $selector = new CRM_Mailing_Selector_Event( |
| 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 | |
| 63 | // check that the user has permission to access mailing id |
| 64 | CRM_Mailing_BAO_Mailing::checkPermission($mailing_id); |
| 65 | |
| 66 | $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); |
| 67 | |
| 68 | if ($context == 'activitySelector') { |
| 69 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); |
| 70 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); |
| 71 | $backUrlTitle = ts('Back to Activities'); |
| 72 | } |
| 73 | elseif ($context == 'mailing') { |
| 74 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); |
| 75 | $backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing"); |
| 76 | $backUrlTitle = ts('Back to Mailing'); |
| 77 | } |
| 78 | elseif ($context == 'angPage') { |
| 79 | $angPage = CRM_Utils_Request::retrieve('angPage', 'String', $this); |
| 80 | if (!preg_match(':^[a-zA-Z0-9\-_/]+$:', $angPage)) { |
| 81 | CRM_Core_Error::fatal('Malformed return URL'); |
| 82 | } |
| 83 | $backUrl = CRM_Utils_System::url('civicrm/a/#/' . $angPage); |
| 84 | $backUrlTitle = ts('Back to Report'); |
| 85 | } |
| 86 | else { |
| 87 | $backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}"); |
| 88 | $backUrlTitle = ts('Back to Report'); |
| 89 | } |
| 90 | |
| 91 | $this->assign('backUrl', $backUrl); |
| 92 | $this->assign('backUrlTitle', $backUrlTitle); |
| 93 | |
| 94 | CRM_Utils_System::setTitle($selector->getTitle()); |
| 95 | $this->assign('title', $selector->getTitle()); |
| 96 | $this->assign('mailing_id', $mailing_id); |
| 97 | |
| 98 | $sortID = NULL; |
| 99 | if ($this->get(CRM_Utils_Sort::SORT_ID)) { |
| 100 | $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), |
| 101 | $this->get(CRM_Utils_Sort::SORT_DIRECTION) |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | $controller = new CRM_Core_Selector_Controller( |
| 106 | $selector, |
| 107 | $this->get(CRM_Utils_Pager::PAGE_ID), |
| 108 | $sortID, |
| 109 | CRM_Core_Action::VIEW, |
| 110 | $this, |
| 111 | CRM_Core_Selector_Controller::TEMPLATE |
| 112 | ); |
| 113 | |
| 114 | $controller->setEmbedded(TRUE); |
| 115 | $controller->run(); |
| 116 | |
| 117 | return parent::run(); |
| 118 | } |
| 119 | |
| 120 | } |