/** * * @access public * @param \CCDNForum\ForumBundle\Entity\Topic $topic * @param int $userId * @return \CCDNForum\ForumBundle\Manager\ManagerInterface */ public function unsubscribe(Topic $topic, $userId) { $subscription = $this->model->findOneSubscriptionForTopicByIdAndUserById($topic->getId(), $userId); if (!$subscription) { return $this; } $subscription->setSubscribed(false); $subscription->setRead(true); $this->gateway->saveSubscription($subscription); return $this; }
protected function createTopic($board, $title) { $topic = new Topic(); $topic->setBoard($board); $topic->setTitle($title); $topic->setCachedViewCount(0); $topic->setCachedReplyCount(0); $topic->setSticky(false); $topic->setClosed(false); $topic->setDeleted(false); return $topic; }
/** * * @access public * @param \CCDNForum\ForumBundle\Entity\Forum $forum * @param \CCDNForum\ForumBundle\Entity\Topic $topic * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail */ public function addUserTopicShow(Forum $forum, Topic $topic) { return $this->addUserBoardShow($forum, $topic->getBoard())->add($topic->getTitle(), array('route' => 'ccdn_forum_user_topic_show', 'params' => array('forumName' => $forum->getName(), 'topicId' => $topic->getId()))); }
public function canReopenTopic(Topic $topic, Forum $forum = null) { if (!$topic->isClosed()) { return false; } if (!$this->canShowTopic($topic, $forum)) { if (!$this->securityContext->isGranted('ROLE_ADMIN')) { return false; } } if (!$this->securityContext->isGranted('ROLE_MODERATOR')) { return false; } return true; }
/** * * @access public * @param \CCDNForum\ForumBundle\Entity\Topic $topic * @return \CCDNForum\ForumBundle\Manager\ManagerInterface */ public function reopen(Topic $topic) { $topic->setClosed(false); $topic->setClosedBy(null); $topic->setClosedDate(null); if ($topic->isDeleted()) { $topic->setDeleted(false); $topic->setDeletedBy(null); $topic->setDeletedDate(null); } $this->persist($topic)->flush(); return $this; }
/** * * @access protected * @param \CCDNForum\ForumBundle\Entity\Topic $topic * @return null|\CCDNForum\ForumBundle\Entity\Board */ private function extractBoardFromTopic(Topic $topic) { if ($topic) { if ($topic->getId()) { return $topic->getBoard(); } } return null; }
/** * * @access protected * @param string $forumName * @param \CCDNForum\ForumBundle\Entity\Topic $topic * @param \CCDNForum\ForumBundle\Entity\Post $post * @return \Symfony\Component\HttpFoundation\RedirectResponse */ protected function redirectResponseForTopicOnPageFromPost($forumName, Topic $topic, Post $post) { //$page = $this->getTopicModel()->getPageForPostOnTopic($topic, $topic->getLastPost()); // Page of the last post. $response = $this->redirectResponse($this->path('ccdn_forum_user_topic_show', array('forumName' => $forumName, 'topicId' => $topic->getId()))); return $response; }