Merge pull request #15821 from seamuslee001/dev_core_183_custom_group
[civicrm-core.git] / CRM / Mailing / Form / Browse.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Build the form object for disable mail feature
20 */
21 class 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.
26 */
27 public function preProcess() {
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)) {
33 CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
34 }
35
36 $mailing = new CRM_Mailing_BAO_Mailing();
37 $mailing->id = $this->_mailingId;
38 $subject = '';
39 if ($mailing->find(TRUE)) {
40 $subject = $mailing->subject;
41 }
42 $this->assign('subject', $subject);
43 }
44
45 /**
46 * Build the form object.
47 */
48 public function buildQuickForm() {
49 $this->addButtons([
50 [
51 'type' => 'next',
52 'name' => ts('Confirm'),
53 'isDefault' => TRUE,
54 ],
55 [
56 'type' => 'cancel',
57 'name' => ts('Cancel'),
58 ],
59 ]);
60 }
61
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) {
67 CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
68 CRM_Core_Session::setStatus(ts('The mailing has been canceled.'), ts('Canceled'), 'success');
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 }
75
76 }