public function __construct($path = NULL) { $this->FS = new FS(); $this->httpResponse = new HTTPResponse(); $this->httpRequest = new HTTPRequest(); $this->path = isset($path) ? $path : ($this->httpRequest->getExists('path') ? $this->httpRequest->getData('path') : NULL); }
public function executeIndex(HTTPRequest $request) { if (!$this->app->user()->isAuthenticated()) { $this->app->httpResponse()->redirect404(); exit; } if (Config::get('platform-fee-ratio') == 0) { $this->app->httpResponse()->redirect404(); exit; } $reservationId = htmlspecialchars($request->getData('reservationId')); $reservation = $this->_announcementReservationManager->get($reservationId); if (is_null($reservation)) { $this->app->httpResponse()->redirect404(); exit; } $userId = $this->app->user()->getAttribute('id'); if ($userId != $reservation->getUserSubscriberId() || $reservation->getStateId() != PaiementStates::WAITING_PAIEMENT) { $this->app->httpResponse()->redirect404(); exit; } $this->page->smarty()->assign('announcementReservationManager', $this->_announcementReservationManager); $this->page->smarty()->assign('usersManager', $this->_usersManager); $this->page->smarty()->assign('reservation', $reservation); $this->page->smarty()->assign('amount', round($reservation->getPrice() * Tipkin\Config::get('platform-fee-ratio'), 2)); }
public function executeAnnounceList(HTTPRequest $request) { $announceId = htmlspecialchars($request->getData('announceId')); $listOfFeedbacks = $this->_feedbacksManager->getByAnnounceId($announceId); $this->page->smarty()->assign('listOfFeedbacks', $listOfFeedbacks); $this->page->smarty()->assign('profilesManager', $this->_profilesManager); $this->page->smarty()->assign('usersManager', $this->_usersManager); }
public function executeDelete(HTTPRequest $request) { $id = $request->getData('carrouselId'); $carrousel = $this->_carrouselsManager->get($id); $announceId = $carrousel->getAnnounceId(); $this->_carrouselsManager->delete($id); $this->app->httpResponse()->redirect('/view/member/announce-' . $announceId); exit; }
public function executeCancel(HTTPRequest $request) { $reservationid = $request->getData('reservationId'); $reservation = $this->_reservationsManager->get($reservationid); if ($this->app->httpRequest()->postExists('submit-form')) { $reservation->setStateId(PaiementStates::CANCELED); $reservation->setUpdatedTime(time()); $this->_reservationsManager->save($reservation); $this->app->httpResponse()->redirect('/admin/history'); exit; } $this->page->smarty()->assign('reservation', $reservation); }
public function executeRefuse(HTTPRequest $request) { $announce = $this->_announcementsManager->get($request->getData('announceId')); $this->page->smarty()->assign('announce', $announce); if ($request->postExists('confirm')) { $announce->setStateId(AnnouncementStates::STATE_REFUSED); $announce->setAdminComment(htmlspecialchars($request->postData('admin-comment'))); $this->_announcementsManager->save($announce); $this->app->user()->setFlash('announce-refused'); //TODO : Envoyer un mail à l'utilistateur $this->app->httpResponse()->redirect('/admin/announcements'); exit; } }
public function executePublish(HTTPRequest $request) { $opinionId = $request->getData('opinionId'); $opinion = $this->_opinionsManager->get($opinionId); if ($request->postExists('submit-form')) { $opinion->setIsPublished(true); $this->_opinionsManager->save($opinion); $this->app->user()->setFlash('opinion-published'); $this->app->httpResponse()->redirect('/admin/opinion'); exit; } $this->page->smarty()->assign('opinion', $opinion); $this->page->smarty()->assign('opinionsManager', $this->_opinionsManager); $this->page->smarty()->assign('usersManager', $this->_usersManager); }
public function executeDeleteFeedback(HTTPRequest $request) { $feedbackId = htmlspecialchars($request->getData('feedbackId')); $feedback = $this->_feedbacksManager->get($feedbackId); if ($request->postExists('submit-form')) { $this->_moderatesManager->deleteByFeedbackId($feedbackId); $this->_feedbacksManager->delete($feedbackId); $this->app->user()->setFlash('feedback-deleted'); $this->app->httpResponse()->redirect('/admin/moderate'); exit; } $this->page->smarty()->assign('feedback', $feedback); $this->page->smarty()->assign('feedbacksManager', $this->_feedbacksManager); $this->page->smarty()->assign('profilesManager', $this->_profilesManager); $this->page->smarty()->assign('usersManager', $this->_usersManager); }
public function executeDelete(HTTPRequest $request) { $category = $this->_categoriesManager->get($request->getData('categoryId')); if ($request->postExists('submit-form')) { $this->_categoriesManager->deleteByParentCategoryId($category->id()); $this->_categoriesManager->delete($category->id()); $this->app->user()->setFlash('category-deleted'); $this->app->httpResponse()->redirect('/admin/categories'); exit; } if ($category->getIsRoot()) { $categoryType = 'category'; } else { $categoryType = 'sub-category'; } $this->page->smarty()->assign('category', $category); $this->page->smarty()->assign('categoriesManager', $this->_categoriesManager); }
public function executeFeedback(HTTPRequest $request) { $feedback = $this->_feedbacksManager->get(htmlspecialchars($request->getData('feedbackId'))); if ($request->postExists('submit-form')) { $moderate = new Moderate(); $moderate->setType(Moderate::TYPE_FEEDBACK); $moderate->setTypeId(htmlspecialchars($request->postData('feedback-id'))); $moderate->setUserAuthorId(htmlspecialchars($request->postData('user-id'))); $moderate->setMessage(htmlspecialchars($request->postData('message'))); $this->_moderatesManager->save($moderate); //Envoyer un mail ici $messageMail = new Mail(); $messageMail->sendModerationRequest(); $this->page->smarty()->assign('messageSent', true); $this->app->user()->setFlash('message-sent'); $this->displayInfoMessage(); } $this->page->smarty()->assign('feedback', $feedback); $this->page->smarty()->assign('profilesManager', $this->_profilesManager); $this->page->smarty()->assign('usersManager', $this->_usersManager); }
public function executePro(HTTPRequest $request) { if (!$this->app->user()->isAuthenticated()) { $this->app->httpResponse()->redirect404(); exit; } $userId = htmlspecialchars($request->getData('userId')); $user = $this->_usersManager->get($userId); $profile = null; if (!is_null($user)) { $profile = $this->_profilesProManager->getByUserId($user->id()); } if (is_null($profile)) { $this->app->httpResponse()->redirect404(); exit; } $mainAddress = $this->_addressesManager->get($profile->getMainAddressId()); $this->_listOfUserAnnonces = $this->_announcementsProManager->getListOf($user->id()); $this->page->smarty()->assign('user', $user); $this->page->smarty()->assign('profile', $profile); $this->page->smarty()->assign('mainAddress', $mainAddress); $this->page->smarty()->assign('listOfUserAnnonces', $this->_listOfUserAnnonces); }
private function assignFilter(HTTPRequest $request, AnnounceFilter $announceFilter) { $regionId = htmlspecialchars($request->getData('regionId')); $departmentId = htmlspecialchars($request->getData('departmentId')); $categoryId = htmlspecialchars($request->getData('categoryId')); $subCategoryId = htmlspecialchars($request->getData('subCategoryId')); $zipCode = htmlspecialchars($request->getData('zipCode')); $filterText = htmlspecialchars(urldecode($request->getData('filter'))); $filterText = preg_replace('/(\\/|\\+)/', ' ', $filterText); //Supprime les espaces inutiles $filterText = preg_replace('/\\s\\s+/', ' ', $filterText); $announceFilter->setRegionId($regionId); $announceFilter->setDepartmentId($departmentId); $announceFilter->setCategoryId($categoryId); $announceFilter->setSubCategoryId($subCategoryId); $announceFilter->setZipCode($zipCode); $announceFilter->setFilterText($filterText); $inCommunity = htmlspecialchars($request->getData('community')); if (!empty($inCommunity)) { $inCommunity = $this->app->user()->getAttribute('id'); } $announceFilter->setInCommunity($inCommunity); $this->page->smarty()->assign('filter', $announceFilter); }
private function reservationRedirect(HTTPRequest $request) { if ($request->getExists('reservationId') && $request->getExists('keyCheck')) { $idReservation = htmlspecialchars($request->getData('reservationId')); $reservation = $this->_announcementReservationManager->get($idReservation); //Si notre lien de réservation a déjà été "consommé" on redirige vers une page de "Rebond" if (is_null($reservation->getKeyCheck())) { $this->app->httpResponse()->redirect('/reservations/rebound/' . $reservation->id()); exit; } elseif ($reservation->getKeyCheck() != $request->getData('keyCheck')) { $this->app->httpResponse()->redirect404(); exit; } } else { $this->app->httpResponse()->redirect404(); exit; } }
public function executeUnarchive(HTTPRequest $request) { $announceId = $request->getData('announceId'); $announce = $this->_announcementsProManager->get($announceId); $this->page->smarty()->assign('announce', $announce); if ($request->postExists('confirm')) { $announce->setStateId(AnnouncementStates::STATE_VALIDATED); $currentDate = new DateTime(); $announce->setPublicationDate($currentDate->format('Y-m-d')); $this->_announcementsProManager->save($announce); $this->app->httpResponse()->redirect('/announcements-pro' . '/validated'); exit; } }
public function executePro(HTTPRequest $request) { $announceId = htmlspecialchars($request->getData('announceId')); $announce = $this->_announcementsProManager->get($announceId); if (!$this->announceIsValid($announce)) { $this->app->httpResponse()->redirect404(); exit; } $profile = $this->_profilesProManager->getByUserId($announce->getUserId()); $user = $this->_usersManager->get($announce->getUserId()); $mainAddress = $this->_addressesManager->get($profile->getMainAddressId()); $this->_listOfUserAnnonces = $this->_announcementsProManager->getListOf($announce->getUserId()); $this->page->smarty()->assign('announce', $announce); $this->page->smarty()->assign('profile', $profile); $this->page->smarty()->assign('user', $user); $this->page->smarty()->assign('categories', $this->_listOfCategories); $this->page->smarty()->assign('mainAddress', $mainAddress); $this->page->smarty()->assign('listOfUserAnnonces', $this->_listOfUserAnnonces); $this->page->smarty()->assign('usersManager', $this->_usersManager); $this->page->smarty()->assign('departmentsManager', $this->_departmentsManager); }
public function executeAdd(HTTPRequest $request) { $userId = htmlspecialchars($request->getData('userId')); $user = $this->_usersManager->get($userId); $this->page->smarty()->assign('user', $user); if ($request->postExists('contact-group')) { $contactRequest = new ContactRequest(); $contactRequest->setUserIdFrom($this->_user->id()); $contactRequest->setUserIdTo(htmlspecialchars($request->postData('user-id-to'))); $contactRequest->setContactGroupId(htmlspecialchars($request->postData('contact-group'))); $this->_contactRequestsManager->save($contactRequest); //TODO envoyer un mail $userFrom = $this->_usersManager->get($contactRequest->getUserIdFrom()); $userTo = $this->_usersManager->get($contactRequest->getUserIdTo()); $messageMail = new Mail(); $messageMail->sendContactRequest($userFrom, $userTo); $this->app->user()->setFlash('contact-request-sent'); $this->app->httpResponse()->redirect('/contacts'); } }
public function executeUnarchiveIndisponibilities(HTTPRequest $request) { $announceId = $request->getData('announceId'); $announce = $this->_announcementsManager->get($announceId); if (is_null($announce)) { $this->app->httpResponse()->redirect404(); exit; } if ($announce->getUserId() != $this->_user->id()) { $this->app->httpResponse()->redirect404(); exit; } if (is_null($announce->getPublicationDate()) || is_null($announce->getEndPublicationDate())) { $this->app->httpResponse()->redirect('/announcements/unarchive/' . $announce->id()); exit; } $announcementUnavailabilities = array(); $announcementUnavailabilities = $this->_announcementUnavailabilitiesManager->getByAnnouncementId($announceId); if ($request->postExists('submit-form')) { $this->_announcementUnavailabilitiesManager->deleteByAnnouncementId($announce->id()); $announcementUnavailabilities = $this->parseIndisponibilities($request, $announce); foreach ($announcementUnavailabilities as $unavailability) { $unavailability->setAnnouncementId($announce->id()); $this->_announcementUnavailabilitiesManager->save($unavailability); } //Traitement et redirection en fonction de l'état de l'annonce //Si archive if ($announce->getStateId() == AnnouncementStates::STATE_ARCHIVED) { $this->app->user()->setFlash('announce-published'); $this->displayInfoMessage(); $announce->setStateId(AnnouncementStates::STATE_VALIDATED); $this->_announcementsManager->save($announce); $this->app->httpResponse()->redirect('/announcements/validated'); exit; } } $dateList = array(); foreach ($announcementUnavailabilities as $unavailability) { $dateList[] = $unavailability->getDate(); } $this->page->smarty()->assign('announce', $announce); $this->page->smarty()->assign('dateList', implode(',', $dateList)); $this->page->smarty()->assign('unavailabilities', $announcementUnavailabilities); }
public function executeUsernameExists(HTTPRequest $request) { $this->init(); if ($request->getExists('username')) { $username = htmlspecialchars($request->getData('username')); $isUsernameExists = $this->_userManager->isUsernameOrMailExist($username, $username); $this->page->smarty()->assign('usernameExists', $isUsernameExists); } else { $this->app->httpResponse()->redirect404(); exit; } }