Merge pull request #15933 from civicrm/5.20
[civicrm-core.git] / CRM / Mailing / Form / Browse.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
c490a46a 19 * Build the form object for disable mail feature
6a488035
TO
20 */
21class CRM_Mailing_Form_Browse extends CRM_Core_Form {
22
23 /**
24 * Heart of the viewing process. The runner gets all the meta data for
25 * the contact and calls the appropriate type of page to view.
6a488035 26 */
00be9182 27 public function preProcess() {
6a488035
TO
28 $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
29 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
30
31 // check for action permissions.
32 if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
2a7b8221 33 CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
6a488035
TO
34 }
35
353ffa53 36 $mailing = new CRM_Mailing_BAO_Mailing();
6a488035 37 $mailing->id = $this->_mailingId;
353ffa53 38 $subject = '';
6a488035
TO
39 if ($mailing->find(TRUE)) {
40 $subject = $mailing->subject;
41 }
42 $this->assign('subject', $subject);
43 }
44
45 /**
fe482240 46 * Build the form object.
6a488035 47 */
6a488035 48 public function buildQuickForm() {
be2fb01f 49 $this->addButtons([
7e8c8317
SL
50 [
51 'type' => 'next',
52 'name' => ts('Confirm'),
53 'isDefault' => TRUE,
54 ],
55 [
56 'type' => 'cancel',
57 'name' => ts('Cancel'),
58 ],
59 ]);
6a488035
TO
60 }
61
6a488035
TO
62 public function postProcess() {
63 if ($this->_action & CRM_Core_Action::DELETE) {
64 CRM_Mailing_BAO_Mailing::del($this->_mailingId);
65 }
66 elseif ($this->_action & CRM_Core_Action::DISABLE) {
9da8dc8c 67 CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
67d4ed51 68 CRM_Core_Session::setStatus(ts('The mailing has been canceled.'), ts('Canceled'), 'success');
6a488035
TO
69 }
70 elseif ($this->_action & CRM_Core_Action::RENEW) {
71 //set is_archived to 1
72 CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
73 }
74 }
96025800 75
6a488035 76}