Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
c490a46a | 35 | * Build the form object for disable mail feature |
6a488035 TO |
36 | */ |
37 | class CRM_Mailing_Form_Browse extends CRM_Core_Form { | |
38 | ||
39 | /** | |
40 | * Heart of the viewing process. The runner gets all the meta data for | |
41 | * the contact and calls the appropriate type of page to view. | |
6a488035 | 42 | */ |
00be9182 | 43 | public function preProcess() { |
6a488035 TO |
44 | $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this); |
45 | $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); | |
46 | ||
47 | // check for action permissions. | |
48 | if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) { | |
0499b0ad | 49 | CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); |
6a488035 TO |
50 | } |
51 | ||
353ffa53 | 52 | $mailing = new CRM_Mailing_BAO_Mailing(); |
6a488035 | 53 | $mailing->id = $this->_mailingId; |
353ffa53 | 54 | $subject = ''; |
6a488035 TO |
55 | if ($mailing->find(TRUE)) { |
56 | $subject = $mailing->subject; | |
57 | } | |
58 | $this->assign('subject', $subject); | |
59 | } | |
60 | ||
61 | /** | |
fe482240 | 62 | * Build the form object. |
6a488035 | 63 | */ |
6a488035 | 64 | public function buildQuickForm() { |
be2fb01f | 65 | $this->addButtons([ |
7e8c8317 SL |
66 | [ |
67 | 'type' => 'next', | |
68 | 'name' => ts('Confirm'), | |
69 | 'isDefault' => TRUE, | |
70 | ], | |
71 | [ | |
72 | 'type' => 'cancel', | |
73 | 'name' => ts('Cancel'), | |
74 | ], | |
75 | ]); | |
6a488035 TO |
76 | } |
77 | ||
6a488035 TO |
78 | public function postProcess() { |
79 | if ($this->_action & CRM_Core_Action::DELETE) { | |
80 | CRM_Mailing_BAO_Mailing::del($this->_mailingId); | |
81 | } | |
82 | elseif ($this->_action & CRM_Core_Action::DISABLE) { | |
9da8dc8c | 83 | CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId); |
67d4ed51 | 84 | CRM_Core_Session::setStatus(ts('The mailing has been canceled.'), ts('Canceled'), 'success'); |
6a488035 TO |
85 | } |
86 | elseif ($this->_action & CRM_Core_Action::RENEW) { | |
87 | //set is_archived to 1 | |
88 | CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE); | |
89 | } | |
90 | } | |
96025800 | 91 | |
6a488035 | 92 | } |