public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { //get id attribute if (isset($openingTag['attributes'][0])) { $newsID = $openingTag['attributes'][0]; } $news = ViewableNews::getNews($newsID); if ($news === null) { return ''; } WCF::getTPL()->assign(array('_news' => $news)); return WCF::getTPL()->fetch('newsBBCodeTag', 'cms'); }
public function readParameters() { parent::readParameters(); if (isset($_REQUEST['id'])) { $this->newsID = intval($_REQUEST['id']); } else { throw new IllegalLinkException(); } if (!isset($this->newsID) || $this->newsID == 0) { throw new IllegalLinkException(); } $this->news = ViewableNews::getNews($this->newsID); if ($this->news === null) { throw new IllegalLinkException(); } foreach ($this->news->getCategories() as $category) { if (!$category->getPermission('canViewNews')) { throw new PermissionDeniedException(); } } }