<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=popbox}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>互动社区&nbsp;&gt;&nbsp;论坛管理&nbsp;&gt;&nbsp;帖子管理
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=Forum.postlist" class="nolink">帖子管理</a>
				<a href="index.php?r=SiteSet.forumset" class="link">属性设置</a>
				<a href="index.php?r=Forum.postallreplylist" class="link">回复信息审核</a>
				<a href="index.php?r=Forum.accusationlist" class="link">举报信息管理</a>
				<a href="index.php?r=Forum.shortcutreplylist" class="link">快速回复语</a>
				<a href="index.php?r=Forum.postloglist" class="link">日志管理</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent3">
					<table class="tbl_leftnav" width="100%"><tr>
						<td class="td_channel"><div class="leftnav">
							<!--{if $channel_id}--><a class="title" href="index.php?r=Forum.postlist">全部</a><!--{else}--><span class="ontitle">全部</span><!--{/if}-->
							<span class="sectitle">频道分类</span>
							<!--{foreach from=$channel item=channel}-->
								<!--{if $channel.id == $channel_id}--><a class="onlink">[<!--{$channel.id}-->]<!--{$channel.channel_text}--></a><!--{else}--><a href="index.php?r=Forum.postlist&channel_id=<!--{$channel.id}-->">[<!--{$channel.id}-->]<!--{$channel.channel_text}--></a><!--{/if}-->
							<!--{/foreach}-->
						</div></td>
						<td>
							<form id="searchForm" name="searchForm" action="index.php" method="get" onSubmit="setDisabled(':button',window.document);">
								<input type="hidden" name="r" value="Forum.postlist"/>
								<input type="hidden" name="channel_id" id="channel_id" value="<!--{$channel_id}-->"/>
								<input type="hidden" name="check_status" id="check_status" value="<!--{$check_status}-->"/>
								<input type="hidden" name="orderby" id="orderby" value="<!--{$orderby}-->"/>
								<div class="searchbar">
									<!--{if $channel_id == null}-->
									头条<select name="bulletin_flag">
										<option value="">全部</option>
										<option value="1" <!--{if $bulletin_flag == 1}-->selected<!--{/if}-->>是</option>
										<option value="0" <!--{if $bulletin_flag == 0}-->selected<!--{/if}-->>否</option>
									</select>
									<!--{/if}-->
									&nbsp;精华&nbsp;<select name="extract_flag">
										<option value="">全部</option>
										<option value="1" <!--{if $extract_flag == 1}-->selected<!--{/if}-->>是</option>
										<option value="0" <!--{if $extract_flag == 0}-->selected<!--{/if}-->>否</option>
									</select>
									&nbsp;位置&nbsp;<select name="position_flag">
										<option value="">全部</option>
										<option value="1" <!--{if $position_flag == 1}-->selected<!--{/if}-->>置顶</option>
										<option value="2" <!--{if $position_flag == 2}-->selected<!--{/if}-->>普通</option>
										<option value="3" <!--{if $position_flag == 3}-->selected<!--{/if}-->>固底</option>
									</select>
									&nbsp;类型&nbsp;<select name="post_type">
										<option value="">全部</option>
										<option value="1" <!--{if $post_type == 1}-->selected<!--{/if}-->>图片帖</option>
										<option value="2" <!--{if $post_type == 2}-->selected<!--{/if}-->>附件帖</option>
										<option value="3" <!--{if $post_type == 3}-->selected<!--{/if}-->>投票帖</option>
										<option value="4" <!--{if $post_type == 4}-->selected<!--{/if}-->>登陆可见帖</option>
										<option value="5" <!--{if $post_type == 5}-->selected<!--{/if}-->>回复可见帖</option>
										<option value="0" <!--{if $post_type == 0}-->selected<!--{/if}-->>普通帖</option>
									</select>
									&nbsp;锁帖&nbsp;<select name="lock_status">
										<option value="">全部</option>
										<option value="9" <!--{if $lock_status == 9}-->selected<!--{/if}-->>已锁</option>
										<option value="1" <!--{if $lock_status == 1}-->selected<!--{/if}-->>未锁</option>
									</select>
									&nbsp;标题&nbsp;<input type="text" class="text" name="title" value="<!--{$title}-->"/>
									<!--{if $channel_id}-->
									&nbsp;专题&nbsp;<select id="topic_select" name="topic_id">
										<option value="">选择</option>
										<!--{foreach from=$topicList item=topic}-->
											<option value="<!--{$topic.id}-->" <!--{if $topic_id == $topic.id}-->selected<!--{/if}-->><!--{$topic.topic_name}--></option>
										<!--{/foreach}-->
									</select>
									<!--{/if}-->
									&nbsp;<button type="submit" class="but2font">查询</button>
								</div>
							</form>
							<div class="operation">
								<button type="button" class="but2font" onClick="window.location.href='index.php?r=Forum.addpost&channel_id=<!--{$channel_id}-->&returnParams=<!--{$returnParams}-->'">新增</button>
								<button type="button" class="but4font" onClick="checkStatus(1, '确定审核通过?')">审核通过</button>
								<button type="button" class="but4font" onClick="showPosition()">位置调整</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.updatepostflag&extract_flag=1&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定加精？')">加精</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.updatepostflag&extract_flag=0&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定消精？')">消精</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.lockpost&lock_status=9&returnParams=<!--{$returnParams}-->', 'recordId', 'post_ids', '确定锁定？')">锁定</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.lockpost&lock_status=1&returnParams=<!--{$returnParams}-->', 'recordId', 'post_ids', '确定解锁？')">解锁</button>
								<!--{if $channel_id}-->
									<button type="button" class="but4font" onClick="showTopicToAdd()">添至专题</button>
									<button type="button" class="but4font" onClick="batchOperate('index.php?r=Forum.cancelposttotopic&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定撤销专题？')">撤销专题</button>
									<button type="button" class="but4font" onClick="showTopic(<!--{$channel_id}-->)">专题管理</button>
								<!--{/if}-->
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.deletepost&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '删除之后，信息无法恢复，是否确定删除？')">删除</button>
							</div>
							<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr class="thead">
									<td width="5%"><input type="checkbox" class="checkall"/></td>
									<td width="25%">标题</td>
									<td width="10%">所属频道</td>
									<td width="10%">发布者</td>
									<td width="11%">
										<!--{if $orderby == 3}-->
											<a class="link" onClick="$('#orderby').val(4);$('#searchForm').submit();">回复</a>↓<!--{elseif $orderby == 4}--><a class="link" onClick="$('#orderby').val(3);$('#searchForm').submit();">回复</a>↑<!--{else}--><a class="link" onClick="$('#orderby').val(3);$('#searchForm').submit();">回复</a><!--{/if}-->/<!--{if $orderby == 1}--><a class="link" onClick="$('#orderby').val(2);$('#searchForm').submit();">点击</a>↓<!--{elseif $orderby == 2}--><a class="link" onClick="$('#orderby').val(1);$('#searchForm').submit();">点击</a>↑	<!--{else}--><a class="link" onClick="$('#orderby').val(1);$('#searchForm').submit();">点击</a>
										<!--{/if}-->
									</td>
									<td width="10%">
										<!--{if $orderby == 5}-->
											<a class="link" onClick="$('#orderby').val(6);$('#searchForm').submit();">发布时间</a>↓
										<!--{elseif $orderby == 6}-->
											<a class="link" onClick="$('#orderby').val(5);$('#searchForm').submit();">发布时间</a>↑
										<!--{else}-->
											<a class="link" onClick="$('#orderby').val(5);$('#searchForm').submit();">发布时间</a>
										<!--{/if}-->
									</td>
									<td width="10%"><select onChange="$('#check_status').val($(this).val());$('#searchForm').submit()">
										<option value="">审核</option>
										<option value="1" <!--{if $check_status == 1}-->selected<!--{/if}-->>已审</option>
										<option value="2" <!--{if $check_status == 2}-->selected<!--{/if}-->>待审</option>
									</select></td>
									<td width="10%">专题</td>
									<td width="10%">操作</td>
								</tr>
								<!--{foreach from=$postList item=data name=foo}-->
								<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
									<td><input type="checkbox" name="recordId" value="<!--{$data.post_id}-->"/></td>
									<td><!--{if $data.lock_status==9}--><font color="red">[锁]</font><!--{/if}--><!--{if $data.extract_flag==1}-->[精]<!--{/if}--><!--{if $data.position_flag==1}-->[顶]<!--{elseif $data.position_flag==3}-->[底]<!--{/if}--><!--{if $data.post_type==1}-->[图]<!--{elseif $data.post_type==2}-->[附]<!--{elseif $data.post_type==3}-->[投票]<!--{elseif $data.post_type==4 || $data.post_type==5}-->[隐]<!--{/if}--><a href="./index.php?r=Forum.updatepost&post_id=<!--{$data.post_id}-->&returnParams=<!--{$returnParams}-->"><!--{$data.title}--></a></td>
									<td>
										<!--{if $data.bulletin_flag==1}-->
											<font style="color:red">[头条]</font>
										<!--{elseif $data.bulletin_flag==0}-->
											<!--{$data.channel_text}-->
										<!--{/if}-->
									</td>
									<td><!--{$data.create_user_pet_name}--></td>
									<td ><a href="index.php?r=Forum.postreplylist&post_id=<!--{$data.post_id}-->&returnParams=<!--{$returnParams}-->"><!--{$data.reply_count}--></a>/<!--{$data.click_count}--></td>
									<td><!--{$data.create_date|date_format:"%Y-%m-%d"}--></td>
									<td>
										<input type="hidden" id="check_status<!--{$data.post_id}-->" value="<!--{$data.check_status}-->">
										<!--{if $data.check_status==2}-->
											<font class="link" onclick="showStatusCheck(<!--{$data.post_id}-->)">待审核</font>
										<!--{elseif $data.check_status==1}-->已审核<!--{/if}-->
									</td>
									<td><!--{$data.topic_name}--></td>
									<td>
										<a href="index.php?r=Forum.updatepost&post_id=<!--{$data.post_id}-->&returnParams=<!--{$returnParams}-->">修改</a>
										<a href="javascript:showOperationLog(<!--{$data.post_id}-->)">记录</a>
										<!--<a href="./index.php?r=Forum.postreplylist&post_id=<!--{$data.post_id}-->&returnParams=<!--{$returnParams}-->">回帖</a>-->
									</td>
								</tr>
								<!--{foreachelse}-->
								<tr><td colspan="9">没有对应数据</td></tr>
								<!--{/foreach}-->
							</table>
							<div class="operation">
								<button type="button" class="but2font" onClick="window.location.href='index.php?r=Forum.addpost&channel_id=<!--{$channel_id}-->&returnParams=<!--{$returnParams}-->'">新增</button>
								<button type="button" class="but4font" onClick="checkStatus(1, '确定审核通过?')">审核通过</button>
								<button type="button" class="but4font" onClick="showPosition()">位置调整</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.updatepostflag&extract_flag=1&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定加精？')">加精</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.updatepostflag&extract_flag=0&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定消精？')">消精</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.lockpost&lock_status=9&returnParams=<!--{$returnParams}-->', 'recordId', 'post_ids', '确定锁定？')">锁定</button>
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.lockpost&lock_status=1&returnParams=<!--{$returnParams}-->', 'recordId', 'post_ids', '确定解锁？')">解锁</button>
								<!--{if $channel_id}-->
									<button type="button" class="but4font" onClick="showTopicToAdd()">添至专题</button>
									<button type="button" class="but4font" onClick="batchOperate('index.php?r=Forum.cancelposttotopic&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定撤销专题？')">撤销专题</button>
									<button type="button" class="but4font" onClick="showTopic(<!--{$channel_id}-->)">专题管理</button>
								<!--{/if}-->
								<button type="button" class="but2font" onClick="batchOperate('index.php?r=Forum.deletepost&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '删除之后，信息无法恢复，是否确定删除？')">删除</button>
							</div>
							<div class="page"><!--{$pager}--></div>
						</td>
					</tr></table>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
function checkStatus(status, msg){
	var postIds = "";
	var errorFlag = 0;
	$("input[name=recordId]").each(function(){
		if ($(this).attr("checked") == true) {
			if ($("#check_status"+$(this).val()).val() == 1) {
				errorFlag = 1;
				return false;
			}
			postIds = postIds+','+$(this).val();
		}
	});
	if(errorFlag==1){
		alert('不能对已审核的帖子重复审核！');
		return false;
	}
	if(postIds!=null&&postIds!=''){
		postIds = postIds.substr(1);
		if(confirm(msg)){
			window.location.href='index.php?r=Forum.checkpost&returnParams=<!--{$returnParams}-->&check_status='+status+'&post_ids='+postIds;
		}
	}else{
		alert('请选择帖子');
	}
}
	
function showStatusCheck(postId){
	var str= '<table width="100%"><tr><td height=50 align="center">';
	str += '<button onclick="window.location.href=\'index.php?r=Forum.checkpost&returnParams=<!--{$returnParams}-->&check_status=1&post_id='+postId+'\'">审核通过</button>&nbsp;&nbsp;';
	str += '<button style="width:auto" onclick="window.location.href=\'index.php?r=Forum.checkpost&returnParams=<!--{$returnParams}-->&check_status=9&post_id='+postId+'\'">审核不通过</button>&nbsp;&nbsp;';
	str += '</td></tr></table>';
	$.popbox({title:"帖子审核", content:str});
}
	
function showOperationLog(postId){
	$.popbox({title:"帖子操作记录", content:popstr_search});
	$.ajax({
		type: "GET",
		url: "index.php",
		cache: false,
		data: "r=Forum.operationlogajax&post_id="+postId,
		success: function(data){
			$.popbox.setcontent({title:"帖子操作记录", content:data});
		}
	});
}

function showPosition(){
	var postIds = '';
	var errorFlag = 0;
	$("input[name=recordId]").each(function(index,element){
		if($(element).attr("checked")==true){
			postIds = postIds+','+$(element).val();
		}
	});
	if(postIds!=null&&postIds!=''){
		postIds = postIds.substr(1);
		var str= '<table width="100%"><tr><td height=30 align="center">';
		str += '<button onclick="window.location.href=\'index.php?r=Forum.updatepostflag&position_flag=1&returnParams=<!--{$returnParams}-->&ids='+postIds+'\'">置顶</button>&nbsp;&nbsp;';
		str += '<button onclick="window.location.href=\'index.php?r=Forum.updatepostflag&position_flag=2&returnParams=<!--{$returnParams}-->&ids='+postIds+'\'">普通</button>&nbsp;&nbsp;';
		str += '<button onclick="window.location.href=\'index.php?r=Forum.updatepostflag&position_flag=3&returnParams=<!--{$returnParams}-->&ids='+postIds+'\'">固底</button>';
		str += '</td></tr></table>';
		$.popbox({title:"帖子审核", content:str});
	}else{
		alert('请选择帖子');
	}
}

function showTopic(channelId){
	$.popbox({title:"管理专题", content:popstr_search});
	$.ajax({
		type: "GET",
		url: "index.php",
		cache:false,
		data: "r=Forum.topiclistajax&channel_id="+channelId,
		success: function(data){
			$.popbox.setcontent({title:"管理专题", content:data});
		}
	});
}

function addTopic(inputId,channelId){
	var topicName = $("#"+inputId).val();
	if(topicName==null||topicName==''){
		alert('请输入专题名!');
		return false;
	}
	topicName = encodeURIComponent(topicName);
	$.popbox({title:"新增专题", content:popstr_search});
	$.ajax({
		type: "GET",
		url: "index.php",
		cache: false,
		data: "r=Forum.addtopicajax&topicName="+topicName+"&channel_id="+channelId,
		success: function(msg){
			//popclose();
			showTopic(channelId);
		}
	});
}

function batchUpadteTopic(channelId){
	var topicNames = "";
	var errorflag=0;
	$("input[name=topicNames]").each(function(index,element){
		if($(element).val()==''){
			errorflag=1;
			return false;
		}
		topicNames = topicNames + "," +$(element).val();
	});
	if(errorflag==1){
		alert("请输入专题名称!");
		return false;
	}
	topicNames = topicNames.substring(1);
	
	var topicIds = "";
	$("input[name=topicIds]").each(function(index,element){
		topicIds = topicIds + "," +$(element).val();
	});
	topicIds = topicIds.substring(1);
	$.ajax({url:"./index.php", 
		data:{r:"Forum.updatebatchtopicajax",
			topicIds:topicIds,
			topicNames:topicNames
		},
		cache:false,
		async:false,
		type:"GET",
		success:function(datastr){
			//popclose();
			showTopic(channelId);
		}
	});
}

function updateTopic(inputId,topicId,channelId){
	var topicName = $("#"+inputId).val();
	if(topicName==null||topicName==''){
		alert('请输入专题名!');
		return false;
	}
	topicName = encodeURIComponent(topicName);
	$.popbox({title:"修改专题", content:popstr_search});
	$.ajax({
		type: "GET",
		url: "index.php",
		cache:false,
		data: "r=Forum.updatetopicajax&topicId="+topicId+"&topicName="+topicName+"&channel_id="+channelId,
		success: function(msg){
			//popclose();
			showTopic(channelId);
		}
	});
}

function deleteTopic(topicId,channelId){
	if(confirm('确定删除?')){
		$.popbox({title:"删除专题", content:popstr_search});
		$.ajax({
			type: "GET",
			url: "index.php",
			cache:false,
			data: "r=Forum.deletetopicajax&topicId="+topicId,
			success: function(msg){
				//popclose();
				showTopic(channelId);
			}
		});
	}
}

function showTopicToAdd(){
	var postIds = '';
	$("input[name=recordId]").each(function(index,element){
		if($(element).attr("checked")==true){
			postIds = postIds+','+$(element).val();
		}
	});
	if(postIds!=null&&postIds!=''){
		postIds = postIds.substr(1);
		var str= '<table class="tbl_edit" width="100%">';
		str += '<tr><td class="td_name">选择专题</td>';
		str += '<td id="topicTd" class="td_content"></td></tr>';
		str += '<tr><td class="noborder"></td>';
		str += '<td class="noborder">';
		str += '<button class="butsubmit" onclick="addToTopic(\''+postIds+'\')">提交</button>&nbsp;';
		str += '</td></tr></table>';
		$.popbox({title:"添至专题", content:str});
		var topicSelect = $("#topic_select").clone();
		topicSelect.show();
		topicSelect.attr("id","topicToselect");
		$("#topicTd").append(topicSelect);
	}else{
		alert('请选择帖子');
	}
}

function addToTopic(postIds){
	var topicId = $("#topicToselect").val();
	if(topicId==null||topicId==''){
		alert('请选择一个专题');
		return false;
	}
	window.location.href='index.php?r=Forum.addposttotopic&returnParams=<!--{$returnParams}-->&post_ids='+postIds+'&topic_id='+topicId;
}
</script>
</html>