/** * * 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; }
/** * @param Forum $forum * @param FrontendUser $user * @return array */ public function getUnreadTopics(Forum $forum, FrontendUser $user) { $sql = 'SELECT t.uid FROM tx_typo3forum_domain_model_forum_topic AS t LEFT JOIN tx_typo3forum_domain_model_user_readtopic AS rt ON rt.uid_foreign = t.uid AND rt.uid_local = ' . (int) $user->getUid() . ' WHERE rt.uid_local IS NULL AND t.forum=' . (int) $forum->getUid(); /** @var Query $query */ $query = $this->createQuery(); $query->statement($sql); return $query->execute()->toArray(); }