BaseEventTypeController::actionRequestDeletion PHP Method

actionRequestDeletion() public method

Action to process delete requests for an event.
public actionRequestDeletion ( $id ) : boolean | void
$id
return boolean | void
    public function actionRequestDeletion($id)
    {
        if (!($this->event = Event::model()->findByPk($id))) {
            throw new CHttpException(403, 'Invalid event id.');
        }
        if (isset($_POST['et_canceldelete'])) {
            return $this->redirect(array('/' . $this->event->eventType->class_name . '/default/view/' . $id));
        }
        $this->patient = $this->event->episode->patient;
        $errors = array();
        if (!empty($_POST)) {
            if (!@$_POST['delete_reason']) {
                $errors = array('Reason' => array('Please enter a reason for deleting this event'));
            } else {
                $this->event->requestDeletion($_POST['delete_reason']);
                if (Yii::app()->params['admin_email']) {
                    mail(Yii::app()->params['admin_email'], 'Request to delete an event', 'A request to delete an event has been submitted.  Please log in to the admin system to review the request.', 'From: OpenEyes');
                }
                Yii::app()->user->setFlash('success', 'Your request to delete this event has been submitted.');
                header('Location: ' . Yii::app()->createUrl('/' . $this->event_type->class_name . '/default/view/' . $this->event->id));
                return true;
            }
        }
        $this->title = 'Delete ' . $this->event_type->name;
        $this->event_tabs = array(array('label' => 'View', 'active' => true));
        $this->render('request_delete', array('errors' => $errors));
    }
BaseEventTypeController