private function getVideoPressReview(Chronicle $chronicle) { if ($chronicle->getBook()) { $criteria = array("type" => array(false, "=", PressReviewTypes::VIDEO), "book" => array(true, "=", $chronicle->getBook()), "is_validated" => array(false, "=", 1)); $video = PressReviewSvc::getInstance()->getList($criteria, 1, false); if ($video && count($video) == 1) { return $video[0]; } } return null; }
public function getDetailLink() { $this->__load(); return parent::getDetailLink(); }
public function setExistingChronicle(Chronicle $chronicle) { $this->setDefaults(array("id" => $chronicle->getId(), "title" => $chronicle->getTitle(), "keywords" => $chronicle->getKeywords(), "text" => $chronicle->getText(), "link" => $chronicle->getLink(), "link_type" => $chronicle->getLink_type(), "user_id" => $chronicle->getGroup()->getId(), "image" => $chronicle->getImage(), "type" => $chronicle->getType_id(), "user_id" => $chronicle->getUser()->getId(), "group_id" => $chronicle->getGroup()->getId())); if ($chronicle->getTag()) { $this->setDefault("tag_id", $chronicle->getTag()->getId()); } if ($chronicle->getBook()) { $this->setDefault("book_id", $chronicle->getBook()->getId()); } }
/** * Get a reviews view object representing a paginated list of reviews for the current book * @param Chronicle $chronicle the current chronicle to get the book and the reviews from * @return \Sb\View\BookReviews NULL BookReviews object or NULL */ private function getReviews(Chronicle $chronicle) { if ($chronicle->getBook()) { // book reviews $userBooks = $chronicle->getBook()->getNotDeletedUserBooks(); $reviewedUserBooks = array_filter($userBooks, array(&$this, "isReviewed")); $reviews = ""; if ($reviewedUserBooks) { $paginatedList = new PaginatedList($reviewedUserBooks, 5); $reviewsView = new BookReviews($paginatedList, $chronicle->getBook()->getId()); return $reviewsView; } } return null; }
private function checkUserCanEditChronicle(Chronicle $chronicle) { $globalContext = new \Sb\Context\Model\Context(); $chronicleGroupId = $chronicle->getGroup()->getId(); $found = false; foreach ($globalContext->getConnectedUser()->getGroupusers() as $groupUser) { /* @var $groupUser GroupUser */ if ($groupUser->getGroup()->getId() == $chronicleGroupId) { $found = true; break; } } if (!$found) { Flash::addItem(__("Vous ne pouvez pas éditer cette chronique.", "s1b")); HTTPHelper::redirectToReferer(); } }
/** * Add or update a chronicle based on a userbook review * * @param \Sb\Db\Model\UserBook $userBook * @param unknown $groupId */ public function addOrUpdateFromUserBook(\Sb\Db\Model\UserBook $userBook) { $bloggerGroupId = 2; /* @var $user \Sb\Db\Model\User */ $user = $userBook->getUser(); /* @var $user \Sb\Db\Model\Book */ $book = $userBook->getBook(); /* @var $existingChronicle \Sb\Db\Model\Chronicle */ $chronicle = $this->getChronicle($user->getId(), $book->getId()); if (is_null($chronicle)) { $chronicle = new Chronicle(); } $chronicle->setUser($user); $chronicle->setBook($userBook->getBook()); $chronicle->setCreation_date(new \DateTime()); $chronicle->setGroup(\Sb\Db\Dao\GroupDao::getInstance()->get($bloggerGroupId)); $chronicle->setIs_validated(true); $chronicle->setLink($userBook->getHyperlink() ? 'http://' . $userBook->getHyperlink() : ''); $chronicle->setLink_type(ChronicleLinkType::URL); $chronicle->setText($userBook->getReview()); $chronicle->setTitle($book->getTitle()); $chronicle->setType_id(ChronicleType::BOOK_CHRONICLE); $chronicle->setKeywords($book->getTitle() . ', ' . $book->getOrderableContributors() . ', ' . $book->getPublisher()->getName()); $tags = $userBook->getTags(); if (count($tags) > 0) { $chronicle->setTag($userBook->getTags()->first()); } $this->getDao()->add($chronicle); }