public function editAction() { try { $globalContext = new \Sb\Context\Model\Context(); if ($globalContext->getIsShowingFriendLibrary()) { Flash::addItem(__("You cannot edit a lending from a friend's library")); HTTPHelper::redirectToHome(); } $userBookId = $_GET['ubid']; $userBook = UserBookDao::getInstance()->get($userBookId); if ($userBook) { // Check user is user book owner if ($globalContext->getConnectedUser()->getId() != $userBook->getUser()->getId()) { Flash::addItem(__("Le livre que vous souhaitez éditer ne correspond pas à l'utilisateur connecté.", "share1book")); HTTPHelper::redirectToLibrary(); } $book = $userBook->getBook(); $bookView = new BookView($book, false, false, false); $this->view->book = $bookView->get(); $lendingView = new LendingView($userBook, $globalContext->getConnectedUser()->getId()); $this->view->bookForm = $lendingView->get(); $buttonsBar = new ButtonsBar(false); $this->view->buttonsBar = $buttonsBar->get(); } else { Flash::addItem("Le livre que vous souhaitez éditer n'existe pas."); HTTPHelper::redirectToLibrary(); } } catch (\Exception $e) { Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString())); $this->forward("error", "error", "default"); } }
public function displayAddingChoiceAction() { try { $globalContext = new \Sb\Context\Model\Context(); if ($globalContext->getIsShowingFriendLibrary()) { Flash::addItem(__("Vous ne pouvez pas ajouter un livre à la bibliothèque d'un ami.", "s1b")); } // Récupération du Book depuis le cache $book = ZendFileCache::getInstance()->load(Constants::BOOK_TO_ADD_PREFIX . session_id()); // If id is known, getting the book from db to have all associated members and userbooks to show the potential reviews $booksAlsoLiked = null; $booksWithSameTags = null; $reviewdUserBooks = null; if ($book->getId()) { $book = BookDao::getInstance()->get($book->getId()); $bookPage = BookPageSvc::getInstance()->get($book->getId()); $booksAlsoLiked = $bookPage->getBooksAlsoLiked(); $booksWithSameTags = $bookPage->getBooksWithSameTags(); $reviewdUserBooks = $bookPage->getReviewedUserBooks(); } $bookView = new BookView($book, true, true, true, $booksAlsoLiked, $booksWithSameTags, $reviewdUserBooks); $this->view->book = $bookView->get(); $buttonsBar = new ButtonsBar(false); $this->view->buttonsBar = $buttonsBar->get(); $this->view->referer = HTTPHelper::getReferer(); } catch (\Exception $e) { Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString())); $this->forward("error", "error", "default"); } }