public function getPlanning() { try { $params = $this->getParams(); if (count($params) > 3 || count($params) < 3) { throw new MissingParamsException(); } if ($params != Cleaner::clean($params)) { throw new MissingParamsException(); } $response = new AJAXAnswer(true); $response->setMessage(Planning::getPlanning($params[0], $params[1], $params[2])); $response->answer(); } catch (MissingParamsException $e) { $error = new AJAXAnswer(false, 'Missing Parameters for this query'); $error->answer(); } }
public function deleteImage() { try { $params = $this->getParams(); $imageID = $params[0]; if (!Authentication::getInstance()->isAuthenticated()) { throw new \Exception('Vous n\'etes pas connecté'); } $userID = Authentication::getInstance()->getUserId(); $id = $this->imageModel->checkOwner($userID, $imageID); if (empty($id)) { throw new \Exception('Cette image n\'est pas à vous !'); } $this->imageModel->deleteImage($userID, $imageID); unlink('content/' . $imageID); $response = new AJAXAnswer(true, 'Image supprimée'); $response->answer(); } catch (MissingParamsException $e) { $error = new AJAXAnswer(false, 'Aucune image n\'est indiqué'); $error->answer(); } catch (\Exception $e) { $error = new AJAXAnswer(false, $e->getMessage()); $error->answer(); } }