<?php
require_once(dirname(__FILE__)."/config.php");
require_once(dirname(__FILE__)."/../include/pub_datalist_dm.php");
require_once(dirname(__FILE__)."/../include/inc_functions.php");
$db = new DedeSql(false);
$id = ereg_replace("[^0-9]","",$id);
if($id < 1) {
	ShowMsg("错误,未定义的操作！","-1");
	exit(); 
}
$rs = $db->GetOne("SELECT ishidden,groupname,ismaster,smalltype,des,uid FROM #@__groups WHERE groupid='$id'");
if(!is_array($rs)){
	$db->Close();
	ShowMsg("圈子不存在,或被删除！","-1");
	exit(); 
}else if($rs['ishidden']){
	$db->Close();
	ShowMsg("圈子被管理员屏蔽中！","-1");
	exit();
}
$title = $rs['groupname'];
$des = $rs['des'];
if(empty($des)) $des = "本圈还没有介绍说明.";
$master = $rs['ismaster'];
//检测管理员
$ismaster    = @explode(",",$master);
$ismaster	 = in_array($cfg_ml->M_UserName,$ismaster);
if(empty($cfg_ml->M_UserName)) $ismaster = 0;
$smalltype = $rs['smalltype'];
$userid	= $rs['uid'];
$WhereSql = "WHERE gid='{$id}' AND closed='0' ";
if(!isset($typeid)) $typeid = 0;
if($typeid>0){
	$WhereSql .= "AND smalltype='$typeid' ";
}
if(!isset($keywords)) $keywords = '';
if(!empty($keywords)) $WhereSql .= "AND subject like '%".$keywords."%' ";
//
$sql = "SELECT tid,subject,digest,displayorder,replies,lastpost,lastposter FROM #@__group_threads $WhereSql  ORDER BY displayorder DESC, lastpost DESC";
$dlist = new DataList();
$dlist->pageSize = 20;
$dlist->SetParameter("id",$id);
$dlist->SetParameter("keywords",$keywords);
$dlist->SetParameter("typeid",$typeid);
$dlist->SetSource($sql);
require_once(dirname(__FILE__)."/templets/groupdisplay.htm");
$dlist->Close();
unset($rs);
$db->Close();
?>