3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * This class is to build the form for Deleting Group
39 class CRM_Event_Form_ManageEvent_Delete
extends CRM_Event_Form_ManageEvent
{
50 * Function to set variables up before form is built
55 public function preProcess() {
58 if ($this->_isTemplate
) {
59 $this->_title
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $this->_id
, 'template_title');
62 $this->_title
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $this->_id
, 'title');
65 if (!CRM_Event_BAO_Event
::checkPermission($this->_id
, CRM_Core_Permission
::DELETE
)) {
66 CRM_Core_Error
::fatal(ts('You do not have permission to access this page'));
71 * Function to actually build the form
76 public function buildQuickForm() {
77 $this->assign('title', $this->_title
);
82 'name' => $this->_isTemplate ?
ts('Delete Event Template') : ts('Delete Event'),
87 'name' => ts('Cancel'),
90 $this->addButtons($buttons);
94 * Process the form when submitted
99 public function postProcess() {
100 $participant = new CRM_Event_DAO_Participant();
101 $participant->event_id
= $this->_id
;
103 if ($participant->find()) {
104 $searchURL = CRM_Utils_System
::url('civicrm/event/search', 'reset=1');
105 CRM_Core_Session
::setStatus(ts('This event cannot be deleted because there are participant records linked to it. If you want to delete this event, you must first find the participants linked to this event and delete them. You can use use <a href=\'%1\'> CiviEvent >> Find Participants page </a>.',
106 array(1 => $searchURL)
107 ), ts('Deletion Error'), 'error');
110 CRM_Event_BAO_Event
::del($this->_id
);
111 if ($this->_isTemplate
) {
112 CRM_Core_Session
::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title
)), ts('Template Deleted'), 'success');
113 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/admin/eventTemplate', 'reset=1'));
116 CRM_Core_Session
::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title
)), ts('Event Deleted'), 'success');