<?php
require_once(dirname(__FILE__)."/config.php");
require_once(dirname(__FILE__)."/../include/pub_datalist_dm.php");
require_once(dirname(__FILE__)."/../include/inc_functions.php");
$id = ereg_replace("[^0-9]","",$id);
$tid = ereg_replace("[^0-9]","",$tid);
if($id < 1 || $tid < 1) {
	ShowMsg("错误,未定义的操作！","-1");
	exit(); 
}
$db = new DedeSql(false);
$rs = $db->GetOne("SELECT * FROM #@__groups WHERE groupid='$id'");
if(!is_array($rs)){
	$db->Close();
	ShowMsg("圈子不存在,或被删除！","-1");
	exit(); 
}else if($rs['ishidden']){
	$db->Close();
	ShowMsg("圈子被管理员屏蔽中！","-1");
	exit();
}
$master = $rs['ismaster'];
//检测管理员
$ismaster    = @explode(",",$master);
$ismaster	 = in_array($cfg_ml->M_UserName,$ismaster);
if(empty($cfg_ml->M_UserName)) $ismaster = 0;
if(!$ismaster){
	$db->Close();
	ShowMsg("对不起,您尚未该操作权限！","-1");
	exit();
}
$rs = $db->GetOne("SELECT * FROM #@__group_threads WHERE tid='$tid' AND closed='0'");
if(!is_array($rs)){
	$db->Close();
	ShowMsg("对不起,主题已被删除或已被关闭！","-1");
	exit();
}
if(!isset($do)) $do = '';
if($do=="digest"){
	$db->ExecuteNoneQuery("UPDATE #@__group_threads SET digest='1' WHERE tid='$tid';");
	$db->Close();
	ShowMsg("该主题已被加精！","-1");
	exit();
}else if($do=="undigest"){
	$db->ExecuteNoneQuery("UPDATE #@__group_threads SET digest='0' WHERE tid='$tid';");
	$db->Close();
	ShowMsg("该主题已被去精！","-1");
	exit();
}else if($do=="top"){
	$db->ExecuteNoneQuery("UPDATE #@__group_threads SET displayorder='1' WHERE tid='$tid';");
	$db->Close();
	ShowMsg("该主题已被置顶！","-1");
	exit();	
}else if($do=="untop"){
	$db->ExecuteNoneQuery("UPDATE #@__group_threads SET displayorder='0' WHERE tid='$tid';");
	$db->Close();
	ShowMsg("该主题已被消顶！","-1");
	exit();	
}
$db->Close();
ShowMsg("对不起您执行的是无效操作！","-1");
exit();	
?>