Merge pull request #4887 from pratikshad/broken-webtest
[civicrm-core.git] / CRM / Mailing / Form / Browse.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2014
33 * $Id$
34 *
35 */
36
37 /**
38 * Build the form object for disable mail feature
39 *
40 * @param
41 *
42 * @return void
43 */
44 class CRM_Mailing_Form_Browse extends CRM_Core_Form {
45
46 /**
47 * Heart of the viewing process. The runner gets all the meta data for
48 * the contact and calls the appropriate type of page to view.
49 *
50 * @return void
51 */
52 public function preProcess() {
53 $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
54 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
55
56 // check for action permissions.
57 if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
58 CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
59 }
60
61 $mailing = new CRM_Mailing_BAO_Mailing();
62 $mailing->id = $this->_mailingId;
63 $subject = '';
64 if ($mailing->find(TRUE)) {
65 $subject = $mailing->subject;
66 }
67 $this->assign('subject', $subject);
68 }
69
70 /**
71 * Build the form object
72 *
73 * @return void
74 */
75
76 public function buildQuickForm() {
77 $this->addButtons(array(
78 array(
79 'type' => 'next',
80 'name' => ts('Confirm'),
81 'isDefault' => TRUE,
82 ),
83 array(
84 'type' => 'cancel',
85 'name' => ts('Cancel'),
86 ),
87 )
88 );
89 }
90
91 /**
92 *
93 * @return void
94 */
95 public function postProcess() {
96 if ($this->_action & CRM_Core_Action::DELETE) {
97 CRM_Mailing_BAO_Mailing::del($this->_mailingId);
98 }
99 elseif ($this->_action & CRM_Core_Action::DISABLE) {
100 CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
101 }
102 elseif ($this->_action & CRM_Core_Action::RENEW) {
103 //set is_archived to 1
104 CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
105 }
106 }
107 }