3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Mailing_Page_Common
extends CRM_Core_Page
{
18 protected $_type = NULL;
23 * This includes assigning smarty variables and other page processing.
28 public function run() {
29 $job_id = CRM_Utils_Request
::retrieve('jid', 'Integer');
30 $queue_id = CRM_Utils_Request
::retrieve('qid', 'Integer');
31 $hash = CRM_Utils_Request
::retrieve('h', 'String');
37 throw new CRM_Core_Exception(ts("Missing input parameters"));
40 // verify that the three numbers above match
41 $q = CRM_Mailing_Event_BAO_Queue
::verify($job_id, $queue_id, $hash);
43 throw new CRM_Core_Exception(ts("There was an error in your request"));
46 $cancel = CRM_Utils_Request
::retrieve("_qf_{$this->_type}_cancel", 'String');
48 $config = CRM_Core_Config
::singleton();
49 CRM_Utils_System
::redirect($config->userFrameworkBaseURL
);
52 $confirm = CRM_Utils_Request
::retrieve('confirm', 'Boolean');
54 list($displayName, $email) = CRM_Mailing_Event_BAO_Queue
::getContactInfo($queue_id);
55 $this->assign('display_name', $displayName);
56 $this->assign('email', $email);
57 $this->assign('confirm', $confirm);
59 $groups = CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
60 $this->assign('groups', $groups);
62 foreach ($groups as $key => $value) {
67 $this->assign('groupExist', $groupExist);
70 if ($this->_type
== 'unsubscribe') {
71 $groups = CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_mailing($job_id, $queue_id, $hash);
73 CRM_Mailing_Event_BAO_Unsubscribe
::send_unsub_response($queue_id, $groups, FALSE, $job_id);
76 // should we indicate an error, or just ignore?
79 elseif ($this->_type
== 'resubscribe') {
80 $groups = CRM_Mailing_Event_BAO_Resubscribe
::resub_to_mailing($job_id, $queue_id, $hash);
82 CRM_Mailing_Event_BAO_Resubscribe
::send_resub_response($queue_id, $groups, $job_id);
85 // should we indicate an error, or just ignore?
89 if (CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_domain($job_id, $queue_id, $hash)) {
90 CRM_Mailing_Event_BAO_Unsubscribe
::send_unsub_response($queue_id, NULL, TRUE, $job_id);
93 // should we indicate an error, or just ignore?
98 $confirmURL = CRM_Utils_System
::url("civicrm/mailing/{$this->_type}",
99 "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1"
101 $this->assign('confirmURL', $confirmURL);
102 // push context for further process CRM-4431
103 $session = CRM_Core_Session
::singleton();
104 $session->pushUserContext($confirmURL);
107 return parent
::run();