/**
  * @param integer $forumId
  *
  * @return array
  * @throws \Exception
  */
 public function getForum($forumId)
 {
     $forum = $this->forumRepository->findByUid($forumId);
     if ($forum === NULL) {
         throw new \Exception("The forum {$forumId} does not exist!", 1332447187);
     }
     return array('success' => true, 'data' => array('title' => $forum->getTitle(), 'description' => $forum->getDescription(), '__identity' => $forum->getUid()));
 }
 /**
  *
  * Loads the option rows for this select field.
  * @return array All option rows.
  *
  */
 protected function getOptions()
 {
     $rootForums = $this->forumRepository->findRootForums();
     $values = array();
     foreach ($rootForums as $rootForum) {
         $values[] = $this->getForumOptionRow($rootForum, TRUE);
     }
     return $values;
 }
 /**
  * @param string $postSummarys
  * @return array
  */
 private function _getPostSummarys($postSummarys)
 {
     $postSummarys = json_decode($postSummarys);
     $data = array();
     $counter = 0;
     $this->request->setFormat('html');
     foreach ($postSummarys as $summary) {
         $post = false;
         switch ($summary->type) {
             case 'lastForumPost':
                 $forum = $this->forumRepository->findByUid($summary->uid);
                 /* @var Post */
                 $post = $forum->getLastPost();
                 break;
             case 'lastTopicPost':
                 $topic = $this->topicRepository->findByUid($summary->uid);
                 /* @var Post */
                 $post = $topic->getLastPost();
                 break;
         }
         if ($post) {
             $data[$counter] = $summary;
             $this->view->assign('post', $post)->assign('hiddenImage', $summary->hiddenimage);
             $data[$counter]->html = $this->view->render('postSummary');
             $counter++;
         }
     }
     $this->request->setFormat('json');
     return $data;
 }
 /**
  * Displays all topics and forums subscribed by the current user.
  *
  * @throws NotLoggedInException
  */
 public function listSubscriptionsAction()
 {
     $user = $this->getCurrentUser();
     if ($user->isAnonymous()) {
         throw new NotLoggedInException('You need to be logged in to view your own subscriptions!', 1335120249);
     }
     $this->view->assignMultiple(['forums' => $this->forumRepository->findBySubscriber($user), 'topics' => $this->topicRepository->findBySubscriber($user), 'user' => $user]);
 }
 /**
  * Mark a whole forum as read
  * @param Forum $forum
  *
  * @throws NotLoggedInException
  * @return void
  */
 public function markReadAction(Forum $forum)
 {
     $user = $this->getCurrentUser();
     if ($user->isAnonymous()) {
         throw new NotLoggedInException("You need to be logged in.", 1288084981);
     }
     $forumStorage = array();
     $forumStorage[] = $forum;
     foreach ($forum->getChildren() as $children) {
         $forumStorage[] = $children;
     }
     foreach ($forumStorage as $checkForum) {
         /** @var Forum $checkForum */
         foreach ($checkForum->getTopics() as $topic) {
             /** @var Topic $topic */
             $topic->addReader($user);
         }
         $checkForum->addReader($user);
         $this->forumRepository->update($checkForum);
     }
     $this->redirect('show', 'Forum', NULL, array('forum' => $forum));
 }
Example #6
0
 public function getChildren()
 {
     return $this->forumRepository->findRootForums();
 }
 /**
  * Sets a post as solution
  *
  * @param Topic $topic
  * @param Post  $post
  */
 public function setPostAsSolution(Topic $topic, Post $post)
 {
     $topic->setSolution($post);
     $this->topicRepository->update($topic);
     $this->forumRepository->update($topic->getForum());
 }