PHPFusion\Forums\ForumServer::thread PHP Метод

thread() публичный статический Метод

public static thread ( $set_info = TRUE )
    public static function thread($set_info = TRUE)
    {
        if (empty(self::$thread_instance)) {
            self::$thread_instance = new Threads\ForumThreads();
            if ($set_info == TRUE) {
                require_once INCLUDES . "mimetypes_include.php";
                self::$thread_instance->set_threadInfo();
            }
        }
        return (object) self::$thread_instance;
    }

Usage Example

Пример #1
0
$valid_get = array("on", "off", "new", "reply", "edit", "newpoll", "editpoll", "deletepoll", "voteup", "votedown");
if (!iMEMBER || !in_array($_GET['post'], $valid_get)) {
    if (fusion_get_settings("site_seo")) {
        redirect(fusion_get_settings("siteurl") . "infusions/forum/index.php");
    }
    redirect(FORUM . "index.php");
}
// When voting up or down
if ($_GET['post'] == 'voteup' or $_GET['post'] == 'votedown') {
    // @todo: extend on user's rank threshold before can vote. - Reputation threshold- Roadmap 9.1
    //include INFUSIONS.'forum/classes/Viewthread.php';
    //include INFUSIONS.'forum/forum_include.php';
    //include INFUSIONS.'forum/classes/Functions.php';
    //$thread = new \PHPFusion\Forums\Viewthread;
    //$thread_info = $thread->get_thread_data();
    $thread_info = \PHPFusion\Forums\ForumServer::thread()->get_threadInfo();
    if ($thread_info['permissions']['can_rate']) {
        // init vars
        $data = array('forum_id' => $thread_info['forum_id'], 'thread_id' => $thread_info['thread_id'], 'post_id' => $thread_info['post_id'], 'vote_user' => $userdata['user_id'], 'vote_datestamp' => time());
        if ($_GET['post'] == 'voteup') {
            $data['vote_points'] = 1;
        } elseif ($_GET['post'] == 'votedown') {
            $data['vote_points'] = -1;
        }
        $res = dbcount("('vote_user')", DB_FORUM_VOTES, "vote_user='******'user_id']) . "' AND thread_id='" . intval($data['thread_id']) . "'");
        if (!$res) {
            // has not voted
            $self_post = dbcount("('post_id')", DB_FORUM_POSTS, "post_id='" . intval($data['post_id']) . "' AND post_user='******'user_id'] . "");
            if (!$self_post) {
                // cannot vote at your own post.
                //print_p($data);