public function actionDelete($albumId) { if ($this->albums->delete()->where($albumId) == 1) { $this->flashSuccess = 'Album has been deleted.'; } $this->redirectTo('/albums/'); }
function deleteAction() { $id = $this->_request->getParam('id', 0); $albums = new Albums(); if ($this->_request->isPost()) { $del = $this->_request->getPost('confirm'); $return_to = $this->_request->getParam('return_to', 0); if (strcmp($del, 'Confirm') == 0 && $id > 0) { $albums->delete('id=' . $id); } elseif (!strcmp($return_to, 'view')) { $this->_redirect('/album/view/id/' . $id); return; } $this->_redirect('/album/list'); } elseif ($id > 0) { $this->view->title = 'Confirm Deletion'; $album = $albums->fetchRow('id=' . $id); $this->view->album_title = $album->title; $form = new AlbumDeleteForm(); $in_return_to = $this->_request->getParam('return_to', 0); if ($in_return_to) { $return_to = new PP_Form_Element_Hidden('return_to'); $return_to->setValue($in_return_to); $form->addElement($return_to); } $form->confirm->setLabel('Confirm'); $form->cancel->setLabel('Cancel'); $this->view->form = $form; } else { /* we were given a bad ID */ } }
public function deleteFormSubmitted(AppForm $form) { if ($form['delete']->isSubmittedBy()) { $album = new Albums(); $album->delete($this->getParam('id')); $this->flashMessage('Album has been deleted.'); } $this->redirect('default'); }