Merge pull request #6460 from yashodha/CRM-16943
[civicrm-core.git] / CRM / Mailing / Form / Browse.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035
TO
32 * $Id$
33 *
34 */
35
36/**
c490a46a 37 * Build the form object for disable mail feature
6a488035
TO
38 *
39 * @param
40 *
41 * @return void
6a488035
TO
42 */
43class CRM_Mailing_Form_Browse extends CRM_Core_Form {
44
45 /**
46 * Heart of the viewing process. The runner gets all the meta data for
47 * the contact and calls the appropriate type of page to view.
48 *
49 * @return void
6a488035 50 */
00be9182 51 public function preProcess() {
6a488035
TO
52 $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
53 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
54
55 // check for action permissions.
56 if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
0499b0ad 57 CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
6a488035
TO
58 }
59
353ffa53 60 $mailing = new CRM_Mailing_BAO_Mailing();
6a488035 61 $mailing->id = $this->_mailingId;
353ffa53 62 $subject = '';
6a488035
TO
63 if ($mailing->find(TRUE)) {
64 $subject = $mailing->subject;
65 }
66 $this->assign('subject', $subject);
67 }
68
69 /**
fe482240 70 * Build the form object.
6a488035 71 *
355ba699 72 * @return void
6a488035 73 */
6a488035
TO
74 public function buildQuickForm() {
75 $this->addButtons(array(
76 array(
77 'type' => 'next',
78 'name' => ts('Confirm'),
79 'isDefault' => TRUE,
80 ),
81 array(
82 'type' => 'cancel',
83 'name' => ts('Cancel'),
84 ),
85 )
86 );
87 }
88
89 /**
6a488035 90 *
355ba699 91 * @return void
6a488035
TO
92 */
93 public function postProcess() {
94 if ($this->_action & CRM_Core_Action::DELETE) {
95 CRM_Mailing_BAO_Mailing::del($this->_mailingId);
96 }
97 elseif ($this->_action & CRM_Core_Action::DISABLE) {
9da8dc8c 98 CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
6a488035
TO
99 }
100 elseif ($this->_action & CRM_Core_Action::RENEW) {
101 //set is_archived to 1
102 CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
103 }
104 }
96025800 105
6a488035 106}