<?php
	//引入公共模块
	require("foundation/fpages_bar.php");
	require("foundation/module_group.php");
	
	//引入语言包
	$g_langpackage=new grouplp;
	$mn_langpackage=new menulp;
	
	//变量区
	$url_group_id=short_check(get_argg('group_id'));
	$subject_id=short_check(get_argg('subject_id'));
	$visitor_id=get_sess_userid();
	$visitor_name=get_sess_username();
	$user_id=get_argg('user_id');
	
	//当前页面参数
	$page_num=trim(get_argg('page'));
	
	//读取方式
	dbtarget('r',$dbServs);
	$dbo=new dbex;
	
	//数据表定义
	$t_group_members=$tablePreStr."group_members";
	$t_groups=$tablePreStr."groups";
	$t_group_subject=$tablePreStr."group_subject";
	$t_group_comment=$tablePreStr."group_subject_comment";
	$role='';
	//权限判断
	if($visitor_id!=''){
		$role=pri_limit($dbo,$visitor_id,$url_group_id);
	}
	
	//取得话题评论
	$condition="subject_id=$subject_id";
	$order_by="order by add_time desc";
	$type="getRs";
	$dbo->setPages($set_page_data_num,$page_num);//设置分页
	$comment_rs=get_db_data($dbo,$t_group_comment,$condition,$order_by,$type);
	$page_total=$dbo->totalPage;//分页总数
	
	//取得群组加入方式
	$sql="select group_join_type from $t_groups where group_id=$url_group_id";
	$g_join_type=$dbo->getRow($sql);
	$join_type=$g_join_type['group_join_type'];
	
	//控制评论
		$isNull=0;
		$show_com='';
	if(empty($comment_rs)){
		$isNull=1;
	}

	//取得主题信息
	$condition="group_id=$url_group_id and subject_id=$subject_id";
	$order_by="order by add_time desc";
	$type="getRow";
	$subject_row=get_db_data($dbo,$t_group_subject,$condition,$order_by,$type);
	$host_id=$subject_row['user_id'];
	
	//防止刷新访问量
	if($visitor_id!=get_session('g_'.$subject_id)){
		//写入方式
		dbtarget('w',$dbServs);
		$sql="update $t_group_subject set hits=hits+1 where subject_id='$subject_id'";
		$dbo->exeUpdate($sql);
		set_session('g_'.$subject_id,$visitor_id);
	}

	//权限显示控制
	$is_pri=1;
	$show_error="content_none";
	$error_str="";
	$isset_data="";
	$is_admin=get_sess_admin();
	if($is_admin==''){
		if($role=='' && $join_type!=0){
			$is_pri=0;
			$show_error="";
			$isset_data="content_none";
			$error_str=$g_langpackage->g_arrest;
			$show_com="content_none";
		}
	}
	//显示控制
	if(empty($subject_row)){
		$show_error="";
		$isset_data="content_none";
		$error_str=$g_langpackage->g_data_none;
		$show_com="content_none";
	}	
	
?>