Exemplo n.º 1
0
	/**
	 * Index a thread
	 *
	 * By default this will look up all of the posts in a thread and calls the core
	 * indexer for each one
	 *
	 * @param int $id the thread id
	 */
	public function index_thread($id)
	{
		global $vbulletin;

		$thread = vB_Legacy_Thread::create_from_id($id);
		
		// make sure thread comes from the CMS comment forum 
		if ($thread->get_field('forumid') != $vbulletin->options['vbcmsforumid'])
		{
			return;
		}

		$set = $vbulletin->db->query_read("
			SELECT post.* FROM " . TABLE_PREFIX . "post AS post WHERE threadid = " . intval($id)
		);

		$indexer = vB_Search_Core::get_instance()->get_core_indexer();
		while ($row = $vbulletin->db->fetch_array($set))
		{
			$post = vB_Legacy_Post::create_from_record($row, $thread);
			$fields = $this->post_to_indexfields($post);
			if ($fields)
			{
				$indexer->index($fields);
			}
		}
	}
Exemplo n.º 2
0
    public static function create_array($ids, $thread_map = array())
    {
        global $vbulletin;
        if (empty($ids)) {
            return array();
        }
        $select = array();
        $joins = array();
        $where = array();
        $select[] = 'post.*';
        $select[] = 'userfield.*, usertextfield.*, user.*, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid';
        $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'user AS user ON (user.userid = post.userid)';
        $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'userfield AS userfield ON (user.userid = userfield.userid)';
        $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'usertextfield AS usertextfield ON (user.userid = usertextfield.userid)';
        $where[] = 'post.postid IN (' . implode(',', $ids) . ')';
        if ($vbulletin->options['avatarenabled']) {
            $select[] = 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar,
						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';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'avatar AS avatar ON (avatar.avatarid = user.avatarid)';
            $joins[] = 'LEFT JOIN ' . TABLE_PREFIX . 'customavatar AS customavatar ON (customavatar.userid = post.userid)';
        }
        // Get all the post and user data in one go
        $set = $vbulletin->db->query_read_slave("\n\t\t\tSELECT " . implode(",", $select) . "\n\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\t\t" . implode("\n", $joins) . "\n\t\t\tWHERE " . implode(' AND ', $where) . "\n\t\t");
        //ensure that $items is in the same order as $ids
        $items = array_fill_keys($ids, false);
        while ($row = $vbulletin->db->fetch_array($set)) {
            $thread = isset($thread_map[$row['threadid']]) ? $thread_map[$row['threadid']] : null;
            $items[$row['postid']] = vB_Legacy_Post::create_from_record($row, $thread);
        }
        $items = array_filter($items);
        return $items;
    }
Exemplo n.º 3
0
	/**
	 * Index a thread
	 *
	 * By default this will look up all of the posts in a thread and calls the core
	 * indexer for each one
	 *
	 * @param int $id the thread id
	 */
	public function index_thread($id)
	{
		throw new Exception ('should not be here');
		global $vbulletin;

		$thread = vB_Legacy_Thread::create_from_id($id);

		$set = $vbulletin->db->query_read("
			SELECT post.* FROM " . TABLE_PREFIX . "post AS post WHERE threadid = " . intval($id)
		);

		$indexer = vB_Search_Core::get_instance()->get_core_indexer();
		while ($row = $vbulletin->db->fetch_array($set))
		{
			$post = vB_Legacy_Post::create_from_record($row, $thread);
			$fields = $this->post_to_indexfields($post);
			if ($fields)
			{
				$indexer->index($fields);
			}
		}
	}
Exemplo n.º 4
0
 public static function create_array($ids, $thread_map = array())
 {
     global $vbulletin;
     $set = $vbulletin->db->query("\r\n\t\t\tSELECT p.*\r\n\t\t\tFROM " . TABLE_PREFIX . "post AS p\r\n\t\t\tWHERE p.postid IN (" . implode(',', $ids) . ")\r\n\t\t");
     //ensure that $items is in the same order as $ids
     $items = array_fill_keys($ids, false);
     while ($row = $vbulletin->db->fetch_array($set)) {
         $thread = isset($thread_map[$row['threadid']]) ? $thread_map[$row['threadid']] : null;
         $items[$row['postid']] = vB_Legacy_Post::create_from_record($row, $thread);
     }
     $items = array_filter($items);
     return $items;
 }