3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class is to build the form for deleting a Survey.
21 class CRM_Campaign_Form_Survey_Delete
extends CRM_Core_Form
{
24 * The id of the object being deleted
35 protected $_surveyTitle;
38 * Set variables up before form is built.
40 public function preProcess() {
41 if (!CRM_Campaign_BAO_Campaign
::accessCampaign()) {
42 CRM_Utils_System
::permissionDenied();
45 $this->_surveyId
= CRM_Utils_Request
::retrieve('id', 'Positive', $this, FALSE);
46 $params = ['id' => $this->_surveyId
];
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
);
54 * Build the form object.
56 public function buildQuickForm() {
60 'name' => ts('Delete'),
65 'name' => ts('Cancel'),
71 * Process the form when submitted.
73 public function postProcess() {
74 if ($this->_surveyId
) {
75 CRM_Campaign_BAO_Survey
::del($this->_surveyId
);
76 CRM_Core_Session
::setStatus('', ts("'%1' survey has been deleted.", [1 => $this->_surveyTitle
]), 'success');
77 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/campaign', 'reset=1&subPage=survey'));
80 CRM_Core_Error
::statusBounce(ts('Delete action is missing expected survey ID.'));