Merge branch '4.5' into master
[civicrm-core.git] / CRM / Mailing / Form / Browse.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 *
34 */
35
36 /**
37 * Build the form object for disable mail feature
38 *
39 * @param
40 *
41 * @return void
42 */
43 class 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
50 */
51 public function preProcess() {
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)) {
57 CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
58 }
59
60 $mailing = new CRM_Mailing_BAO_Mailing();
61 $mailing->id = $this->_mailingId;
62 $subject = '';
63 if ($mailing->find(TRUE)) {
64 $subject = $mailing->subject;
65 }
66 $this->assign('subject', $subject);
67 }
68
69 /**
70 * Build the form object
71 *
72 * @return void
73 */
74
75 public function buildQuickForm() {
76 $this->addButtons(array(
77 array(
78 'type' => 'next',
79 'name' => ts('Confirm'),
80 'isDefault' => TRUE,
81 ),
82 array(
83 'type' => 'cancel',
84 'name' => ts('Cancel'),
85 ),
86 )
87 );
88 }
89
90 /**
91 *
92 * @return void
93 */
94 public function postProcess() {
95 if ($this->_action & CRM_Core_Action::DELETE) {
96 CRM_Mailing_BAO_Mailing::del($this->_mailingId);
97 }
98 elseif ($this->_action & CRM_Core_Action::DISABLE) {
99 CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
100 }
101 elseif ($this->_action & CRM_Core_Action::RENEW) {
102 //set is_archived to 1
103 CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
104 }
105 }
106 }