예제 #1
0
 private function setChronicleData(ChronicleForm $form, Chronicle $chronicle)
 {
     $globalContext = new \Sb\Context\Model\Context();
     $book = BookDao::getInstance()->get($form->getChronicleBookId());
     $chronicle->setBook($book);
     $group = GroupDao::getInstance()->get($form->getChronicleGroupId());
     $chronicle->setGroup($group);
     if ($form->getChronicleImage()) {
         $fullImageName = $this->getImageUrl($form->getChronicleGroupId()) . "/" . $form->getChronicleImage();
         $chronicle->setImage($fullImageName);
     }
     $chronicle->setIs_validated(true);
     $chronicle->setKeywords($form->getChronicleKeywords());
     $chronicle->setLink($form->getChronicleLink());
     $tag = TagDao::getInstance()->get($form->getChronicleTagId());
     $chronicle->setTag($tag);
     $chronicle->setText($form->getChronicleText());
     $chronicle->setTitle($form->getChronicleTitle());
     $chronicle->setType_id($form->getChronicleType());
     $chronicle->setUser($globalContext->getConnectedUser());
     $chronicle->setLink_type($form->getChronicleLinkType());
 }
 public function setGroup($group)
 {
     $this->__load();
     return parent::setGroup($group);
 }
예제 #3
0
 /**
  * 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);
 }