<?php

/*
 * Copyright (C) xgcms.com
 */

!defined('FRAMEWORK_PATH') && exit('FRAMEWORK_PATH not defined.');

include POST_PATH.'control/common_control.class.php';

class space_control extends common_control {
	private $you;
	function __construct() {
		parent::__construct();
		
		// 初始化用户信息
		$uid = intval(core::gpc('uid'));
		empty($uid) && $uid = $this->_user['uid'];
		$user = $this->member->get($uid);
		$this->check_user_exists($user);
		$this->member->format($user);
		//$this->member->format_follow($user, $this->_user['uid'], $uid);
		empty($_SERVER['miscarr']) && $_SERVER['miscarr'] = $this->mcache->read('miscarr');
		$user['groupname'] = $_SERVER['miscarr']['group'][$user['groupid']];
		
		$this->you = $user;
		$this->view->assign('you', $this->you);
	}
	// 别人的发帖
	public function on_user() {
		$this->_checked['you_post'] = 'class="checked"';
		
		$user = $this->you;
		$uid = $user['uid'];

		$this->_title[] = $user['username'].'的资料';
		$this->_nav[] = '参与主题';
		$this->_seo_keywords = $user['username'];
		$this->_seo_description = $user['username'].'的个人信息和参与的帖子';
		
		// hook you_post_before.php
		$page = misc::page();
		$pagesize = 40;
		$mypostlist = $this->mypost->get_list_by_uid($uid, $page, $pagesize);
		$pages = misc::simple_page("?space-user-uid-$uid.html", count($mypostlist), $page, $pagesize);
	
		empty($_SERVER['miscarr']) && $_SERVER['miscarr'] = $this->mcache->read('miscarr');
		
		foreach($mypostlist as &$post) {
			$post['fname'] = isset($_SERVER['miscarr']['forum'][$post['fid']]) ? $_SERVER['miscarr']['forum'][$post['fid']] : '';
			$this->mypost->format($post);
		}
		$this->view->assign('pages', $pages);
		$this->view->assign('mypostlist', $mypostlist);
		
		// hook you_post_after.php
		$this->view->display('space.html');
	}
	
}

?>