Skip to content

Instantly share code, notes, and snippets.

@vitorpacheco
Created May 4, 2012 02:46
Show Gist options
  • Select an option

  • Save vitorpacheco/2591560 to your computer and use it in GitHub Desktop.

Select an option

Save vitorpacheco/2591560 to your computer and use it in GitHub Desktop.
beforeDelete
public function beforeDelete($cascade = true) {
if (in_array($this->id, array(self::GRUPO_ADMIN, self::GRUPO_PUBLICO))) {
return false;
}
return true;
}
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