Created
May 4, 2012 02:46
-
-
Save vitorpacheco/2591560 to your computer and use it in GitHub Desktop.
beforeDelete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function beforeDelete($cascade = true) { | |
| if (in_array($this->id, array(self::GRUPO_ADMIN, self::GRUPO_PUBLICO))) { | |
| return false; | |
| } | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function admin_delete($id = null) { | |
| $this->set('title_for_layout', __('Excluir Grupo')); | |
| if (!$this->request->is('post')) { | |
| throw new MethodNotAllowedException(); | |
| } | |
| $this->Grupo->id = $id; | |
| if (!$this->Grupo->exists()) { | |
| throw new NotFoundException(__('Grupo inválido')); | |
| } | |
| if ($this->Grupo->delete()) { | |
| $this->Session->setFlash(__('Grupo excluído'), 'flash_success'); | |
| $this->redirect(array('action' => 'index')); | |
| } | |
| $this->Session->setFlash(__('O grupo não foi excluído'), 'flash_failure'); | |
| $this->redirect(array('action' => 'index')); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment