/** * * Recursively generates option rows for a forum and each subforum of this forum. * * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Forum $forum * The forum for which to generate the option row. * @param boolean $isRoot TRUE, if the forum is a root category, otherwise * FALSE. * @return array An option row for the specified forum. * */ protected function getForumOptionRow(\Mittwald\Typo3Forum\Domain\Model\Forum\Forum $forum, $isRoot = FALSE) { $result = array('name' => $forum->getTitle(), 'uid' => $forum->getUid(), '_isRoot' => $isRoot, '_children' => array()); foreach ($forum->getChildren() as $childForum) { $result['_children'][] = $this->getForumOptionRow($childForum, FALSE); } return $result; }
/** * 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)); }