/** * Execute plugin * * @param array $permissions Moderator permissions * @return @e string */ public function executePlugin($permissions) { //----------------------------------------- // Check permissions //----------------------------------------- if (!$this->canView($permissions)) { return ''; } //----------------------------------------- // Get forum class //----------------------------------------- if (!$this->registry->isClassLoaded('topics')) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums'); $this->registry->setClass('topics', new $classToLoad($this->registry)); } //----------------------------------------- // Get results //----------------------------------------- $st = intval($this->request['st']); $_filters = $this->_getFilters(); $_filters = array_merge($_filters, array('postType' => array('sdelete', 'pdelete', 'oktoremove'), 'getCount' => true, 'sortField' => 'pid', 'sortOrder' => 'desc', 'parse' => true, 'limit' => 10, 'offset' => $st)); $this->registry->getClass('topics')->setPermissionData(); $posts = $this->registry->getClass('topics')->getPosts($_filters); $total = $this->registry->getClass('topics')->getPostsCount(); /* Got soft delete pids? */ $other_data = array(); if (is_array($posts) and count($posts)) { $other_data = IPSDeleteLog::fetchEntries(array_keys($posts), 'post', false); } //----------------------------------------- // Page links //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => $total, 'itemsPerPage' => 10, 'currentStartValue' => $st, 'baseUrl' => "app=core&module=modcp&fromapp=forums&tab=deletedposts")); return $this->registry->output->getTemplate('modcp')->deletedPosts($posts, $other_data, $pages); }
/** * Execute plugin * * @param array $permissions Moderator permissions * @return @e string */ public function executePlugin($permissions) { //----------------------------------------- // Check permissions //----------------------------------------- if (!$this->canView($permissions)) { return ''; } //----------------------------------------- // Get forum class //----------------------------------------- if (!$this->registry->isClassLoaded('topics')) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums'); $this->registry->setClass('topics', new $classToLoad($this->registry)); } //----------------------------------------- // Get forum class //----------------------------------------- $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('forums') . '/modules_public/forums/forums.php', 'public_forums_forums_forums'); $this->forums = new $classToLoad($this->registry); $this->forums->makeRegistryShortcuts($this->registry); $st = intval($this->request['st']); $_filters = $this->_getFilters(); $_filters = array_merge($_filters, array('topicType' => array('sdelete', 'pdelete', 'oktoremove'), 'getCount' => true, 'sortField' => 'tid', 'sortOrder' => 'desc', 'limit' => 10, 'offset' => $st)); $this->registry->getClass('topics')->setPermissionData(); $topics = $this->registry->getClass('topics')->getTopics($_filters); $total = $this->registry->getClass('topics')->getTopicsCount(); $final = array(); //----------------------------------------- // Format data //----------------------------------------- if (count($topics)) { foreach ($topics as $tid => $topic) { /* Have to preserve original forum id for linked topics */ if ($topic['state'] == 'link') { $_originalForum = $topic['forum_id']; } $topic = $this->_checkPermissions($topic); $topic = $this->forums->renderEntry($topic); $topic['forum'] = $this->registry->class_forums->getForumById($topic['forum_id']); if ($topic['state'] == 'link') { $topic['_toForum'] = $this->registry->class_forums->getForumById($_originalForum); } $final[$tid] = $topic; } } $other_data = array(); if (is_array($topics) and count($topics)) { $other_data = IPSDeleteLog::fetchEntries(array_keys($topics), 'topic', false); } //----------------------------------------- // Page links //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => $total, 'itemsPerPage' => 10, 'currentStartValue' => $st, 'baseUrl' => "app=core&module=modcp&fromapp=forums&tab=deletedtopics")); return $this->registry->output->getTemplate('modcp')->deletedTopics($final, $other_data, $pages); }
/** * Builds an array of forum data for use in the output template * * @return array */ public function renderForum() { //----------------------------------------- // INIT //----------------------------------------- $this->request['page'] = $this->request['changefilters'] ? 0 : (isset($this->request['page']) ? intval($this->request['page']) : 0); $announce_data = array(); $topic_data = array(); $other_data = array(); $multi_mod_data = array(); $footer_filter = array(); $member_ids = array(); //----------------------------------------- // Show? //----------------------------------------- if (isset($this->request['show']) and $this->request['show'] == 'sinceLastVisit') { $this->request['prune_day'] = 200; } //----------------------------------------- // Are we actually a moderator for this forum? //----------------------------------------- $mod = $this->memberData['forumsModeratorData']; if (!$this->memberData['g_is_supmod']) { if (!isset($mod[$this->forum['id']]) or !is_array($mod[$this->forum['id']])) { $this->memberData['is_mod'] = 0; } } //----------------------------------------- // Announcements //----------------------------------------- if (is_array($this->registry->cache()->getCache('announcements')) and count($this->registry->cache()->getCache('announcements'))) { $announcements = array(); foreach ($this->registry->cache()->getCache('announcements') as $announce) { $order = $announce['announce_start'] ? $announce['announce_start'] . ',' . $announce['announce_id'] : $announce['announce_id']; if ($announce['announce_forum'] == '*') { $announcements[$order] = $announce; } else { if (strstr(',' . $announce['announce_forum'] . ',', ',' . $this->forum['id'] . ',')) { $announcements[$order] = $announce; } } } if (count($announcements)) { //----------------------------------------- // sort by start date //----------------------------------------- krsort($announcements); foreach ($announcements as $announce) { if ($announce['announce_start']) { $announce['announce_start'] = $this->lang->getDate($announce['announce_start'], 'date'); } else { $announce['announce_start'] = '--'; } $announce['announce_title'] = IPSText::stripslashes($announce['announce_title']); $announce['forum_id'] = $this->forum['id']; $announce['announce_views'] = intval($announce['announce_views']); $announce_data[] = $announce; $member_ids[$announce['member_id']] = $announce['member_id']; } $this->forum['_showAnnouncementsBar'] = 1; } } //----------------------------------------- // Read topics //----------------------------------------- $First = $this->registry->class_forums->pageToSt(intval($this->request['page'])); //----------------------------------------- // Sort options //----------------------------------------- $cookie_prune = IPSCookie::get($this->forum['id'] . "_prune_day"); $cookie_sort = IPSCookie::get($this->forum['id'] . "_sort_key"); $cookie_sortb = IPSCookie::get($this->forum['id'] . "_sort_by"); $cookie_fill = IPSCookie::get($this->forum['id'] . "_topicfilter"); $prune_value = $this->selectVariable(array(1 => !empty($this->request['prune_day']) ? $this->request['prune_day'] : NULL, 2 => !empty($cookie_prune) ? $cookie_prune : NULL, 3 => $this->forum['prune'], 4 => '100')); $sort_key = $this->selectVariable(array(1 => !empty($this->request['sort_key']) ? $this->request['sort_key'] : NULL, 2 => !empty($cookie_sort) ? $cookie_sort : NULL, 3 => $this->forum['sort_key'], 4 => 'last_post')); $sort_by = $this->selectVariable(array(1 => !empty($this->request['sort_by']) ? $this->request['sort_by'] : NULL, 2 => !empty($cookie_sortb) ? $cookie_sortb : NULL, 3 => $this->forum['sort_order'], 4 => 'Z-A')); $topicfilter = $this->selectVariable(array(1 => !empty($this->request['topicfilter']) ? $this->request['topicfilter'] : NULL, 2 => !empty($cookie_fill) ? $cookie_fill : NULL, 3 => $this->forum['topicfilter'], 4 => 'all')); if (!empty($this->request['remember'])) { if ($this->request['prune_day']) { IPSCookie::set($this->forum['id'] . "_prune_day", $this->request['prune_day']); } if ($this->request['sort_key']) { IPSCookie::set($this->forum['id'] . "_sort_key", $this->request['sort_key']); } if ($this->request['sort_by']) { IPSCookie::set($this->forum['id'] . "_sort_by", $this->request['sort_by']); } if ($this->request['topicfilter']) { IPSCookie::set($this->forum['id'] . "_topicfilter", $this->request['topicfilter']); } } //----------------------------------------- // Figure out sort order, day cut off, etc //----------------------------------------- $Prune = $prune_value < 100 ? time() - $prune_value * 60 * 60 * 24 : (($prune_value == 200 and $this->memberData['member_id']) ? $this->memberData['last_visit'] : 0); $sort_keys = array('last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views'); $prune_by_day = array('1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', '200' => 'show_last_visit'); $sort_by_keys = array('Z-A' => 'descending_order', 'A-Z' => 'ascending_order'); $filter_keys = array('all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved'); if ($this->memberData['member_id']) { $filter_keys['istarted'] = 'topicfilter_istarted'; $filter_keys['ireplied'] = 'topicfilter_ireplied'; } //----------------------------------------- // check for any form funny business by wanna-be hackers //----------------------------------------- if (!isset($filter_keys[$topicfilter]) or !isset($sort_keys[$sort_key]) or !isset($prune_by_day[$prune_value]) or !isset($sort_by_keys[strtoupper($sort_by)])) { $this->registry->getClass('output')->showError('forums_bad_filter', 10339); } $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC'; //----------------------------------------- // If sorting by starter, add secondary.. //----------------------------------------- $sort_key_chk = $sort_key; if ($sort_key == 'starter_name') { $sort_key = "starter_name {$r_sort_by}, t.last_post DESC"; $r_sort_by = ''; } //----------------------------------------- // Additional queries? //----------------------------------------- $add_query_array = array(); $add_query = ""; switch ($topicfilter) { case 'all': break; case 'open': $add_query_array[] = "t.state='open'"; break; case 'hot': $add_query_array[] = "t.state='open' AND t.posts + 1 >= " . intval($this->settings['hot_topic']); break; case 'locked': $add_query_array[] = "t.state='closed'"; break; case 'moved': $add_query_array[] = "t.state='link'"; break; case 'poll': $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)"; break; default: break; } if (!$this->memberData['g_other_topics'] or $topicfilter == 'istarted' or !$this->forum['can_view_others'] and !$this->memberData['is_mod']) { $add_query_array[] = "t.starter_id='" . $this->memberData['member_id'] . "'"; } /* Answered / unanswered */ if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) { if ($this->request['answered'] == 'true') { $add_query_array[] = 't.topic_answered_pid != 0'; } else { if ($this->request['answered'] == 'false') { $add_query_array[] = 't.topic_answered_pid = 0'; } } } $_SQL_EXTRA = ''; $_SQL_APPROVED = ''; $_SQL_AGE_PRUNE = ''; if (count($add_query_array)) { $_SQL_EXTRA = ' AND ' . implode(' AND ', $add_query_array); } //----------------------------------------- // Moderator? //----------------------------------------- $this->request['modfilter'] = isset($this->request['modfilter']) ? $this->request['modfilter'] : ''; $modFilter = ''; if ($this->memberData['is_mod']) { if ($this->request['modfilter'] == 'unapproved') { $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('hidden'), 't.') . ' OR t.topic_queuedposts'; } elseif ($this->permissions['TopicSoftDeleteSee']) { if ($this->request['modfilter'] == 'hidden') { $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted'), 't.') . ' OR t.topic_deleted_posts'; } else { $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden', 'sdeleted'), 't.'); } } else { $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden'), 't.'); } } else { if ($this->permissions['TopicSoftDeleteSee']) { $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'sdeleted'), 't.'); } else { $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible'), 't.'); } } if ($modFilter) { $_SQL_APPROVED = ' AND (' . $modFilter . ')'; } if ($Prune) { if ($prune_value == 200) { /* Just new content, don't show pinned, please */ if ($modFilter) { $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune} AND ( {$modFilter} ) )"; } else { $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune})"; } } else { if ($modFilter) { $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune} AND ( {$modFilter} ) )"; } else { $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune})"; } } } //----------------------------------------- // Query the database to see how many topics there are in the forum //----------------------------------------- if ($topicfilter == 'ireplied') { //----------------------------------------- // Checking topics we've replied to? //----------------------------------------- $this->DB->build(array('select' => 'COUNT(' . $this->DB->buildDistinct('p.topic_id') . ') as max', 'from' => array('topics' => 't'), 'where' => "t.forum_id={$this->forum['id']} AND p.author_id=" . $this->memberData['member_id'] . " AND p.new_topic=0" . $_SQL_APPROVED . $_SQL_AGE_PRUNE, 'add_join' => array(array('from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid')))); $this->DB->execute(); $total_possible = $this->DB->fetch(); } else { if ($_SQL_EXTRA or $_SQL_AGE_PRUNE or $this->request['modfilter']) { $this->DB->build(array('select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA)); $this->DB->execute(); $total_possible = $this->DB->fetch(); } else { $total_possible['max'] = $this->memberData['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics']; if ($this->permissions['TopicSoftDeleteSee'] and $this->forum['deleted_topics']) { $total_possible['max'] += intval($this->forum['deleted_topics']); } $Prune = 0; } } //----------------------------------------- // Generate the forum page span links //----------------------------------------- $_extraStuff = ''; if ($this->request['modfilter']) { $_extraStuff .= "&modfilter=" . $this->request['modfilter']; } if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) { $_extraStuff .= "&answered=" . $this->request['answered']; } $this->forum['SHOW_PAGES'] = $this->registry->getClass('output')->generatePagination(array('totalItems' => $total_possible['max'], 'itemsPerPage' => $this->settings['display_max_topics'], 'currentStartValue' => intval($this->request['page']), 'isPagesMode' => true, 'seoTitle' => $this->forum['name_seo'], 'disableSinglePage' => false, 'baseUrl' => "showforum=" . $this->forum['id'] . "&prune_day={$prune_value}&sort_by={$sort_by}&sort_key={$sort_key_chk}&topicfilter={$topicfilter}{$_extraStuff}")); //----------------------------------------- // Start printing the page //----------------------------------------- $other_data = array('forum_data' => $this->forum, 'hasMore' => $this->registry->class_forums->pageToSt($this->request['page']) + $this->settings['display_max_topics'] > $total_possible['max'] ? false : true, 'can_edit_topics' => $this->can_edit_topics, 'can_open_topics' => $this->can_open_topics, 'can_close_topics' => $this->can_close_topics, 'can_move_topics' => $this->can_move_topics); $total_topics_printed = 0; //----------------------------------------- // Get main topics //----------------------------------------- $topic_array = array(); $topic_ids = array(); $topic_sort = ""; //----------------------------------------- // Cut off? //----------------------------------------- $modAll = ($this->memberData['g_is_supmod'] or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($this->memberData['forumsModeratorData'][$this->forum['id']]['delete_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['move_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['split_merge'])); $parse_dots = 1; if ($topicfilter == 'ireplied') { //----------------------------------------- // Checking topics we've replied to? // No point in getting dots again... //----------------------------------------- $parse_dots = 0; $_joins = array(array('select' => 't.*', 'from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid AND p.author_id=' . $this->memberData['member_id'])); if ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) { $_joins[] = $this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid')); } // For some reason, mySQL doesn't like the distinct + t.* being in reverse order... $this->DB->build(array('select' => $this->DB->buildDistinct('p.author_id'), 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . " AND p.new_topic=0", 'order' => "t.pinned desc,{$topic_sort} t.{$sort_key} {$r_sort_by}", 'limit' => array(intval($First), intval($this->settings['display_max_topics'])), 'add_join' => $_joins)); $this->DB->execute(); } else { $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA, 'order' => 't.pinned DESC, ' . $topic_sort . ' t.' . $sort_key . ' ' . $r_sort_by, 'limit' => array(intval($First), $this->settings['display_max_topics']), 'add_join' => ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) ? array($this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'))) : array())); $this->DB->execute(); } while ($t = $this->DB->fetch()) { /* Should we display the moderate checkbox for this post? */ $t['moddable'] = FALSE; if ($modAll or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($t['pinned'] == 0 and $this->memberData['forumsModeratorData'][$this->forum['id']]['pin_topic'] or $t['pinned'] == 1 and $this->memberData['forumsModeratorData'][$this->forum['id']]['unpin_topic'] or $t['state'] == 'open' and $this->memberData['forumsModeratorData'][$this->forum['id']]['close_topic'] or $t['state'] == 'closed' and $this->memberData['forumsModeratorData'][$this->forum['id']]['open_topic'])) { $t['moddable'] = TRUE; } /* Add to array */ $topic_array[$t['tid']] = $t; $topic_ids[$t['tid']] = $t['tid']; if ($t['last_poster_id']) { $member_ids[$t['last_poster_id']] = $t['last_poster_id']; } if ($t['starter_id']) { $member_ids[$t['starter_id']] = $t['starter_id']; } } ksort($topic_ids); //----------------------------------------- // Are we dotty? //----------------------------------------- if ($this->settings['show_user_posted'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) { $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), ''); $this->DB->build(array('select' => $this->DB->buildDistinct('topic_id'), 'from' => 'posts', 'where' => $_queued . ' AND author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')')); $this->DB->execute(); while ($p = $this->DB->fetch()) { if (is_array($topic_array[$p['topic_id']])) { $topic_array[$p['topic_id']]['author_id'] = $this->memberData['member_id']; } } } //----------------------------------------- // Get needed members //----------------------------------------- if (count($member_ids)) { $_members = IPSMember::load($member_ids); //----------------------------------------- // Add member data to announcements //----------------------------------------- $new_announces = array(); foreach ($announce_data as $announce) { $announce = array_merge($announce, IPSMember::buildDisplayData($_members[$announce['member_id']])); $new_announces[] = $announce; } $announce_data = $new_announces; } //----------------------------------------- // Show meh the topics! //----------------------------------------- $adCodeSet = false; foreach ($topic_array as $topic) { /* Add member */ if ($topic['last_poster_id']) { $topic = array_merge(IPSMember::buildDisplayData($_members[$topic['last_poster_id']]), $topic); } else { $topic = array_merge(IPSMember::buildProfilePhoto(array()), $topic); } if ($topic['starter_id']) { $topic['_starter'] = $_members[$topic['starter_id']]; } /* AD Code */ if ($this->registry->getClass('IPSAdCode')->userCanViewAds() && !$adCodeSet) { $topic['_adCode'] = $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_forum_view_topic_code'); if ($topic['_adCode']) { $adCodeSet = true; } } if ($topic['pinned']) { $this->pinned_topic_count++; } $topic_data[$topic['tid']] = $this->renderEntry($topic); $total_topics_printed++; } //----------------------------------------- // Finish off the rest of the page $filter_keys[$topicfilter])) //----------------------------------------- $sort_by_html = ""; $sort_key_html = ""; $prune_day_html = ""; $filter_html = ""; foreach ($sort_by_keys as $k => $v) { $sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n"; } foreach ($sort_keys as $k => $v) { $sort_key_html .= $k == $sort_key_chk ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_keys[$k]]}</option>\n"; } foreach ($prune_by_day as $k => $v) { $prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected='selected'>{$this->lang->words[$prune_by_day[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$prune_by_day[$k]]}</option>\n"; } foreach ($filter_keys as $k => $v) { $filter_html .= $k == $topicfilter ? "<option value='{$k}' selected='selected'>{$this->lang->words[$filter_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$filter_keys[$k]]}</option>\n"; } $footer_filter['sort_by'] = $sort_key_html; $footer_filter['sort_order'] = $sort_by_html; $footer_filter['sort_prune'] = $prune_day_html; $footer_filter['topic_filter'] = $filter_html; if ($this->memberData['is_mod']) { $count = 0; $other_pages = 0; if ($this->request['selectedtids'] != "") { $tids = explode(",", $this->request['selectedtids']); if (is_array($tids) and count($tids)) { foreach ($tids as $tid) { if ($tid != '') { if (!isset($topic_array[$tid])) { $other_pages++; } $count++; } } } } $this->lang->words['f_go'] .= " ({$count})"; if ($other_pages) { $this->lang->words['f_go'] .= " ({$other_pages} " . $this->lang->words['jscript_otherpage'] . ")"; } } //----------------------------------------- // Multi-moderation? //----------------------------------------- if ($this->memberData['is_mod']) { $mm_array = $this->registry->getClass('class_forums')->getMultimod($this->forum['id']); if (is_array($mm_array) and count($mm_array)) { foreach ($mm_array as $m) { $multi_mod_data[] = $m; } } } //----------------------------------------- // Need to update topics? //----------------------------------------- if (count($this->update_topics_open)) { $this->DB->update('topics', array('state' => 'open'), 'tid IN (' . implode(",", $this->update_topics_open) . ')'); } if (count($this->update_topics_close)) { $this->DB->update('topics', array('state' => 'closed'), 'tid IN (' . implode(",", $this->update_topics_close) . ')'); } /* Got soft delete tids? */ if (is_array($this->_sdTids) and count($this->_sdTids)) { $other_data['sdData'] = IPSDeleteLog::fetchEntries($this->_sdTids, 'topic', false); } /* Fetch follow data */ $other_data['follow_data'] = $this->_like->render('summary', $this->forum['id']); return array('announce_data' => $announce_data, 'topic_data' => $topic_data, 'other_data' => $other_data, 'multi_mod_data' => $multi_mod_data, 'footer_filter' => $footer_filter, 'active_users' => $this->_generateActiveUserData()); }
/** * Formats / grabs extra data for results * Takes an array of IDS (can be IDs from anything) and returns an array of expanded data. * * @param array $ids Ids * @param array $followData Retrieve the follow meta data * @return array */ public function processResults($ids, $followData = array()) { /* INIT */ $sort_by = IPSSearchRegistry::get('in.search_sort_by'); $sort_order = IPSSearchRegistry::get('in.search_sort_order'); $search_term = IPSSearchRegistry::get('in.clean_search_term'); $content_title_only = IPSSearchRegistry::searchTitleOnly(); $_post_joins = array(); $members = array(); $results = array(); $topicIds = array(); $dots = array(); $sortKey = ''; $sortType = ''; $_sdTids = array(); $_sdPids = array(); /* Set up some basic permissions */ $permissions['PostSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts(0); $permissions['TopicSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics(0); $permissions['canQueue'] = $this->registry->getClass('class_forums')->canQueuePosts(0); $permissions['SoftDeleteReason'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteReason(0); $permissions['SoftDeleteContent'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteContent(0); $permissions['PostSoftDeleteRestore'] = $this->registry->getClass('class_forums')->can_Un_SoftDeletePosts(0); $permissions['TopicSoftDeleteRestore'] = $this->registry->getClass('class_forums')->can_Un_SoftDeleteTopics(0); /* Got some? */ if (count($ids)) { /* Cache? */ if (IPSContentCache::isEnabled()) { if (IPSContentCache::fetchSettingValue('post')) { $_post_joins[] = IPSContentCache::join('post', 'p.' . $this->table['pid']); } if (IPSContentCache::fetchSettingValue('sig')) { $_post_joins[] = IPSContentCache::join('sig', 'p.' . $this->table['author_id'], 'ccb', 'left', 'ccb.cache_content as cache_content_sig, ccb.cache_updated as cache_updated_sig'); } } if ($this->registry->tags->isEnabled()) { $_post_joins[] = $this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid')); } /* Sorting */ switch ($sort_by) { default: case 'date': $sortKey = IPSSearchRegistry::get('set.returnType') == 'tids' ? 'last_post' : $this->table['post_date']; $sortType = 'numerical'; break; case 'title': $sortKey = 'title'; $sortType = 'string'; break; case 'posts': $sortKey = 'posts'; $sortType = 'numerical'; break; case 'views': $sortKey = 'views'; $sortType = 'numerical'; break; } /* Set vars */ IPSSearch::$ask = $sortKey; IPSSearch::$aso = strtolower($sort_order); IPSSearch::$ast = $sortType; /* If we are search in titles only, then the ID array will be TIDs */ if (IPSSearchRegistry::get('set.returnType') == 'tids') { $k = 'tid'; $this->DB->build(array('select' => "t.*", 'from' => array('topics' => 't'), 'where' => 't.tid IN( ' . implode(',', $ids) . ')', 'add_join' => array_merge(array(array('select' => 'p.*', 'from' => array($this->table['_table_'] => 'p'), 'where' => 'p.' . $this->table['pid'] . '=t.topic_firstpost', 'type' => 'left'), array('select' => 'm.member_id, m.members_display_name, m.members_seo_name', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.' . $this->table['author_id'], 'type' => 'left')), $_post_joins))); } else { $k = $this->table['pid']; $this->DB->build(array('select' => "p.*", 'from' => array($this->table['_table_'] => 'p'), 'where' => 'p.' . $this->table['pid'] . ' IN( ' . implode(',', $ids) . ')', 'add_join' => array_merge(array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.' . $this->table['topic_id'], 'type' => 'left'), array('select' => 'm.member_id, m.members_display_name, m.members_seo_name', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.' . $this->table['author_id'], 'type' => 'left')), $_post_joins))); } /* Grab data */ $this->DB->execute(); /* Grab the results */ while ($row = $this->DB->fetch()) { $_rows[$row[$k]] = $this->searchArchives ? $this->archiveReader->archiveToNativeFields($row) : $row; } /* Get the 'follow' meta data? */ if (count($followData)) { $followData = classes_like_meta::get($followData); /* Merge the data from the follow class into the results */ foreach ($followData as $_formatted) { $_rows[$_formatted['like_rel_id']]['_followData'] = $_formatted; } } /* Sort */ if (count($_rows)) { usort($_rows, array("IPSSearch", "usort")); foreach ($_rows as $id => $row) { /* Prevent member from stepping on it */ $row['topic_title'] = $row['title']; /* Get author data? */ if ($k == 'tid') { if (!empty($row['last_poster_id'])) { $members[$row['last_poster_id']] = $row['last_poster_id']; } } else { if (!empty($row['author_id'])) { $members[$row['author_id']] = $row['author_id']; } } /* Topic ids? */ if (!empty($row['topic_id'])) { $topicIds[$row['topic_id']] = $row['topic_id']; } /* If we're using sphinx, check forum permissions again as the 15 minute delta rebuild could expose a moved topic before deltas rebuild. We don't need to do this for SQL search as the results are delivered live and lets face it, we can do without the load */ if ($this->settings['search_method'] != 'traditional') { /* Can we read? */ if (!$this->registry->permissions->check('view', $this->registry->class_forums->forum_by_id[$row['forum_id']])) { continue; } /* Can read, but is it password protected, etc? */ if (!$this->registry->class_forums->forumsCheckAccess($row['forum_id'], 0, 'forum', array(), true)) { continue; } } $row['cleanSearchTerm'] = urlencode($search_term); $row['topicPrefix'] = $row['pinned'] ? $this->registry->getClass('output')->getTemplate('forum')->topicPrefixWrap($this->lang->words['pre_pinned']) : ''; $row['_isVisible'] = $this->registry->getClass('class_forums')->fetchHiddenTopicType($row) == 'visible' ? true : false; $row['_isHidden'] = $this->registry->getClass('class_forums')->fetchHiddenTopicType($row) == 'hidden' ? true : false; $row['_isDeleted'] = $this->registry->getClass('class_forums')->fetchHiddenTopicType($row) == 'sdelete' ? true : false; $row['_p_isVisible'] = $this->registry->getClass('class_forums')->fetchHiddenType($row) == 'visible' ? true : false; $row['_p_isHidden'] = $this->registry->getClass('class_forums')->fetchHiddenType($row) == 'hidden' ? true : false; $row['_p_isDeleted'] = $this->registry->getClass('class_forums')->fetchHiddenType($row) == 'sdelete' ? true : false; /* Hidden and we do not have permission? */ if ($row['_isHidden'] and !$permissions['canQueue']) { continue; } /* Is the topic deleted? If so, then the first post will appear as such */ if ($row['_isDeleted'] and $permissions['TopicSoftDeleteSee']) { $row['_p_isDeleted'] = true; $_sdPids[$row['pid']] = $row['pid']; } /* Collect TIDS of soft deleted topics */ if ($row['_isDeleted']) { if ($permissions['TopicSoftDeleteSee']) { $_sdTids[$row['tid']] = $row['tid']; } else { continue; } } /* Collect TIDS of soft deleted topics */ if ($row['_p_isDeleted']) { if ($permissions['PostSoftDeleteSee']) { $_sdPids[$row['pid']] = $row['pid']; } else { continue; } } /* Tags */ if (!empty($row['tag_cache_key'])) { $row['tags'] = $this->registry->tags->formatCacheJoinData($row); } $results[$k == 'tid' ? $row['tid'] : $row['pid']] = $this->genericizeResults($row); } } /* Need to load members? */ if (count($members)) { $mems = IPSMember::load($members, 'all'); $mems[0] = array(); foreach ($results as $id => $r) { $_memberIdColumn = IPSSearchRegistry::get('set.returnType') == 'tids' ? 'last_poster_id' : 'author_id'; if (isset($mems[$r[$_memberIdColumn]])) { $mems[$r[$_memberIdColumn]]['m_posts'] = $mems[$r[$_memberIdColumn]]['posts']; unset($mems[$r[$_memberIdColumn]]['last_post']); if (isset($r['cache_content_sig'])) { $mems[$r[$_memberIdColumn]]['cache_content'] = $r['cache_content_sig']; $mems[$r[$_memberIdColumn]]['cache_updated'] = $r['cache_updated_sig']; } $_mem = IPSMember::buildDisplayData($mems[$r[$_memberIdColumn]], array('reputation' => 0, 'warn' => 0)); unset($_mem['cache_content'], $_mem['cache_updated']); $results[$id]['_realPosts'] = $results[$id]['posts']; $results[$id] = array_merge($results[$id], $_mem); $results[$id]['posts'] = $results[$id]['_realPosts']; } } } /* Generate 'dot' folder icon */ if ($this->settings['show_user_posted'] and count($topicIds)) { $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), ''); $this->DB->build(array('select' => 'author_id, topic_id', 'from' => 'posts', 'where' => $_queued . ' AND author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topicIds) . ')')); $this->DB->execute(); while ($p = $this->DB->fetch()) { $dots[$p['topic_id']] = 1; } /* Merge into results */ foreach ($results as $id => $r) { if (isset($dots[$r['topic_id']])) { $results[$id]['_hasPosted'] = 1; } } } /* Got any deleted items */ if (count($_sdTids)) { $sData = IPSDeleteLog::fetchEntries($_sdTids, 'topic', false); if (count($sData)) { foreach ($results as $id => $data) { if (isset($_sdTids[$data['tid']])) { $results[$id]['sData'] = $sData[$data['tid']]; $results[$id]['permissions'] = $permissions; } } } } /* Got any deleted items */ if (count($_sdPids)) { $sData = IPSDeleteLog::fetchEntries($_sdPids, 'post', false); if (count($sData)) { foreach ($results as $id => $data) { if (isset($_sdPids[$data['pid']]) and !isset($results[$id]['sData'])) { $results[$id]['sData'] = $sData[$data['pid']]; $results[$id]['permissions'] = $permissions; } } } } } return $results; }
/** * Fetch raw comments * * @param mixed parent ID * @param array Filters * @return array */ public function fetch($parent, $filters = array()) { /* Check parent */ if (is_numeric($parent)) { $parent = $this->fetchParent($parent); } /* Set filters */ $filters = $this->_setFilters($filters); $parent = $this->remapFromLocal($parent, 'parent'); $comments = array(); $q = array(); $_remap = $this->remapKeys(); list($app, $_where) = explode('-', $this->whoAmI()); /* unpack cache */ $this->_unpackRepCache(); /* Joins */ $_post_joins = array(array('select' => 'm.member_id as my_member_id, m.*', 'where' => 'm.member_id=c.' . $_remap['comment_author_id'], 'from' => array('members' => 'm'), 'type' => 'left'), array('select' => 'pc.*', 'where' => 'pc.member_id=m.member_id', 'from' => array('pfields_content' => 'pc'), 'type' => 'left'), array('select' => 'pp.*', 'where' => 'pp.pp_member_id=m.member_id', 'from' => array('profile_portal' => 'pp'), 'type' => 'left')); /* Reputation system enabled? */ if ($this->reputationEnabled() && $this->settings['reputation_enabled']) { /* Add the join to figure out if the user has already rated the post */ $_post_joins[] = $this->registry->repCache->getUserHasRatedJoin($_remap['comment_id'], 'c.' . $_remap['comment_id'], $app); /* Add the join to figure out the total ratings for each post */ if ($this->settings['reputation_show_content']) { $_post_joins[] = $this->registry->repCache->getTotalRatingJoin($_remap['comment_id'], 'c.' . $_remap['comment_id'], $app); } } /* Start of query */ $q[] = "c." . $_remap['comment_parent_id'] . "=" . $parent['parent_id']; /* Can moderate? */ if ($this->can('moderate', array('comment_parent_id' => $parent['parent_id'])) !== true) { $q[] = 'c.' . $_remap['comment_approved'] . '=1'; } /* Fetching a single comment? */ if (isset($filters['comment_id'])) { if (is_numeric($filters['comment_id'])) { $q[] = 'c.' . $_remap['comment_id'] . '=' . intval($filters['comment_id']); } else { if (is_array($filters['comment_id'])) { $q[] = 'c.' . $_remap['comment_id'] . ' IN(' . implode(",", IPSLib::cleanIntArray($filters['comment_id'])) . ')'; } } } /* Set up parser */ $this->parser->set(array('parseArea' => $this->bbcodeSection())); /* Allow plugin to add additional where clauses, or modify existing ones */ $query = array('select' => 'c.*', 'from' => array($this->table() => 'c'), 'where' => implode(' AND ', $q), 'order' => 'c.' . $_remap[$filters['sortKey']] . ' ' . $filters['sortOrder'], 'limit' => array($filters['offset'], $filters['limit']), 'add_join' => $_post_joins); $query = $this->alterFetchQuery($query, $_remap, $parent, $filters); /* Fetch the data */ $this->DB->build($query); $oq = $this->DB->execute(); /* Go get 'em bawss */ $hidden = array(); while ($row = $this->DB->fetch($oq)) { /* Reset member ID */ $row['member_id'] = $row[$_remap['comment_author_id']]; if (!$row['member_id'] and $row['my_member_id']) { $row['member_id'] = $row['my_member_id']; } /* Set up parser */ $this->parser->set(array('memberData' => $row)); /* Remap */ $row = $this->remapFromLocal($row); /* cache in generic state */ $this->_cache[$row['comment_id']] = $row; /* Preserve original DB formatting */ $row['_db_comment'] = $row['comment_text']; /* Parse for display */ $row['comment_text'] = $this->parser->display($row['comment_text']); /* Can moderate? */ if ($this->can('moderate', array('comment_parent_id' => $parent['parent_id']))) { if ($this->request['selectedpids']) { if (strstr(',' . $this->request['selectedpids'] . ',', ',' . $row['pid'] . ',')) { $row['_pidChecked'] = true; } } } /* Ignored users */ foreach ($this->member->ignored_users as $_i) { if ($_i['ignore_topics'] and $_i['ignore_ignore_id'] == $row['comment_author_id']) { if (!strstr($this->settings['cannot_ignore_groups'], ',' . $row['member_group_id'] . ',')) { $row['_ignored'] = true; break; } } } /* Reputation */ if ($this->settings['reputation_enabled']) { $row['pp_reputation_points'] = $row['pp_reputation_points'] ? $row['pp_reputation_points'] : 0; $row['has_given_rep'] = $row['has_given_rep'] ? $row['has_given_rep'] : 0; $row['rep_points'] = $this->registry->repCache->getRepPoints(array('app' => $app, 'type' => $_remap['comment_id'], 'type_id' => $row['comment_id'], 'rep_points' => $row['rep_points'])); if (!($this->settings['reputation_protected_groups'] && in_array($this->memberData['member_group_id'], explode(',', $this->settings['reputation_protected_groups']))) && $this->memberData['_members_cache']['rep_filter'] !== '*') { if ($this->settings['reputation_show_content'] && $row['rep_points'] < $this->memberData['_members_cache']['rep_filter'] && $this->settings['reputation_point_types'] != 'like') { $row['_repignored'] = true; } } } /* View */ $row['_canView'] = $this->can('view', $row) === true ? 1 : 0; /* Edit button */ $row['_canEdit'] = $this->can('edit', $row) === true ? 1 : 0; /* Hide/Unhide buttons */ $row['_canHide'] = $this->can('hide', $row) === true ? 1 : 0; $row['_canUnhide'] = $this->can('unhide', $row) === true ? 1 : 0; $row['_canApprove'] = $this->can('visibility', $row) === true ? 1 : 0; /* Delete button */ $row['_canDelete'] = $this->can('delete', $row) === true ? 1 : 0; /* Reply button */ $row['_canReply'] = $this->can('add', $row) === true ? 1 : 0; /* Report link */ if ($this->fetchSetting('urls-report', $parent)) { $_parts = substr_count($this->fetchSetting('urls-report', $parent), '%s'); switch ($_parts) { case 1: $row['urls-report'] = sprintf($this->fetchSetting('urls-report', $parent), $row['comment_id']); break; case 2: $row['urls-report'] = sprintf($this->fetchSetting('urls-report', $parent), $row['comment_id'], $parent['parent_id']); break; } } /* Ensure parity */ $row['member_id'] = $row['comment_author_id']; $row['members_display_name'] = $row['members_display_name'] ? $row['members_display_name'] : $this->lang->words['global_guestname']; /* Reputation */ if ($this->settings['reputation_enabled']) { $row['like'] = $this->returnReputationFormatted($app, $_remap, $row); } /* Hidden Information */ if ($row['comment_approved'] == -1) { $hidden[] = $row['comment_id']; } /* Done */ $comments[$row['comment_id']] = array('author' => IPSMember::buildDisplayData($row), 'comment' => $row); } if (!empty($hidden)) { foreach (IPSDeleteLog::fetchEntries($hidden, $this->whoAmI()) as $k => $v) { $comments[$k]['sD'] = $v; } } return is_array($comments) ? $comments : array(); }
/** * Main Execution Function * * @param object Registry reference * @return @e void [Outputs to screen/redirects] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // INIT //----------------------------------------- $post_data = array(); $poll_data = ''; $function = ''; /* Print CSS */ $this->registry->output->addToDocumentHead('raw', "<link rel='stylesheet' type='text/css' title='Main' media='print' href='{$this->settings['css_base_url']}style_css/{$this->registry->output->skin['_csscacheid']}/ipb_print.css' />"); /* Followed stuffs */ require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php'; /*noLibHook*/ $this->_like = classes_like::bootstrap('forums', 'topics'); /* Init */ if (!$this->registry->isClassLoaded('topics')) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums'); $this->registry->setClass('topics', new $classToLoad($this->registry)); } try { /* Load up the data dudes */ $this->registry->getClass('topics')->autoPopulate(null, false); } catch (Exception $crowdCheers) { $msg = str_replace('EX_', '', $crowdCheers->getMessage()); $this->registry->output->showError($msg, 10340, null, null, 404); } /* Shortcut */ $this->forumClass = $this->registry->getClass('class_forums'); /* Setup basics for this method */ $topicData = $this->registry->getClass('topics')->getTopicData(); $forumData = $this->forumClass->getForumById($topicData['forum_id']); /* VigLink */ if (!$forumData['viglink']) { $this->settings['viglink_enabled'] = FALSE; } /* Rating */ $this->can_rate = $this->memberData['member_id'] ? intval($this->memberData['g_topic_rate_setting']) : 0; /* Set up topic */ $topicData = $this->topicSetUp($topicData); /* Specific view? */ $this->_doViewCheck(); /* Get Posts */ $_NOW = IPSDebug::getMemoryDebugFlag(); if ($this->registry->getClass('topics')->isArchived($topicData) && $this->registry->class_forums->fetchArchiveTopicType($topicData) != 'working') { /* Load up archive class */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/archive/reader.php', 'classes_archive_reader'); $this->archiveReader = new $classToLoad(); $this->archiveReader->setApp('forums'); $postData = $this->archiveReader->get(array('parentData' => $topicData, 'goNative' => true, 'offset' => intval($this->registry->getClass('topics')->pageToSt($this->request['page'])), 'limit' => intval($this->settings['display_max_posts']), 'sortKey' => $this->settings['post_order_column'], 'sortOrder' => $this->settings['post_order_sort'])); } else { $postData = $this->_getPosts(); } /* Finish off post Data */ if (count($postData)) { foreach ($postData as $pid => $data) { $postData[$pid] = $this->parsePostRow($data); } } /* Do we have a P parameter, and if so, is it actually in this set of results? */ if (!$this->request['view'] && ($this->request['p'] && !in_array($this->request['p'], array_keys($postData)))) { /* Go find it */ $this->request['view'] = 'findpost'; $this->_doViewCheck(); /* Exits above */ } unset($this->cached_members); /* Status? */ if ($topicData['_ppd_ok'] === TRUE) { /* status from PPD */ if ($this->forumClass->ppdStatusMessage) { $topicData['_fastReplyStatusMessage'][] = $this->forumClass->ppdStatusMessage; } } $topicData['_fastReplyModAll'] = FALSE; switch (intval($forumData['preview_posts'])) { case 1: case 3: $topicData['_fastReplyModAll'] = TRUE; break; } //----------------------------------------- // Update the item marker //----------------------------------------- if (!$this->request['view'] && !$this->registry->getClass('topics')->isArchived($topicData)) { /* If we marked page 2 but land back on page 1 again we don't want to unmark it! */ $lastMarked = $this->registry->classItemMarking->fetchTimeLastMarked(array('forumID' => $forumData['id'], 'itemID' => $topicData['tid'])); /* is this the very last page? */ if ($this->registry->getClass('topics')->isOnLastPage()) { /* ...then make the timestamp 'NOW' so polls will be cleared correctly */ $this->_maxPostDate = IPS_UNIX_TIME_NOW; } if ($lastMarked < $this->_maxPostDate) { $this->registry->getClass('classItemMarking')->markRead(array('forumID' => $forumData['id'], 'itemID' => $topicData['tid'], 'markDate' => $this->_maxPostDate, 'containerLastActivityDate' => $forumData['last_post'])); } } /* add meta update time */ if ($this->_maxPostDate) { $this->registry->output->addMetaTag('og:updated_time', $this->_maxPostDate, false); } /* Set has unread flag */ $forumData['_hasUnreadTopics'] = $this->registry->getClass('class_forums')->getHasUnread($forumData['id']); IPSDebug::setMemoryDebugFlag("TOPICS: Parsed Posts - Completed", $_NOW); //----------------------------------------- // Generate template //----------------------------------------- $topicData['id'] = $topicData['forum_id']; //----------------------------------------- // This has to be called first to set $this->poll_only //----------------------------------------- $poll_data = $topicData['poll_state'] ? $this->_generatePollOutput() : array('html' => '', 'poll' => ''); $displayData = array('fast_reply' => $this->_getFastReplyData(), 'multi_mod' => $this->registry->getClass('topics')->getMultiModerationData(), 'reply_button' => $this->_getReplyButtonData(), 'active_users' => $this->_getActiveUserData(), 'mod_links' => $this->registry->getClass('topics')->isArchived($topicData) ? '' : $this->_generateModerationPanel(), 'follow_data' => ($this->registry->getClass('topics')->isArchived($topicData) or $topicData['_isDeleted']) ? '' : $this->_like->render('summary', $topicData['tid']), 'same_tagged' => $this->registry->getClass('topics')->isArchived($topicData) ? '' : $this->_getSameTaggedData(), 'poll_data' => $poll_data, 'load_editor_js' => $this->_getFastReplyData() && $topicData['_isDeleted'] ? true : false, 'smilies' => '', 'best_answer_post_data' => $this->_getBestAnswerFeature($postData, $topicData)); //----------------------------------------- // If we can edit, but not reply, load JS still //----------------------------------------- if (!($displayData['fast_reply'] and $displayData['reply_button']['url']) and $this->_canEditAPost) { $displayData['load_editor_js'] = true; $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite'); $editor = new $classToLoad(); $displayData['smilies'] = $editor->fetchEmoticons(); } $postData = $this->_parseAttachments($postData); /* Rules */ if ($forumData['show_rules'] == 2) { IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = 1; IPSText::getTextClass('bbcode')->parse_nl2br = 1; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'topics'; IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others']; $forumData['rules_text'] = IPSText::getTextClass('bbcode')->preDisplayParse($forumData['rules_text']); } /* Got soft delete pids? */ if (is_array($this->_sdPids) and count($this->_sdPids)) { $displayData['sdData'] = IPSDeleteLog::fetchEntries($this->_sdPids, 'post', false); } if ($topicData['_isDeleted']) { $topicData['sdData'] = IPSDeleteLog::fetchEntries(array($topicData['tid']), 'topic', false); $topicData['sdData'] = $topicData['sdData'][$topicData['tid']]; } if ($topicData['starter_id']) { $topicData['_starter'] = IPSMember::buildDisplayData(IPSMember::load($topicData['starter_id'])); } else { $topicData['_starter'] = IPSMember::buildDisplayData(IPSMember::setUpGuest($topicData['starter_name'] ? $this->settings['guest_name_pre'] . $topicData['starter_name'] . $this->settings['guest_name_suf'] : '')); } /* Can we report? */ $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary', 'core'); $reports = new $classToLoad($this->registry); $topicData['_canReport'] = $reports->canReport('post'); /* No likey no lighty */ require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php'; /*noLibHook*/ $_like = classes_like::bootstrap('forums', 'topics'); $topicData['_isLiked'] = $this->memberData['member_id'] ? $_like->isLiked($topicData['tid'], $this->memberData['member_id']) : false; $template = $this->registry->output->getTemplate('topic')->topicViewTemplate($forumData, $topicData, $postData, $displayData); //----------------------------------------- // Send for output //----------------------------------------- $this->registry->output->setTitle(strip_tags($topicData['title']) . '<%pageNumber%> - ' . $forumData['name'] . ' - ' . $this->settings['board_name']); $this->registry->output->addContent($template); if (is_array($this->nav) and count($this->nav)) { foreach ($this->nav as $_nav) { $this->registry->output->addNavigation($_nav[0], $_nav[1], $_nav[2], $_nav[3]); } } /** * Add navigational links */ $this->registry->output->addToDocumentHead('raw', "<link rel='up' href='" . $this->registry->output->buildSEOUrl('showforum=' . $topicData['forum_id'], 'publicNoSession', $forumData['name_seo'], 'showforum') . "' />"); $this->registry->output->addToDocumentHead('raw', "<link rel='author' href='" . $this->registry->output->buildSEOUrl('showuser='******'starter_id'], 'publicNoSession', $topicData['seo_first_name'], 'showuser') . "' />"); /* Add Meta Content */ if ($this->_firstPostContent) { /* Strip tags on title to ensure multi-mod added code isn't displayed */ $this->registry->output->addMetaTag('keywords', strip_tags(trim($topicData['title']) . ' ' . str_replace("\n", " ", str_replace("\r", "", strip_tags($this->_firstPostContent)))), TRUE); } $pageData = $this->registry->output->getPaginationProcessedData(); $pageMeta = $pageData['pages'] > 1 ? sprintf($this->lang->words['topic_meta_pages'], $pageData['current_page'], $pageData['pages']) . ' ' : ''; # Trim to 155 chars based on Dan's recommendation $this->registry->output->addMetaTag('description', trim($pageMeta . sprintf($this->lang->words['topic_meta_description'], strip_tags($topicData['title']), $forumData['name'], str_replace("\r", "", $this->_firstPostContent))), FALSE); /* Set Ad code for the board index */ if ($this->registry->getClass('IPSAdCode')->userCanViewAds()) { $this->registry->getClass('IPSAdCode')->setGlobalCode('header', 'ad_code_topic_view_header'); $this->registry->getClass('IPSAdCode')->setGlobalCode('footer', 'ad_code_topic_view_footer'); } $this->registry->output->sendOutput(); }