public function deletarEventoAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $id_evento = $this->_getParam('evento', 0); $model_pessoa = new Application_Model_Pessoa(); $model_evento = new Application_Model_Evento(); try { if ($id_evento < 1) { throw new Exception("Parâmetros inválidos. Tente novamente do início ou contate o administrador."); } $this->autenticacao(); $sessao = Zend_Auth::getInstance()->getIdentity(); $id_pessoa_sessao = $sessao["idPessoa"]; $id_pessoa_db = $model_evento->getResponsavel($id_evento); if ($id_pessoa_db != $id_pessoa_sessao && !$model_pessoa->isAdmin()) { throw new Exception("Você não é administrador para executar esta ação."); } $model_evento->deletarEvento($id_evento); $this->_helper->flashMessenger->addMessage(array('success' => 'Evento removido com sucesso.')); } catch (Zend_Db_Exception $ex) { if ($ex->getCode() == 23503) { $this->_helper->flashMessenger->addMessage(array('info' => _("This event could not be deleted."))); } else { $this->_helper->flashMessenger->addMessage(array('danger' => _('An unexpected error ocurred.<br/> Details: ') . $ex->getMessage())); } } $this->_helper->redirector->goToRoute(array('controller' => 'evento', 'action' => 'index'), 'default', true); }