<?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_guestbook WHERE bid='$ID'");	
}else if($action=="save"){
	if($ID > 0){
		$row = $db->GetOne("SELECT * FROM #@__group_guestbook WHERE bid='$ID'");
		if(empty($message)) $message = $row['message'];
		if(empty($title))		$title = $row['title'];
		$db->ExecuteNoneQuery("UPDATE #@__group_guestbook SET message='".$message."',title='".$title."' WHERE bid='$ID'");
	}
}else if($action=="edit"){
	$row = $db->GetOne("SELECT * FROM #@__group_guestbook WHERE bid='$ID'");
	$title = $row['title'];
	$message = $row['message'];
}

//列表加载模板
$wheresql = "WHERE gid='{$gid}'";
if(!empty($keyword)) $wheresql .= " AND	(title like '%".$keyword."%' OR message like '%".$keyword."%')";
if(!empty($username)) $wheresql .= " AND uname like '%".$username."%'";
$sql = "SELECT * FROM #@__group_guestbook $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_guestbook.htm");
$dlist->Close();
$db->Close();
?>