Skip to content

Instantly share code, notes, and snippets.

@sergiopvilar
Created September 26, 2011 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiopvilar/1243239 to your computer and use it in GitHub Desktop.
Save sergiopvilar/1243239 to your computer and use it in GitHub Desktop.
function admin_delete($id = null){
$pub = $this->Publicacao->read(null,$id);
if($pub['Publicacao']['usuario_id']==$this->Auth->user('id')):
$this->Publicacao->set(array(
'id' => $id,
'state' => '0'
));
$this->Publicacao->save($this->data);
$this->Publicacao->deleteAll(array('Publicacao.parent' => $id));
$this->Session->setFlash('A Publicação foi excluída com sucesso.','flash_info');
debug('oi');
else:
$this->Session->setFlash('Ops! Você não tem permissão para excluir essa publicação.','flash_error');
endif;
$this->redirect(array('action' => 'index'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment