/** * Main Execution Function * * @access public * @param object Registry reference * @return void [Outputs to screen/redirects] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // INIT //----------------------------------------- $post_data = array(); $poll_data = ''; $function = ''; //----------------------------------------- // INIT module //----------------------------------------- $this->loadTopicAndForum(); //----------------------------------------- // Topic rating: Rating //----------------------------------------- $this->can_rate = $this->memberData['member_id'] ? intval($this->memberData['g_topic_rate_setting']) : 0; //----------------------------------------- // Reputation Cache //----------------------------------------- if ($this->settings['reputation_enabled']) { /* Load the class */ require_once IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php'; $this->registry->setClass('repCache', new classReputationCache()); /* Update the filter? */ if (isset($this->request['rep_filter']) && $this->request['rep_filter'] == 'update') { $_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']); if ($this->request['rep_filter_set'] == '*') { $_mem_cache['rep_filter'] = '*'; } else { $_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']); } IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache); $this->memberData['_members_cache'] = $_mem_cache; } else { $this->memberData['_members_cache'] = IPSMember::unpackMemberCache($this->memberData['members_cache']); } } //----------------------------------------- // Process the topic //----------------------------------------- $this->topicSetUp(); //----------------------------------------- // Which view are we using? // If mode='show' we're viewing poll results, don't change view mode //----------------------------------------- $this->topic_view_mode = $this->_generateTopicViewMode(); //----------------------------------------- // VIEWS //----------------------------------------- $this->_doViewCheck(); //----------------------------------------- // UPDATE TOPIC? //----------------------------------------- $this->_doUpdateTopicCheck(); //----------------------------------------- // Check PPD //----------------------------------------- $this->_ppd_ok = $this->registry->getClass('class_forums')->checkGroupPostPerDay($this->memberData, TRUE); //----------------------------------------- // Post ID stuff //----------------------------------------- $find_pid = $this->request['pid'] == "" ? isset($this->request['p']) ? $this->request['p'] : 0 : (isset($this->request['pid']) ? $this->request['pid'] : 0); $threaded_pid = $find_pid ? '&pid=' . $find_pid : ''; $linear_pid = $find_pid ? '&view=findpost&p=' . $find_pid : ''; //----------------------------------------- // Remove potential [attachmentid= tag in title //----------------------------------------- $this->topic['title'] = IPSText::stripAttachTag($this->topic['title']); //----------------------------------------- // Get posts //----------------------------------------- $_NOW = IPSDebug::getMemoryDebugFlag(); if ($this->topic_view_mode == 'threaded') { require_once IPSLib::getAppDir('forums') . '/sources/classes/threaded.php'; $threaded = new threadedModeLibrary($this->registry, $this); $post_data = $threaded->_getTopicDataThreaded(); } else { $post_data = $this->_getTopicDataLinear(); } unset($this->cached_members); IPSDebug::setMemoryDebugFlag("TOPICS: Parsed Posts - Completed", $_NOW); //----------------------------------------- // Generate template //----------------------------------------- $this->topic['id'] = $this->topic['forum_id']; /* Posting Allowed? */ $this->forum['_user_can_post'] = 1; //( $this->_ppd_ok === TRUE ) ? 1 : 0; if (!$this->registry->permissions->check('start', $this->forum)) { $this->forum['_user_can_post'] = 0; } if (!$this->forum['sub_can_post']) { $this->forum['_user_can_post'] = 0; } if ($this->forum['min_posts_post'] && $this->forum['min_posts_post'] > $this->memberData['posts']) { $this->forum['_user_can_post'] = 0; } if (!$this->forum['status']) { $this->forum['_user_can_post'] = 0; } if (!$this->memberData['g_post_new_topics']) { $this->forum['_user_can_post'] = 0; } //----------------------------------------- // This has to be called first to set $this->poll_only //----------------------------------------- $poll_data = $this->topic['poll_state'] ? $this->_generatePollOutput() : ''; $displayData = array('threaded_mode_enabled' => $this->topic_view_mode == 'threaded' ? 1 : 0, 'fast_reply' => $this->_getFastReplyData(), 'multi_mod' => $this->_getMultiModerationData(), 'reply_button' => $this->_getReplyButtonData(), 'active_users' => $this->_getActiveUserData(), 'mod_links' => $this->_generateModerationPanel(), 'poll_data' => $poll_data); $post_data = $this->_parseAttachments($post_data); /* Rules */ if ($this->forum['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']; $this->forum['rules_text'] = IPSText::getTextClass('bbcode')->preDisplayParse($this->forum['rules_text']); } //----------------------------------------- // Fix post order if linear+ and ordering // posts DESC (rare, I know): 16221 //----------------------------------------- if ($this->topic_view_mode == 'linearplus' and $this->settings['post_order_sort'] == 'desc') { $newPosts = array(); foreach ($post_data as $pid => $data) { if ($pid == $this->topic['topic_firstpost']) { array_unshift($newPosts, $data); } else { $newPosts[] = $data; } } //----------------------------------------- // Nothing else relies on the key being pid //----------------------------------------- $post_data = $newPosts; } $template = $this->registry->output->getTemplate('topic')->topicViewTemplate($this->forum, $this->topic, $post_data, $displayData); //----------------------------------------- // Send for output //----------------------------------------- $this->registry->output->setTitle($this->topic['title'] . ' - ' . $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]); } } /** * Update cache monitor */ IPSContentCache::updateMonitor($this->_cacheMonitor); /** * Add navigational links */ $this->registry->output->addToDocumentHead('raw', "<link rel='up' href='" . $this->registry->output->buildSEOUrl('showforum=' . $this->topic['forum_id'], 'public', $this->forum['name_seo'], 'showforum') . "' />"); $this->registry->output->addToDocumentHead('raw', "<link rel='author' href='" . $this->registry->output->buildSEOUrl('showuser='******'starter_id'], 'public', $this->topic['seo_first_name'], 'showuser') . "' />"); /* Add Meta Content */ if ($this->_firstPostContent) { $this->registry->output->addMetaTag('keywords', $this->topic['title'] . ' ' . str_replace("\n", " ", str_replace("\r", "", strip_tags($this->_firstPostContent))), TRUE); } $this->registry->output->addMetaTag('description', $this->topic['title'] . ': ' . $this->topic['description'], TRUE); $this->registry->output->sendOutput(); }