| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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-2015 |
| 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 | 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 | /** |
| 90 | * |
| 91 | * @return void |
| 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) { |
| 98 | CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId); |
| 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 | } |
| 105 | |
| 106 | } |