public function set_threadInfo()
{
if (!isset($_GET['thread_id']) && !isnum($_GET['thread_id'])) {
redirect(INFUSIONS . 'forum/index.php');
}
$forum_settings = $this->get_forum_settings();
$locale = fusion_get_locale("", FORUM_LOCALE);
$userdata = fusion_get_userdata();
// Download acceptable types for Forum
$this->thread_data = self::get_thread($_GET['thread_id']);
// fetch query and define iMOD
if (!empty($this->thread_data)) {
$thread_stat = self::get_thread_stats($_GET['thread_id']);
// get post_count, lastpost_id, first_post_id.
if ($this->thread_data['forum_type'] == 1) {
if (fusion_get_settings("site_seo")) {
redirect(fusion_get_settings("siteurl") . "infusions/forum/index.php");
}
redirect(INFUSIONS . 'forum/index.php');
}
if ($thread_stat['post_count'] < 1) {
if (fusion_get_settings("site_seo")) {
redirect(fusion_get_settings("siteurl") . "infusions/forum/index.php");
}
redirect(INFUSIONS . 'forum/index.php');
}
// Set meta
add_to_title($this->thread_data['thread_subject']);
add_to_meta($locale['forum_0000']);
if ($this->thread_data['forum_description'] !== '') {
add_to_meta('description', $this->thread_data['forum_description']);
}
if ($this->thread_data['forum_meta'] !== '') {
add_to_meta('keywords', $this->thread_data['forum_meta']);
}
// Set Forum Breadcrumbs
$forum_index = dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php', 'title' => $locale['forum_0000']));
$this->forum_breadcrumbs($forum_index, $this->thread_data['forum_id']);
add_breadcrumb(array('link' => INFUSIONS . 'forum/viewthread.php?forum_id=' . $this->thread_data['forum_id'] . '&thread_id=' . $this->thread_data['thread_id'], 'title' => $this->thread_data['thread_subject']));
$this->setThreadPermission();
// Sanitizes $_GETs
$_GET['forum_id'] = intval($this->thread_data['forum_id']);
/**
* Generate User Tracked Buttons
*/
$this->thread_info['buttons']['notify'] = array();
if ($this->getThreadPermission("can_access")) {
// only member can track the thread
if ($this->thread_data['user_tracked']) {
$this->thread_info['buttons']['notify'] = array('link' => INFUSIONS . "forum/postify.php?post=off&forum_id=" . $this->thread_data['forum_id'] . "&thread_id=" . $this->thread_data['thread_id'], 'title' => $locale['forum_0174']);
} else {
$this->thread_info['buttons']['notify'] = array('link' => INFUSIONS . "forum/postify.php?post=on&forum_id=" . $this->thread_data['forum_id'] . "&thread_id=" . $this->thread_data['thread_id'], 'title' => $locale['forum_0175']);
}
}
$this->thread_info['thread'] = $this->thread_data;
/**
* Generate Quick Reply Form
*/
$qr_form = "";
if ($this->getThreadPermission("can_reply") == TRUE && $this->thread_data['forum_quick_edit'] == TRUE) {
$qr_form = QuickReply::display_quickReply($this->thread_data);
}
/**
* Generate Poll Form
*/
$poll = new Poll($this->thread_info);
$poll_form = $poll->generate_poll($this->thread_data);
/**
* Generate Attachment
*/
$attach = new Attachment($this->thread_info);
$attachments = $attach::get_attachments($this->thread_data);
/**
* Generate Mod Form
*/
if (iMOD) {
$this->moderator()->setForumId($this->thread_data['forum_id']);
$this->moderator()->setThreadId($this->thread_data['thread_id']);
$this->moderator()->set_modActions();
/**
* Thread moderation form template
*/
$addition = isset($_GET['rowstart']) ? "&rowstart=" . intval($_GET['rowstart']) : "";
$this->thread_info['form_action'] = INFUSIONS . "forum/viewthread.php?thread_id=" . intval($this->thread_data['thread_id']) . $addition;
$this->thread_info['open_post_form'] = openform('moderator_menu', 'post', $this->thread_info['form_action']);
$this->thread_info['mod_options'] = array('renew' => $locale['forum_0207'], 'delete' => $locale['forum_0201'], $this->thread_data['thread_locked'] ? "unlock" : "lock" => $this->thread_data['thread_locked'] ? $locale['forum_0203'] : $locale['forum_0202'], $this->thread_data['thread_sticky'] ? "nonsticky" : "sticky" => $this->thread_data['thread_sticky'] ? $locale['forum_0205'] : $locale['forum_0204'], 'move' => $locale['forum_0206']);
$this->thread_info['close_post_form'] = closeform();
$this->thread_info['mod_form'] = "\n\t\t\t\t<div class='list-group-item'>\n\n\t\t\t\t\t<div class='btn-group m-r-10'>\n\n\t\t\t\t\t\t" . form_button("check_all", $locale['forum_0080'], $locale['forum_0080'], array('class' => 'btn-default btn-sm', "type" => "button")) . "\n\t\t\t\t\t\t" . form_button("check_none", $locale['forum_0081'], $locale['forum_0080'], array('class' => 'btn-default btn-sm', "type" => "button")) . "\n\t\t\t\t\t</div>\n\n\t\t\t\t\t" . form_button('move_posts', $locale['forum_0176'], $locale['forum_0176'], array('class' => 'btn-default btn-sm m-r-10')) . "\n\t\t\t\t\t" . form_button('delete_posts', $locale['forum_0177'], $locale['forum_0177'], array('class' => 'btn-default btn-sm')) . "\n\t\t\t\t\t<div class='pull-right'>\n\t\t\t\t\t\t" . form_button('go', $locale['forum_0208'], $locale['forum_0208'], array('class' => 'btn-default pull-right btn-sm m-t-0 m-l-10')) . "\n\t\t\t\t\t\t" . form_select('step', '', '', array('options' => $this->thread_info['mod_options'], 'placeholder' => $locale['forum_0200'], 'width' => '250px', 'allowclear' => TRUE, 'class' => 'm-b-0 m-t-5', 'inline' => TRUE)) . "\n\t\t\t\t\t</div>\n\n\t\t\t\t</div>\n";
add_to_jquery("\n\t\t\t\t\$('#check_all').bind('click', function() {\n\t\t\t\t var thread_posts = \$('#moderator_menu input:checkbox').prop('checked', true);\n\t\t\t\t});\n\t\t\t\t\$('#check_none').bind('click', function() {\n\t\t\t\t var thread_posts = \$('#moderator_menu input:checkbox').prop('checked', false); });\n\t\t\t\t");
}
$this->thread_info += array("thread" => $this->thread_data, "thread_id" => $this->thread_data['thread_id'], "forum_id" => $this->thread_data['forum_id'], 'thread_tags' => $this->thread_data['thread_tags'], 'thread_tags_display' => '', "forum_cat" => isset($_GET['forum_cat']) && verify_forum($_GET['forum_cat']) ? $_GET['forum_cat'] : 0, "forum_branch" => isset($_GET['forum_branch']) && verify_forum($_GET['forum_branch']) ? $_GET['forum_branch'] : 0, "forum_link" => array("link" => INFUSIONS . "forum/index.php?viewforum&forum_id=" . $this->thread_data['forum_id'] . "&forum_cat=" . $this->thread_data['forum_cat'] . "&forum_branch=" . $this->thread_data['forum_branch'], "title" => $this->thread_data['forum_name']), "thread_attachments" => $attachments, "post_id" => isset($_GET['post_id']) && verify_post($_GET['post_id']) ? $_GET['post_id'] : 0, "pid" => isset($_GET['pid']) && isnum($_GET['pid']) ? $_GET['pid'] : 0, "section" => isset($_GET['section']) ? $_GET['section'] : '', "forum_moderators" => $this->moderator()->parse_forum_mods($this->thread_data['forum_mods']), "max_post_items" => $thread_stat['post_count'], "post_firstpost" => $thread_stat['first_post_id'], "post_lastpost" => $thread_stat['last_post_id'], "posts_per_page" => $forum_settings['posts_per_page'], "threads_per_page" => $forum_settings['threads_per_page'], "lastvisited" => isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time(), "allowed_post_filters" => array('oldest', 'latest', 'high'), "attachtypes" => explode(",", $forum_settings['forum_attachtypes']), "quick_reply_form" => $qr_form, "poll_form" => $poll_form, "post-filters" => "", 'mod_options' => array(), 'form_action' => '', 'open_post_form' => '', 'close_post_form' => '', 'mod_form' => '');
//print_p($this->thread_info);
if (!empty($this->thread_info['thread_tags'])) {
$this->thread_info['thread_tags_display'] = $this->tag(FALSE)->display_thread_tags($this->thread_info['thread_tags']);
}
/**
* Generate All Thread Buttons
*/
$this->thread_info['buttons'] += array("print" => array("link" => BASEDIR . "print.php?type=F&item_id=" . $this->thread_data['thread_id'] . "&rowstart=" . $_GET['rowstart'], "title" => $locale['forum_0178']), "newthread" => $this->getThreadPermission("can_post") == TRUE ? array("link" => INFUSIONS . "forum/newthread.php?forum_id=" . $this->thread_data['forum_id'], "title" => $locale['forum_0264']) : array(), "reply" => $this->getThreadPermission("can_reply") == TRUE ? array("link" => INFUSIONS . "forum/viewthread.php?action=reply&forum_id=" . $this->thread_data['forum_id'] . "&thread_id=" . $this->thread_data['thread_id'], "title" => $locale['forum_0360']) : array(), "poll" => $this->getThreadPermission("can_create_poll") == TRUE ? array("link" => INFUSIONS . "forum/viewthread.php?action=newpoll&forum_id=" . $this->thread_data['forum_id'] . "&thread_id=" . $this->thread_data['thread_id'], "title" => $locale['forum_0366']) : array());
/**
* Generate Post Filters
*/
$this->thread_info['post-filters'][0] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_data['thread_id'] . '&section=oldest', 'locale' => $locale['forum_0180']);
$this->thread_info['post-filters'][1] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_data['thread_id'] . '&section=latest', 'locale' => $locale['forum_0181']);
if ($this->getThreadPermission("can_rate") == TRUE) {
$this->thread_info['allowed-post-filters'][2] = 'high';
$this->thread_info['post-filters'][2] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_info['thread_id'] . '&section=high', 'locale' => $locale['forum_0182']);
}
$this->handle_quick_reply();
$this->get_thread_post();
//self::set_ThreadJs();
// execute in the end.
} else {
redirect(FORUM . 'index.php');
}
}