<?php
require_once(dirname(__FILE__)."/config.php");
require_once(dirname(__FILE__)."/../include/pub_datalist_dm.php");
require_once(dirname(__FILE__)."/../include/inc_functions.php");
CheckPurview('group_Edit');
$gid = ereg_replace("[^0-9]","",$gid);
$ID = ereg_replace("[^0-9]","",$ID);
if($gid < 1){
	ShowMsg("含有非法操作!.","-1");
	exit();
}
$db = new DedeSql(false);
if($action=="del"){
	if($ID > 0)	$db->ExecuteNoneQuery("DELETE FROM #@__group_notice WHERE id='$ID'");	
}else if($action=="edit"){
	$row = $db->GetOne("SELECT * FROM #@__group_notice WHERE id='$ID'");
	$title = $row['title'];
	$notice = $row['notice'];
}else if($action=="save"){
	$row = $db->GetOne("SELECT * FROM #@__group_notice WHERE id='$ID'");
	if(empty($title)) $title = $row['title'];
	if(empty($notice)) $notice = $row['notice'];
	$db->ExecuteNoneQuery("UPDATE #@__group_notice SET notice='".$notice."',title='".$title."' WHERE id='$ID'");
}
//列表加载模板
$wheresql = "WHERE gid='{$gid}'";
if(!empty($keyword)) $wheresql .= " AND	(title like '%".$keyword."%' OR notice like '%".$keyword."%')";
if(!empty($username)) $wheresql .= " AND uname like '%".$username."%'";
$sql = "SELECT * FROM #@__group_notice $wheresql ORDER BY stime DESC";
$dlist = new DataList();
$dlist->pageSize = 20;
$dlist->SetParameter("keyword",$keyword);
$dlist->SetParameter("username",$username);
$dlist->SetParameter("gid",$gid);
$dlist->SetSource($sql);
include(dirname(__FILE__)."/templets/group_notice.htm");
$dlist->Close();
$db->Close();
?>