/**
  * Validates the "getNewsPreview" action.
  */
 public function validateGetNewsPreview()
 {
     $this->viewableNews = ViewableNews::getViewableNews(reset($this->objectIDs));
     if ($this->viewableNews === null || !$this->viewableNews->canRead()) {
         throw new PermissionDeniedException();
     }
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     MessageForm::readParameters();
     if (isset($_REQUEST['id'])) {
         $this->updateID = intval($_REQUEST['id']);
     }
     $this->update = new NewsUpdate($this->updateID);
     if (!$this->update->updateID) {
         throw new IllegalLinkException();
     }
     $this->newsID = $this->update->newsID;
     $this->news = ViewableNews::getViewableNews($this->newsID);
     // check news permissions
     if (!$this->news->isEditable()) {
         throw new PermissionDeniedException();
     }
 }
 /**
  * @see	\wcf\system\bbcode\IBBCode::getParsedTag()
  */
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     // get news id from bbcode
     if (isset($openingTag['attributes'][0])) {
         $newsID = $openingTag['attributes'][0];
     }
     $displayMode = 'link';
     if (isset($openingTag['attributes'][1])) {
         $displayMode = $openingTag['attributes'][1];
     }
     // get news
     $news = ViewableNews::getViewableNews($newsID);
     if ($news === null) {
         return '';
     }
     switch ($displayMode) {
         case 'meta':
             WCF::getTPL()->assign(array('news' => $news));
             return WCF::getTPL()->fetch('newsBBCodeTag', 'news');
             break;
         default:
             return '<a href="' . LinkHandler::getInstance()->getLink('news', array('application' => 'news', 'object' => $news)) . '">' . ($content ?: $news->subject) . '</a>';
     }
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['id'])) {
         $this->newsID = intval($_REQUEST['id']);
     }
     $this->news = ViewableNews::getViewableNews($this->newsID);
     if ($this->news === null) {
         throw new IllegalLinkException();
     }
     // check permission for the news
     if (!$this->news->canRead()) {
         throw new PermissionDeniedException();
     }
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // add breadcrumbs
     NEWSCore::getInstance()->setBreadcrumbs(array(), null, $this->news->getDecoratedObject());
 }
 /**
  * Returns the related viewable news object
  * 
  * @return	\news\data\news\ViewableNews
  */
 public function getNews()
 {
     return ViewableNews::getViewableNews($this->newsID);
 }