/**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventObj->poll->messageType == 'post') {
         // check permissions
         require_once WBB_DIR . 'lib/data/post/Post.class.php';
         $post = new Post($eventObj->poll->messageID);
         if (!$post->postID) {
             throw new IllegalLinkException();
         }
         require_once WBB_DIR . 'lib/data/thread/Thread.class.php';
         $thread = new Thread($post->threadID);
         $thread->enter();
         require_once WBB_DIR . 'lib/data/board/Board.class.php';
         $board = new Board($thread->boardID);
         $eventObj->canVotePoll = $board->getPermission('canVotePoll');
         // plug in breadcrumbs
         WCF::getTPL()->assign(array('board' => $board, 'thread' => $thread, 'showThread' => true));
         WCF::getTPL()->append('specialBreadCrumbs', WCF::getTPL()->fetch('navigation'));
         // get other polls from this thread
         if ($thread->polls > 1) {
             require_once WCF_DIR . 'lib/data/message/poll/Poll.class.php';
             $polls = array();
             $sql = "SELECT \t\tpoll_vote.pollID AS voted,\n\t\t\t\t\t\t\tpoll_vote.isChangeable,\n\t\t\t\t\t\t\tpoll.*\n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_poll poll\n\t\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_poll_vote poll_vote\n\t\t\t\t\tON \t\t(poll_vote.pollID = poll.pollID\n\t\t\t\t\t\t\t" . (!WCF::getUser()->userID ? "AND poll_vote.ipAddress = '" . escapeString(WCF::getSession()->ipAddress) . "'" : '') . "\n\t\t\t\t\t\t\tAND poll_vote.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\tWHERE \t\tpoll.pollID IN (\n\t\t\t\t\t\t\t\tSELECT\tpollID\n\t\t\t\t\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\t\t\t\t\tWHERE\tthreadID = " . $thread->threadID . "\n\t\t\t\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t\t\t\t\t\tAND pollID <> 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\tORDER BY\tpoll.question";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $polls[] = new Poll(null, $row, $eventObj->canVotePoll);
             }
             if (count($polls) > 1) {
                 WCF::getTPL()->assign(array('polls' => $polls, 'pollID' => $eventObj->pollID));
                 WCF::getTPL()->append('additionalSidebarContent', WCF::getTPL()->fetch('pollOverviewSidebar'));
             }
         }
     }
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (isset($_REQUEST['threadID']) && intval($_REQUEST['threadID']) != 0) {
         $threadID = intval($_REQUEST['threadID']);
         require_once WBB_DIR . 'lib/data/thread/Thread.class.php';
         $thread = new Thread($threadID);
         if (!$thread->threadID) {
             throw new IllegalLinkException();
         }
         $thread->enter();
         $sql = "SELECT\tpollID\n\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\tWHERE\tthreadID = " . $threadID . "\n\t\t\t\t\tAND\tisDeleted = 0\n\t\t\t\t\tAND\tisDisabled = 0\n\t\t\t\t\tAND\tpollID > 0\n\t\t\t\tORDER BY postID ASC";
         $row = WCF::getDB()->getFirstRow($sql);
         $eventObj->pollID = $row['pollID'];
     }
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     $attachment = $eventObj->attachment;
     if ($attachment['containerID'] && $attachment['containerType'] == 'post') {
         // get thread
         require_once WBB_DIR . 'lib/data/thread/Thread.class.php';
         $thread = new Thread(null, null, $attachment['containerID']);
         // check read permission
         $thread->enter();
         // get board
         require_once WBB_DIR . 'lib/data/board/Board.class.php';
         $board = Board::getBoard($thread->boardID);
         // check download permission
         if (!$board->getPermission('canDownloadAttachment') && (!$eventObj->thumbnail || !$board->getPermission('canViewAttachmentPreview'))) {
             throw new PermissionDeniedException();
         }
     }
 }