Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
3819f101 | 19 | * This class is to build the form for deleting a Survey. |
6a488035 TO |
20 | */ |
21 | class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form { | |
22 | ||
23 | /** | |
24 | * The id of the object being deleted | |
25 | * | |
26 | * @var int | |
27 | */ | |
28 | protected $_surveyId; | |
29 | ||
30 | /** | |
100fef9d | 31 | * SurveyTitle |
6a488035 TO |
32 | * |
33 | * @var string | |
34 | */ | |
35 | protected $_surveyTitle; | |
36 | ||
6a488035 | 37 | /** |
fe482240 | 38 | * Set variables up before form is built. |
6a488035 TO |
39 | */ |
40 | public function preProcess() { | |
41 | if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { | |
42 | CRM_Utils_System::permissionDenied(); | |
43 | } | |
44 | ||
45 | $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); | |
be2fb01f | 46 | $params = ['id' => $this->_surveyId]; |
6a488035 TO |
47 | CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo); |
48 | $this->_surveyTitle = $surveyInfo['title']; | |
49 | $this->assign('surveyTitle', $this->_surveyTitle); | |
50 | CRM_Utils_System::setTitle(ts('Delete Survey') . ' - ' . $this->_surveyTitle); | |
51 | } | |
52 | ||
53 | /** | |
fe482240 | 54 | * Build the form object. |
6a488035 TO |
55 | */ |
56 | public function buildQuickForm() { | |
be2fb01f | 57 | $this->addButtons([ |
5d4fcf54 TO |
58 | [ |
59 | 'type' => 'next', | |
60 | 'name' => ts('Delete'), | |
61 | 'isDefault' => TRUE, | |
62 | ], | |
63 | [ | |
64 | 'type' => 'cancel', | |
65 | 'name' => ts('Cancel'), | |
66 | ], | |
67 | ]); | |
6a488035 TO |
68 | } |
69 | ||
70 | /** | |
fe482240 | 71 | * Process the form when submitted. |
6a488035 TO |
72 | */ |
73 | public function postProcess() { | |
74 | if ($this->_surveyId) { | |
75 | CRM_Campaign_BAO_Survey::del($this->_surveyId); | |
be2fb01f | 76 | CRM_Core_Session::setStatus('', ts("'%1' survey has been deleted.", [1 => $this->_surveyTitle]), 'success'); |
6a488035 | 77 | CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey')); |
0db6c3e1 TO |
78 | } |
79 | else { | |
8ef12e64 | 80 | CRM_Core_Error::fatal(ts('Delete action is missing expected survey ID.')); |
6a488035 TO |
81 | } |
82 | } | |
96025800 | 83 | |
6a488035 | 84 | } |