public function deleteloginimageAction($id) { $imagebank = Imagebank::findFirst(array('conditions' => 'idImagebank = ?1', 'bind' => array(1 => $id))); if ($imagebank) { if (!$imagebank->delete()) { foreach ($imagebank as $msg) { $this->logger->log("Could not delete image from db... {$msg}"); } $this->flashSession->error("Ocurrió un error mientras se eliminaba la imagen, por favor contacte al administrador"); return $this->response->redirect('imagebank'); } $dir = $this->imgbnk->loginimages . $imagebank->name; try { $uploader = new \Silar\Misc\Uploader(); $uploader->deleteFileFromServer($dir); $this->flashSession->success("Se ha eliminado la imagen exitosamente"); return $this->response->redirect('imagebank'); } catch (Exception $e) { $this->logger->log("Exception: {$e}"); $this->flashSession->error("Ocurrió un error mientras se eliminaba la imagen, por favor contacte al administrador"); return $this->response->redirect('imagebank'); } } $this->flashSession->error("La imagen a eliminar no existe"); return $this->response->redirect('imagebank'); }
private function findLoginImages() { $this->images = \Imagebank::find(); $this->totalImages = \count($this->images); if ($this->totalImages > 0) { $this->getRandomImage(); } else { $this->image = 'none.jpg'; } }