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', CRM_Core_DAO
::$_nullObject,
47 FALSE, NULL, $_REQUEST
50 $config = CRM_Core_Config
::singleton();
51 CRM_Utils_System
::redirect($config->userFrameworkBaseURL
);
54 $confirm = CRM_Utils_Request
::retrieve('confirm', 'Boolean', CRM_Core_DAO
::$_nullObject,
55 FALSE, NULL, $_REQUEST
58 list($displayName, $email) = CRM_Mailing_Event_BAO_Queue
::getContactInfo($queue_id);
59 $this->assign('display_name', $displayName);
60 $this->assign('email', $email);
61 $this->assign('confirm', $confirm);
63 $groups = CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
64 $this->assign('groups', $groups);
66 foreach ($groups as $key => $value) {
71 $this->assign('groupExist', $groupExist);
74 if ($this->_type
== 'unsubscribe') {
75 $groups = CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_mailing($job_id, $queue_id, $hash);
77 CRM_Mailing_Event_BAO_Unsubscribe
::send_unsub_response($queue_id, $groups, FALSE, $job_id);
80 // should we indicate an error, or just ignore?
83 elseif ($this->_type
== 'resubscribe') {
84 $groups = CRM_Mailing_Event_BAO_Resubscribe
::resub_to_mailing($job_id, $queue_id, $hash);
86 CRM_Mailing_Event_BAO_Resubscribe
::send_resub_response($queue_id, $groups, FALSE, $job_id);
89 // should we indicate an error, or just ignore?
93 if (CRM_Mailing_Event_BAO_Unsubscribe
::unsub_from_domain($job_id, $queue_id, $hash)) {
94 CRM_Mailing_Event_BAO_Unsubscribe
::send_unsub_response($queue_id, NULL, TRUE, $job_id);
97 // should we indicate an error, or just ignore?
102 $confirmURL = CRM_Utils_System
::url("civicrm/mailing/{$this->_type}",
103 "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1"
105 $this->assign('confirmURL', $confirmURL);
106 // push context for further process CRM-4431
107 $session = CRM_Core_Session
::singleton();
108 $session->pushUserContext($confirmURL);
111 return parent
::run();