/** * @see WarningObjectType::getObjectByID() */ public function getObjectByID($objectID) { if (is_array($objectID)) { $posts = array(); $sql = "SELECT\t\tpost.*, thread.topic, thread.boardID\n\t\t\t\tFROM \t\twbb" . WBB_N . "_post post\n\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\tWHERE \t\tpostID IN (" . implode(',', $objectID) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $posts[$row['postID']] = new PostWarningObject(null, $row); } return count($posts) > 0 ? $posts : null; } else { // get object $post = new PostWarningObject($objectID); if (!$post->postID) { return null; } // check permissions if (!class_exists('WBBACP')) { // ignore permission in acp $board = Board::getBoard($post->boardID); if (!$board->getPermission('canViewBoard') || !$board->getPermission('canEnterBoard')) { return null; } } // return object return $post; } }
/** * @see Action::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['threadID'])) { $this->threadID = intval($_REQUEST['threadID']); } // get thread $this->thread = new ThreadEditor($this->threadID); // get board $this->board = Board::getBoard($this->thread->boardID); // enter thread $this->thread->enter($this->board); }
/** * @see Page::readData() */ public function readData() { parent::readData(); // get post, thread and board $this->post = new PostEditor($this->postID); $this->thread = new Thread($this->post->threadID); $this->board = Board::getBoard($this->thread->boardID); // get ip addresses of the author $this->authorIpAddresses = PostEditor::getIpAddressByAuthor($this->post->userID, $this->post->username, $this->post->ipAddress); // get hostnames $this->loadHostnames(); // get other users of this ip address if ($this->post->ipAddress) { $this->otherUsers = PostEditor::getAuthorByIpAddress($this->post->ipAddress, $this->post->userID, $this->post->username); } }
/** * @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(); } } }
/** * Gets the number of pages in this thread. * * @return integer number of pages in this thread */ public function getPages($board = null) { // get board if ($board == null || $board->boardID != $this->boardID) { if ($this->board !== null) { $board = $this->board; } else { $board = Board::getBoard($this->boardID); } } // get posts per page if (WCF::getUser()->postsPerPage) { $postsPerPage = WCF::getUser()->postsPerPage; } else { if ($board->postsPerPage) { $postsPerPage = $board->postsPerPage; } else { $postsPerPage = THREAD_POSTS_PER_PAGE; } } return intval(ceil(($this->replies + 1) / $postsPerPage)); }
/** * Closes the category with the given board id for this user. * * @param integer $boardID * @param integer $close 1 closes the category * -1 opens the category */ public function closeCategory($boardID, $close = 1) { require_once WBB_DIR . 'lib/data/board/Board.class.php'; $board = Board::getBoard($boardID); if (!$board->isCategory()) { throw new IllegalLinkException(); } $sql = "REPLACE INTO\twbb" . WBB_N . "_board_closed_category_to_user\n\t\t\t\t\t(userID, boardID, isClosed)\n\t\t\tVALUES\t\t(" . $this->userID . ",\n\t\t\t\t\t" . $boardID . ",\n\t\t\t\t\t" . $close . ")"; WCF::getDB()->registerShutdownUpdate($sql); WCF::getSession()->resetUserData(); $this->closedCategories[$boardID] = $close; }
/** * Returns true, if the active user can reply this thread. */ public function canReplyThread($board = null) { if ($board == null || $board->boardID != $this->boardID) { if ($this->board !== null) { $board = $this->board; } else { $board = Board::getBoard($this->boardID); } } return !$board->isClosed && ($this->isClosed && $board->getModeratorPermission('canReplyClosedThread') || !$this->isClosed && ($board->getPermission('canReplyThread') || $this->userID && $this->userID == WCF::getUser()->userID && $board->getPermission('canReplyOwnThread'))); }
/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { if (TEAM_SHOW_MODERATED_BOARDS) { if ($eventName == 'readData') { $eventObj->activeFields[] = 'moderatedBoards'; } else { if ($eventName == 'assignVariables') { require_once WBB_DIR . 'lib/data/board/Board.class.php'; // get user ids $userIDArray = array_keys($eventObj->members); if (count($userIDArray)) { // get user to groups $userToGroups = array(); $groupIDArray = array(); $sql = "SELECT\tuserID, groupID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $userIDArray) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!isset($userToGroups[$row['userID']])) { $userToGroups[$row['userID']] = array(); } $userToGroups[$row['userID']][] = $row['groupID']; $groupIDArray[$row['groupID']] = $row['groupID']; } // get user to boards $userToBoards = array(); $sql = "SELECT\tuserID, boardID\n\t\t\t\t\t\tFROM\twbb" . WBB_N . "_board_moderator\n\t\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $userIDArray) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!isset($userToBoards[$row['userID']])) { $userToBoards[$row['userID']] = array(); } $userToBoards[$row['userID']][] = $row['boardID']; } // get group to boards $groupToBoards = array(); if (count($groupIDArray)) { $sql = "SELECT\tgroupID, boardID\n\t\t\t\t\t\t\tFROM\twbb" . WBB_N . "_board_moderator\n\t\t\t\t\t\t\tWHERE\tgroupID IN (" . implode(',', $groupIDArray) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!isset($groupToBoards[$row['groupID']])) { $groupToBoards[$row['groupID']] = array(); } $groupToBoards[$row['groupID']][] = $row['boardID']; } } foreach ($eventObj->members as $key => $memberData) { // get board ids $boardIDArray = array(); if (isset($userToBoards[$key])) { $boardIDArray = $userToBoards[$key]; } if (isset($userToGroups[$key])) { foreach ($userToGroups[$key] as $groupID) { if (isset($groupToBoards[$groupID])) { $boardIDArray = array_merge($boardIDArray, $groupToBoards[$groupID]); } } } // get boards and check permissions array_unique($boardIDArray); $boards = array(); foreach ($boardIDArray as $boardID) { $board = Board::getBoard($boardID); if ($board->getPermission('canViewBoard')) { $boards[$board->boardID] = WCF::getLanguage()->get(StringUtil::encodeHTML($board->title)); } } if (count($boards)) { // sort boards StringUtil::sort($boards); // generate output $output = ''; foreach ($boards as $boardID => $title) { if (!empty($output)) { $output .= ', '; } $output .= '<a href="index.php?page=Board&boardID=' . $boardID . SID_ARG_2ND . '">' . $title . '</a>'; } $eventObj->members[$key]['moderatedBoards'] = $output; } } } } } } }
/** * Updates the user stats (user posts, activity points & user rank). * * @param string $threadIDs changed threads * @param string $mode (enable|copy|move|delete) * @param integer $destinationBoardID */ public static function updateUserStats($threadIDs, $mode, $destinationBoardID = 0) { if (empty($threadIDs)) { return; } // get destination board $destinationBoard = null; if ($destinationBoardID) { $destinationBoard = Board::getBoard($destinationBoardID); } if ($mode == 'copy' && !$destinationBoard->countUserPosts) { return; } // update user posts, activity points $userPosts = array(); $userActivityPoints = array(); $sql = "SELECT\tboardID, userID\n\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\tWHERE\tthreadID IN (" . $threadIDs . ")\n\t\t\t\t" . ($mode != 'enable' ? "AND everEnabled = 1" : '') . "\n\t\t\t\tAND userID <> 0"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $board = Board::getBoard($row['boardID']); switch ($mode) { case 'enable': if ($board->countUserPosts) { // posts if (!isset($userPosts[$row['userID']])) { $userPosts[$row['userID']] = 0; } $userPosts[$row['userID']]++; // activity points if (!isset($userActivityPoints[$row['userID']])) { $userActivityPoints[$row['userID']] = 0; } $userActivityPoints[$row['userID']] += ACTIVITY_POINTS_PER_THREAD; } break; case 'copy': if ($destinationBoard->countUserPosts) { // posts if (!isset($userPosts[$row['userID']])) { $userPosts[$row['userID']] = 0; } $userPosts[$row['userID']]++; // activity points if (!isset($userActivityPoints[$row['userID']])) { $userActivityPoints[$row['userID']] = 0; } $userActivityPoints[$row['userID']] += ACTIVITY_POINTS_PER_THREAD; } break; case 'move': if ($board->countUserPosts != $destinationBoard->countUserPosts) { // posts if (!isset($userPosts[$row['userID']])) { $userPosts[$row['userID']] = 0; } $userPosts[$row['userID']] += $board->countUserPosts ? -1 : 1; // activity points if (!isset($userActivityPoints[$row['userID']])) { $userActivityPoints[$row['userID']] = 0; } $userActivityPoints[$row['userID']] += $board->countUserPosts ? ACTIVITY_POINTS_PER_THREAD * -1 : ACTIVITY_POINTS_PER_THREAD; } break; case 'delete': if ($board->countUserPosts) { // posts if (!isset($userPosts[$row['userID']])) { $userPosts[$row['userID']] = 0; } $userPosts[$row['userID']]--; // activity points if (!isset($userActivityPoints[$row['userID']])) { $userActivityPoints[$row['userID']] = 0; } $userActivityPoints[$row['userID']] -= ACTIVITY_POINTS_PER_THREAD; } break; } } // save posts if (count($userPosts)) { require_once WBB_DIR . 'lib/data/user/WBBUser.class.php'; foreach ($userPosts as $userID => $posts) { WBBUser::updateUserPosts($userID, $posts); } } // save activity points if (count($userActivityPoints)) { require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php'; foreach ($userActivityPoints as $userID => $points) { UserRank::updateActivityPoints($points, $userID); } } }
/** * Validates the given parent id. */ protected function validateParentID() { if ($this->parentID) { try { Board::getBoard($this->parentID); } catch (IllegalLinkException $e) { throw new UserInputException('parentID', 'invalid'); } } }
/** * Closes the category with the given board id for this guest. * * @param integer $boardID * @param integer $close 1 closes the category * -1 opens the category */ public function closeCategory($boardID, $close = 1) { $this->getClosedCategories(); require_once WBB_DIR . 'lib/data/board/Board.class.php'; $board = Board::getBoard($boardID); if (!$board->isCategory()) { throw new IllegalLinkException(); } $this->closedCategories[$boardID] = $close; WCF::getSession()->register('closedCategories', $this->closedCategories); }
/** * @see Form::validate() */ public function validate() { parent::validate(); // action if (!in_array($this->action, $this->availableActions)) { throw new UserInputException('action'); } // move to if ($this->action == 'move') { try { $board = Board::getBoard($this->moveTo); } catch (IllegalLinkException $e) { throw new UserInputException('moveTo'); } if (!$board->isBoard()) { throw new UserInputException('moveTo'); } } // validate new language if ($this->action == 'changeLanguage') { require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor($this->newLanguageID); if (!$language->getLanguageID()) { throw new UserInputException('newLanguageID'); } } }
public function __construct($data, $boxname = "") { $this->spnrbData['templatename'] = "simplePieNewsreaderBox"; $this->getBoxStatus($data); $this->spnrbData['boxID'] = $data['boxID']; if (SPNRBOX_BOXOPENED == true) { $this->spnrbData['Status'] = 1; } if (WBBCore::getUser()->getPermission('user.board.canViewSimplePieNewsreaderBox')) { require_once WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/simplepie.inc'; require_once WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/idna_convert.class.php'; // FILTER? if (SPNRBOX_FILTER && strlen(SPNRBOX_FILTERWORDS) >= 3) { require_once WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/simplepie_filter.php'; $feed = new SimplePie_Filter(); if (!defined('SPNRBOX_FILTERCLASS')) { define('SPNRBOX_FILTERCLASS', 'hightlight'); } define('SPNRBOX_FILTERON', 1); } else { $feed = new SimplePie(); define('SPNRBOX_FILTERON', 0); } // CACHE if (SPNRBOX_CACHEMAX != 0 && SPNRBOX_CACHEMIN != 0) { $feed->set_autodiscovery_cache_duration(SPNRBOX_CACHEMAX); $feed->set_cache_duration(SPNRBOX_CACHEMIN); } else { $feed->set_autodiscovery_cache_duration(9999999999); $feed->set_cache_duration(9999999999); } // CHARSET if (!defined('CHARSET')) { define('CHARSET', 'UTF-8'); } if (!defined('SPNRBOX_CHARSET')) { define('SPNRBOX_CHARSET', 'UTF-8'); } if (SPNRBOX_CHARSET == 'default') { $charset = CHARSET; } else { $charset = SPNRBOX_CHARSET; } $feed->set_cache_location(WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/cache'); $feed->set_favicon_handler(RELATIVE_WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/handler_image.php'); $feed->set_image_handler(RELATIVE_WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/handler_image.php'); $feed->set_output_encoding($charset); // BOOKMARKS $bookmarks = array(); if (SPNRBOX_SHOWSOCIALBOOKMARKS) { $socialBookmarks = preg_split("/\r?\n/", SPNRBOX_SOCIALBOOKMARKS); $cntBookmark = 0; foreach ($socialBookmarks as $row) { $row = trim($row); if (preg_match("/\\|/", $row)) { list($bookmarkTitle, $bookmarkUrl, $bookmarkImg, $bookmarkEncodeTitle, $bookmarkEncodeUrl) = preg_split("/\\|/", $row, 5); $bookmarkTitle = trim($bookmarkTitle); $bookmarkUrl = trim($bookmarkUrl); $bookmarkImg = trim($bookmarkImg); $bookmarkEncodeTitle = trim($bookmarkEncodeTitle); $bookmarkEncodeUrl = trim($bookmarkEncodeUrl); if (!empty($bookmarkTitle) && !empty($bookmarkUrl) && !empty($bookmarkImg) && isset($bookmarkEncodeTitle) && isset($bookmarkEncodeUrl)) { $bookmarks[$cntBookmark]['bookmarkTitle'] = $bookmarkTitle; $bookmarks[$cntBookmark]['bookmarkUrl'] = $bookmarkUrl; $bookmarks[$cntBookmark]['bookmarkImg'] = $bookmarkImg; $bookmarks[$cntBookmark]['bookmarkEncodeTitle'] = $bookmarkEncodeTitle == 1 ? 1 : 0; $bookmarks[$cntBookmark]['bookmarkEncodeUrl'] = $bookmarkEncodeUrl == 1 ? 1 : 0; $cntBookmark++; } } } } // THEMA ZUM FEED if (WCF::getUser()->getPermission('user.board.canViewThreadToFeed') && SPNRBOX_FEEDTOTHREAD) { require_once WBB_DIR . 'lib/data/board/Board.class.php'; $accessibleBoards = explode(',', Board::getAccessibleBoards()); $selectiveBoards = explode(',', SPNRBOX_FEEDTOTHREADBOARDID); $boardStructur = WCF::getCache()->get('board', 'boardStructure'); if (count($selectiveBoards) != 0) { $this->spnrbData['boardsForm'] = count($selectiveBoards) == 1 ? 'button' : 'list'; $cntBoards = 0; $prefix = ''; foreach ($selectiveBoards as $k => $v) { $tmp = Board::getBoard($v); if ($tmp->boardType < 2 && in_array($v, $accessibleBoards)) { $this->spnrbData['boards'][$cntBoards]['id'] = $tmp->boardID; $this->spnrbData['boards'][$cntBoards]['type'] = $tmp->boardType; $prefix = ''; foreach ($boardStructur as $boardDepth => $boardKey) { if (in_array($this->spnrbData['boards'][$cntBoards]['id'], $boardKey)) { $prefix = str_repeat('--', $boardDepth); break; } } $this->spnrbData['boards'][$cntBoards]['title'] = ($prefix != '' ? $prefix : '') . ' ' . $tmp->title; $cntBoards++; } } } else { $this->spnrbData['boardsForm'] = ''; } } $feedUrls = preg_split('/\\r?\\n/', SPNRBOX_FEEDS); $cntFeedUrl = 0; foreach ($feedUrls as $k => $feedurl) { $feedurl = trim($feedurl); if (empty($feedurl)) { continue; } $feed->set_feed_url($feedurl); $feed->init(); $feed->handle_content_type(); if (SPNRBOX_FILTERON) { $feed->set_filter(SPNRBOX_FILTERWORDS, SPNRBOX_FILTERMODE); } if (!($favicon = $feed->get_favicon())) { $favicon = RELATIVE_WBB_DIR . 'icon/alternate_favicon.png'; } $this->spnrbData['spnrFeeds'][$cntFeedUrl]['id'] = $cntFeedUrl; $this->spnrbData['spnrFeeds'][$cntFeedUrl]['link'] = $feed->get_permalink(); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['title'] = $feed->get_title(); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['favicon'] = $favicon; $this->spnrbData['spnrFeeds'][$cntFeedUrl]['xml'] = $feedurl; $items = $feed->get_items(); if (SPNRBOX_FILTERON) { $items = $feed->filter($items); } $i = 0; foreach ($items as $item) { if ($i >= SPNRBOX_NUMOFFEEDS) { break; } $iFeed = $item->get_feed(); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['id'] = $i; $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['link'] = $item->get_permalink(); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['title'] = html_entity_decode($item->get_title(), ENT_QUOTES, $charset); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['content'] = SPNRBOX_FILTERON ? $this->highlight(SPNRBOX_FILTERWORDS, $item->get_content(), SPNRBOX_FILTERCLASS) : $item->get_content(); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['date'] = $item->get_date('d.m.Y - H:i:s'); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['bookmarks'] = array(); if (count($bookmarks)) { $x = 0; foreach ($bookmarks as $bookmark) { $search[0] = "/\\{TITLE\\}/"; $search[1] = "/\\{URL\\}/"; $replace[0] = $bookmark['bookmarkEncodeTitle'] == 1 ? rawurlencode(html_entity_decode($item->get_title(), ENT_QUOTES, $charset)) : html_entity_decode($item->get_title()); $replace[1] = $bookmark['bookmarkEncodeUrl'] == 1 ? rawurlencode(html_entity_decode($item->get_permalink(), ENT_QUOTES, $charset)) : html_entity_decode($item->get_permalink()); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['bookmarks'][$x]['bookmarkTitle'] = htmlspecialchars($bookmark['bookmarkTitle']); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['bookmarks'][$x]['bookmarkUrl'] = preg_replace($search, $replace, html_entity_decode($bookmark['bookmarkUrl'])); $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['bookmarks'][$x]['bookmarkImg'] = RELATIVE_WBB_DIR . "icon/" . $bookmark['bookmarkImg']; $x++; } } if ($enclosure = $item->get_enclosure()) { $this->spnrbData['spnrFeeds'][$cntFeedUrl]['iFeed'][$i]['enclosure'] = '<p>' . $enclosure->native_embed(array('audio' => RELATIVE_WBB_DIR . 'icon/place_audio.png', 'video' => RELATIVE_WBB_DIR . 'icon/place_video.png', 'mediaplayer' => RELATIVE_WBB_DIR . 'icon/mediaplayer.swf', 'alt' => '<img src="' . RELATIVE_WBB_DIR . 'icon/mini_podcast.png" class="download" border="0" title="Download Podcast (' . $enclosure->get_extension() . '; ' . $enclosure->get_size() . ' MB)" />', 'altclass' => 'download')) . '</p>'; } $i++; } $cntFeedUrl++; } } }
/** * Reads the given parameters. */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['threadID'])) { $this->threadID = intval($_REQUEST['threadID']); } else { if (isset($_REQUEST['threadid'])) { $this->threadID = intval($_REQUEST['threadid']); } } // wbb2 style if (isset($_REQUEST['messageID'])) { $this->postID = intval($_REQUEST['messageID']); } else { if (isset($_REQUEST['postID'])) { $this->postID = intval($_REQUEST['postID']); } else { if (isset($_REQUEST['postid'])) { $this->postID = intval($_REQUEST['postid']); } } } // wbb2 style if (isset($_REQUEST['action'])) { $this->action = $_REQUEST['action']; } if (isset($_REQUEST['highlight'])) { $this->highlight = $_REQUEST['highlight']; } // get thread $this->thread = new ViewableThread($this->threadID, null, $this->postID); $this->threadID = $this->thread->threadID; // get board $this->board = Board::getBoard($this->thread->boardID); if ($this->board->postSortOrder) { $this->sortOrder = $this->board->postSortOrder; } if ($this->board->enableRating != -1) { $this->enableRating = $this->board->enableRating; } // posts per page if ($this->board->postsPerPage) { $this->itemsPerPage = $this->board->postsPerPage; } if (WCF::getUser()->postsPerPage) { $this->itemsPerPage = WCF::getUser()->postsPerPage; } // enter thread $this->thread->enter($this->board); // init post list $this->postList = new ThreadPostList($this->thread, $this->board); $this->postList->sqlOrderBy = 'post.time ' . $this->sortOrder; // handle jump to if ($this->action == 'lastPost') { $this->goToLastPost(); } if ($this->action == 'firstNew') { $this->goToFirstNewPost(); } if ($this->postID) { $this->goToPost(); } // handle subscriptions if (WCF::getUser()->userID) { $this->thread->updateSubscription(); if ($this->thread->subscribed) { WCF::getSession()->unregister('lastSubscriptionsStatusUpdateTime'); } } // handle parameters and special actions $this->handleRating(); }
/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { if ($eventName == 'readParameters') { // handle special search options here $action = ''; if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } if (empty($action)) { return; } // get accessible board ids require_once WBB_DIR . 'lib/data/board/Board.class.php'; $boardIDArray = Board::getAccessibleBoardIDArray(array('canViewBoard', 'canEnterBoard', 'canReadThread')); foreach ($boardIDArray as $key => $boardID) { if (WCF::getUser()->isIgnoredBoard($boardID)) { unset($boardIDArray[$key]); } else { if (!Board::getBoard($boardID)->searchable) { unset($boardIDArray[$key]); } } } if (!count($boardIDArray)) { return; } switch ($action) { case 'unread': $sql = "SELECT\t\tthread.threadID\n\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_thread thread\n\t\t\t\t\t\tWHERE\t\tthread.boardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\t\t\tAND thread.lastPostTime > " . WCF::getUser()->getLastMarkAllAsReadTime() . "\n\t\t\t\t\t\t\t\t" . (WCF::getUser()->userID ? "\n\t\t\t\t\t\t\t\tAND thread.lastPostTime > IFNULL((\n\t\t\t\t\t\t\t\t\tSELECT\tlastVisitTime\n\t\t\t\t\t\t\t\t\tFROM \twbb" . WBB_N . "_thread_visit\n\t\t\t\t\t\t\t\t\tWHERE \tthreadID = thread.threadID\n\t\t\t\t\t\t\t\t\t\tAND userID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\t\t), 0)\n\t\t\t\t\t\t\t\tAND thread.lastPostTime > IFNULL((\n\t\t\t\t\t\t\t\t\tSELECT\tlastVisitTime\n\t\t\t\t\t\t\t\t\tFROM \twbb" . WBB_N . "_board_visit\n\t\t\t\t\t\t\t\t\tWHERE \tboardID = thread.boardID\n\t\t\t\t\t\t\t\t\t\tAND userID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\t\t), 0)\n\t\t\t\t\t\t\t\t" : '') . "\n\t\t\t\t\t\t\t\tAND thread.isDeleted = 0\n\t\t\t\t\t\t\t\tAND thread.isDisabled = 0\n\t\t\t\t\t\t\t\t" . (count(WCF::getSession()->getVisibleLanguageIDArray()) ? " AND languageID IN (" . implode(',', WCF::getSession()->getVisibleLanguageIDArray()) . ")" : "") . "\n\t\t\t\t\t\t\t\tAND thread.movedThreadID = 0\n\t\t\t\t\t\tORDER BY\tthread.lastPostTime DESC"; break; case 'newPostsSince': $since = TIME_NOW; if (isset($_REQUEST['since'])) { $since = intval($_REQUEST['since']); } $sql = "SELECT\t\tthread.threadID\n\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_thread thread\n\t\t\t\t\t\tWHERE\t\tthread.boardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\t\t\tAND thread.lastPostTime > " . $since . "\n\t\t\t\t\t\t\t\tAND thread.isDeleted = 0\n\t\t\t\t\t\t\t\tAND thread.isDisabled = 0\n\t\t\t\t\t\t\t\t" . (count(WCF::getSession()->getVisibleLanguageIDArray()) ? " AND languageID IN (" . implode(',', WCF::getSession()->getVisibleLanguageIDArray()) . ")" : "") . "\n\t\t\t\t\t\t\t\tAND thread.movedThreadID = 0\n\t\t\t\t\t\tORDER BY\tthread.lastPostTime DESC"; break; case 'unreplied': $sql = "SELECT\t\tthreadID\n\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_thread\n\t\t\t\t\t\tWHERE\t\tboardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t\t\t\t\tAND movedThreadID = 0\n\t\t\t\t\t\t\t\t" . (count(WCF::getSession()->getVisibleLanguageIDArray()) ? " AND languageID IN (" . implode(',', WCF::getSession()->getVisibleLanguageIDArray()) . ")" : "") . "\n\t\t\t\t\t\t\t\tAND replies = 0\n\t\t\t\t\t\tORDER BY\tlastPostTime DESC"; break; case '24h': $sql = "SELECT\t\tthreadID\n\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_thread\n\t\t\t\t\t\tWHERE\t\tboardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\t\t\tAND lastPostTime > " . (TIME_NOW - 86400) . "\n\t\t\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t\t\t\t\t" . (count(WCF::getSession()->getVisibleLanguageIDArray()) ? " AND languageID IN (" . implode(',', WCF::getSession()->getVisibleLanguageIDArray()) . ")" : "") . "\n\t\t\t\t\t\t\t\tAND movedThreadID = 0\n\t\t\t\t\t\tORDER BY\tlastPostTime DESC"; break; default: return; } // build search hash $searchHash = StringUtil::getHash($sql); // execute query $matches = array(); $result = WCF::getDB()->sendQuery($sql, 1000); while ($row = WCF::getDB()->fetchArray($result)) { $matches[] = array('messageID' => $row['threadID'], 'messageType' => 'post'); } // result is empty if (count($matches) == 0) { throw new NamedUserException(WCF::getLanguage()->get('wbb.search.error.noMatches')); } // save result in database $searchData = array('packageID' => PACKAGE_ID, 'query' => '', 'result' => $matches, 'additionalData' => array('post' => array('findThreads' => 1)), 'sortOrder' => 'DESC', 'sortField' => 'time', 'types' => array('post')); $searchData = serialize($searchData); $sql = "INSERT INTO\twcf" . WCF_N . "_search\n\t\t\t\t\t\t(userID, searchData, searchDate, searchType, searchHash)\n\t\t\t\tVALUES\t\t(" . WCF::getUser()->userID . ",\n\t\t\t\t\t\t'" . escapeString($searchData) . "',\n\t\t\t\t\t\t" . TIME_NOW . ",\n\t\t\t\t\t\t'messages',\n\t\t\t\t\t\t'" . $searchHash . "')"; WCF::getDB()->sendQuery($sql); $searchID = WCF::getDB()->getInsertID(); // forward to result page HeaderUtil::redirect('index.php?form=Search&searchID=' . $searchID . SID_ARG_2ND_NOT_ENCODED); exit; } else { if ($eventName == 'readFormParameters') { if (isset($_POST['findThreads'])) { $this->findThreads = intval($_POST['findThreads']); } if (isset($_REQUEST['findUserThreads'])) { $this->findUserThreads = intval($_REQUEST['findUserThreads']); } if ($this->findUserThreads == 1) { $this->findThreads = 1; } // handle findThreads option if ($this->findThreads == 1 && (!count($eventObj->types) || in_array('post', $eventObj->types))) { // remove all other searchable message types // findThreads only supports post search $eventObj->types = array('post'); } else { $this->findThreads = 0; } } else { if ($eventName == 'assignVariables') { if ($eventObj instanceof SearchResultPage) { $html = '<div class="floatedElement"> <label for="findThreads">' . WCF::getLanguage()->get('wbb.search.results.display') . '</label> <select name="findThreads" id="findThreads"> <option value="0">' . WCF::getLanguage()->get('wbb.search.results.display.post') . '</option> <option value="1"' . ($eventObj->additionalData['post']['findThreads'] == 1 ? ' selected="selected"' : '') . '>' . WCF::getLanguage()->get('wbb.search.results.display.thread') . '</option> </select> </div>'; WCF::getTPL()->append('additionalDisplayOptions', $html); } else { $html = '<div class="floatedElement"> <label for="findThreads">' . WCF::getLanguage()->get('wbb.search.results.display') . '</label> <select name="findThreads" id="findThreads"> <option value="0"' . ($this->findThreads == 0 ? ' selected="selected"' : '') . '>' . WCF::getLanguage()->get('wbb.search.results.display.post') . '</option> <option value="1"' . ($this->findThreads == 1 ? ' selected="selected"' : '') . '>' . WCF::getLanguage()->get('wbb.search.results.display.thread') . '</option> </select> </div>'; WCF::getTPL()->append('additionalDisplayOptions', $html); WCF::getTPL()->append('additionalAuthorOptions', '<label><input type="checkbox" name="findUserThreads" value="1"' . ($this->findUserThreads == 1 ? ' checked="checked"' : '') . '/> ' . WCF::getLanguage()->get('wbb.search.findUserThreads') . '</label>'); } } } } }