/** * Confirm if image should be deleted and delete image * * @return void */ function deleteAction() { $id = (int) $this->_request->getParam('id', 0); $image_class = new Images(); if ($this->_request->isPost()) { $image = $image_class->fetchRow('id = ' . $id); $album_id = $image->album_id; // decerement viewer_order on all the images that have a higher // viewer_order than the deleted image $select = $image_class->select(); $select->where('album_id = ' . $image->album_id)->where('viewer_order > ' . $image->viewer_order); $statement = $select->__toString(); $this->logger->info($statement); $images = $image_class->fetchAll($select); foreach ($images as $image) { $image->viewer_order--; $this->logger->info("image {$image->id} now has index of {$image->viewer_order}"); $image->save(); } $del = $this->_request->getPost('confirm'); if ($del == 'Confirm' && $id > 0) { $image_class->delete('id=' . $id); } if ($this->_request->getParam('from', 0) == 'viewImage' && $del != 'Confirm') { $this->_redirect('/image/view/id/' . $id); } else { $this->_redirect('/album/view/id/' . $album_id); } } else { if ($id > 0) { $this->view->title = 'Confirm Deletion'; $image = $image_class->fetchRow('id=' . $id); $this->view->image_title = $image->title; $form = new ImageDeleteForm(); $form->confirm->setLabel('Confirm'); $form->cancel->setLabel('Cancel'); $this->view->form = $form; $form->populate($image->toArray()); } } }
function imageList() { $image_class = new Images(); $images = $image_class->fetchAll('file_uploaded=1 AND album_id=' . $this->album_id); return $images; }