Exemplo n.º 1
0
 public function addAction()
 {
     try {
         if ($this->getContext()->getConnectedUser()) {
             $config = $this->getConfig();
             $return = \Sb\Db\Service\UserBookSvc::getInstance()->addFromPost($this->getContext()->getConnectedUser(), $config);
             $this->view->message = $return;
         } else {
             $this->view->message = __("Vous devez être connecté pour ajouter un livre.", "s1b");
         }
     } catch (\Exception $e) {
         Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString()));
         $this->view->message = __("Une erreur s'est produite lors de l'ajout du livre.", "s1b");
     }
 }
Exemplo n.º 2
0
 public function get($bookId)
 {
     try {
         $key = self::BOOK_PAGE . "_id_" . $bookId;
         $result = $this->getData($key);
         if ($result === false) {
             $result = new BookPage();
             /* @var Book $book */
             $book = BookDao::getInstance()->get($bookId);
             if (!$book) {
                 return null;
             }
             $result->setBook($book);
             $booksAlsoLiked = BookSvc::getInstance()->getBooksAlsoLiked($bookId, false);
             $result->setBooksAlsoLiked($booksAlsoLiked);
             $booksWithSameAuthor = BookSvc::getInstance()->getBooksWithSameContributors($bookId, false);
             $result->setBooksWithSameAuthor($booksWithSameAuthor);
             $booksWithSameTags = BookSvc::getInstance()->getBooksWithSameTags($bookId, false);
             $result->setBooksWithSameTags($booksWithSameTags);
             $lastlyReadUserbooks = UserBookSvc::getInstance()->getLastlyReadUserbookByBookId($bookId, 5, false);
             $result->setLastlyReadUserbooks($lastlyReadUserbooks);
             $reviewedUserBooks = $this->getReviewedUserBooks($book->getNotDeletedUserBooks());
             $result->setReviewedUserBooks($reviewedUserBooks);
             $pressReviews = $this->getBookPressReviews($book);
             $result->setPressReviews($pressReviews);
             $relatedChronicles = $this->getChroniclesRelativeToBook($book);
             $result->setRelatedChronicles($relatedChronicles);
             $criteria = array("type" => array(false, "=", PressReviewTypes::VIDEO), "book" => array(true, "=", $book), "is_validated" => array(false, "=", 1));
             $videoPressReviews = PressReviewSvc::getInstance()->getList($criteria, 1, false);
             if ($videoPressReviews) {
                 $video = $videoPressReviews[0];
                 $result->setVideoPressReview($video);
             }
             $this->setData($key, $result);
         }
         return $result;
     } catch (\Exception $e) {
         $this->logException(get_class(), __FUNCTION__, $e);
     }
 }
Exemplo n.º 3
0
 private function getPage($key)
 {
     $userId = $this->getContext()->getIsShowingFriendLibrary() ? $this->getContext()->getLibraryUserId() : $this->getContext()->getConnectedUser()->getId();
     $books = UserBookSvc::getInstance()->getUserBooks($key, $userId, true);
     if ($books) {
         // Prepare list view
         $view = $this->createBookTableView($key, $books);
         $response = $view->get();
         return $response;
     } else {
         return "";
     }
 }