コード例 #1
0
ファイル: thread.php プロジェクト: 0hyeah/yurivn
    public static function create_array($ids)
    {
        global $vbulletin;
        $current_user = new vB_Legacy_CurrentUser();
        $select = array();
        $joins = array();
        $where = array();
        $threadids = implode(',', array_map('intval', $ids));
        $select[] = "thread.*";
        $where[] = "thread.threadid IN ({$threadids})";
        // always add the thread preview field to the results, unless it is disabled.
        if ($vbulletin->options['threadpreview'] > 0) {
            $select[] = "post.pagetext AS preview";
            $joins['threadpreview'] = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)";
        } else {
            //being a chicken here and making sure we don't remove the preview item
            //from the array in case it matters
            $select[] = "'' as preview";
        }
        if (!$current_user->isGuest()) {
            //join in thread subscriptions if enabled
            if ($vbulletin->options['threadsubscribed']) {
                $select[] = "subscribethread.subscribethreadid";
                $joins['subscribethread'] = "LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON\n\t\t\t\t\tsubscribethread.threadid = thread.threadid AND\n\t\t\t\t\tsubscribethread.userid =  " . intval($current_user->getField('userid'));
            }
            if ($vbulletin->options['threadmarking']) {
                $select[] = "threadread.readtime";
                $joins['threadread'] = "LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON\n\t\t\t\t\tthreadread.threadid = thread.threadid AND\n\t\t\t\t\tthreadread.userid =  " . intval($current_user->getField('userid'));
            }
        }
        if ($vbulletin->options['avatarenabled']) {
            $select[] = 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, user.avatarrevision,
						customavatar.dateline AS avatardateline, customavatar.width AS width, customavatar.height AS height,
						customavatar.height_thumb AS height_thumb, customavatar.width_thumb AS width_thumb, customavatar.filedata_thumb,
						first_user.avatarrevision AS first_avatarrevision, first_avatar.avatarpath AS first_avatarpath,
						NOT ISNULL(first_customavatar.userid) AS first_hascustomavatar, first_customavatar.dateline AS first_avatardateline,
						first_customavatar.width AS first_width, first_customavatar.height AS first_height, first_customavatar.height_thumb
						AS first_height_thumb, first_customavatar.width_thumb AS first_width_thumb, first_customavatar.filedata_thumb AS
						first_filedata_thumb';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'user AS user ON (user.userid = thread.lastposterid)';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'avatar AS avatar ON (avatar.avatarid = user.avatarid)';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'customavatar AS customavatar ON (customavatar.userid = user.userid)';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'user AS first_user ON (first_user.userid = thread.postuserid)';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'avatar AS first_avatar ON (first_avatar.avatarid = first_user.avatarid)';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'customavatar AS first_customavatar ON (first_customavatar.userid = first_user.userid)';
        }
        if ($vbulletin->options['showdots']) {
            $select[] = "lastpost.lastposttime";
            $joins['lastpost'] = "LEFT JOIN (\n\t\t\t\tSELECT threadid, MAX(dateline) AS lastposttime\n\t\t\t\tFROM " . TABLE_PREFIX . "post\n\t\t\t\tWHERE threadid IN ({$threadids})\n\t\t\t\t\tAND userid = " . intval($current_user->getField('userid')) . "\n\t\t\t\tGROUP BY threadid\n\t\t\t) AS lastpost ON (lastpost.threadid = thread.threadid)";
        }
        $set = $vbulletin->db->query_read_slave("\n\t\t\tSELECT " . implode(",", $select) . "\n\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t\t\t" . implode("\n", $joins) . "\n\t\t\tWHERE " . implode(' AND ', $where) . "\n\t\t");
        $threads = array();
        while ($threadinfo = $vbulletin->db->fetch_array($set)) {
            $threads[$threadinfo['threadid']] = self::create_from_record($threadinfo);
        }
        return $threads;
    }
コード例 #2
0
ファイル: thread.php プロジェクト: Kheros/MMOver
 public static function create_array($ids)
 {
     global $vbulletin;
     $current_user = new vB_Legacy_CurrentUser();
     $select = array();
     $joins = array();
     $where = array();
     $select[] = "thread.*";
     $where[] = "thread.threadid IN (" . implode(',', array_map('intval', $ids)) . ")";
     // always add the thread preview field to the results, unless it is disabled.
     if ($vbulletin->options['threadpreview'] > 0) {
         $select[] = "post.pagetext AS preview";
         $joins['threadpreview'] = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)";
     } else {
         //being a chicken here and making sure we don't remove the preview item
         //from the array in case it matters
         $select[] = "'' as preview";
     }
     if (!$current_user->isGuest()) {
         //join in thread subscriptions if enabled
         if ($vbulletin->options['threadsubscribed']) {
             $select[] = "subscribethread.subscribethreadid";
             $joins['subscribethread'] = "LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON\r\n\t\t\t\t\tsubscribethread.threadid = thread.threadid AND\r\n\t\t\t\t\tsubscribethread.userid =  " . intval($current_user->getField('userid'));
         }
         if ($vbulletin->options['threadmarking']) {
             $select[] = "threadread.readtime";
             $joins['threadread'] = "LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON\r\n\t\t\t\t\tthreadread.threadid = thread.threadid AND\r\n\t\t\t\t\tthreadread.userid =  " . intval($current_user->getField('userid'));
         }
     }
     global $vbulletin;
     $set = $vbulletin->db->query($q = "\r\n\t\t\tSELECT " . implode(",", $select) . "\r\n\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\r\n\t\t\t\t" . implode("\n", $joins) . "\r\n\t\t\tWHERE " . implode(' AND ', $where) . "\r\n\t\t");
     $threads = array();
     while ($threadinfo = $vbulletin->db->fetch_array($set)) {
         $threads[$threadinfo['threadid']] = self::create_from_record($threadinfo);
     }
     return $threads;
 }