<%@ page contentType="text/html;charset=UTF-8" errorPage="../error.jsp"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.hongshee.ejforum.util.PageUtils"%>
<%@ page import="com.hongshee.ejforum.common.CacheManager"%>
<%@ page import="com.hongshee.ejforum.data.UserDAO.UserInfo"%>
<%@ page import="com.hongshee.ejforum.data.SectionDAO.SectionVO"%>
<%@ page import="com.hongshee.ejforum.data.BoardDAO.BoardVO"%>
<%@ page import="com.hongshee.ejforum.data.GroupDAO.GroupVO"%>
<%@ page import="com.hongshee.ejforum.data.OptionVO"%>
<%@ page import="com.hongshee.ejforum.common.ForumSetting"%>
<%@ page import="com.hongshee.ejforum.common.IConstants"%>
<%
	UserInfo userinfo = PageUtils.getAdminUser(request, response);
	if (userinfo == null) return;
	String fromPath = request.getContextPath() + "/admin/forums/forum_edit.jsp";
	
	int sectionID = PageUtils.getIntParam(request,"sid");
	int boardID = PageUtils.getIntParam(request,"fid");

	CacheManager cache = CacheManager.getInstance();
    ArrayList sections = cache.getSections();
	BoardVO aBoard = cache.getBoard(boardID);

    ArrayList groups = cache.getGroups();

	ForumSetting setting = ForumSetting.getInstance();
	OptionVO[] styles = setting.getStyles();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="../style/admin.css" type=text/css rel=stylesheet>
<SCRIPT src="../../js/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="../js/admin.js" type=text/javascript></SCRIPT>
</HEAD>
<BODY topMargin=10>
<TABLE cellSpacing=6 cellPadding=2 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE class=guide cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD><A onclick="parent.location='../index.htm';return false;" 
            href="#">后台管理首页</A>&nbsp;&raquo;&nbsp;版块详细设置</TD></TR></TBODY></TABLE><BR>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD>
            <DIV style="FLOAT: left; MARGIN-LEFT: 0px; PADDING-TOP: 8px"><A 
            onclick="collapse_change('tip','../images')" href="#">技巧提示</A></DIV>
            <DIV style="FLOAT: right; PADDING-BOTTOM: 9px; MARGIN-RIGHT: 4px"><A 
            onclick="collapse_change('tip','../images')" href="#">
			<IMG id=menuimg_tip src="../images/menu_reduce.gif" border=0></A></DIV></TD></TR>
        <TBODY id=menu_tip>
        <TR>
          <TD>
            <UL><LI><%= PageUtils.getString("forum_info_tip_1") %></LI></UL>
		</TD></TR></TBODY></TABLE><BR>
      <FORM id="settings" name="settings" onSubmit="checkfields(this); return false;" action="../perform.jsp" method=post>
	  <INPUT type=hidden name="act" value="forums_forum_info">
	  <INPUT type=hidden name="boardID" value="<%= boardID %>">
	  <INPUT type=hidden name="fromPath" value="<%= fromPath %>">
      <A name=tb01></A>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD colSpan=2>版块基本设置<A onClick="collapse_change('tb01','../images')" href="#">
  		    <IMG id=menuimg_tb01 style="MARGIN-TOP: -12px; FLOAT: right; MARGIN-RIGHT: 4px" 
             src="../images/menu_reduce.gif" border=0></A></TD></TR>
        <TBODY id=menu_tb01>
        <TR>
          <TD class=altbg1 width="45%"><B>版块名称:</B></TD>
          <TD class=altbg2><INPUT size=50 value="" name="boardName"> </TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>显示版块:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_1") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio CHECKED value="N" name="state" id="state[N]"> 是 &nbsp; &nbsp; 
			<INPUT class=radio type=radio value="I" name="state" id="state[I]"> 否 </TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>所属分区:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_2") %></SPAN></TD>
          <TD class=altbg2>
		  	<SELECT name="sectionID"> 
<%
	if (sections != null)
	{
		SectionVO aSection = null;
		for (int i=0; i<sections.size(); i++)	
		{
			aSection = (SectionVO)sections.get(i);
%>			
				<OPTION value=<%= aSection.sectionID %>><%= aSection.sectionName %></OPTION> 
<%
		}
	}
%>
			</SELECT><INPUT type=hidden name="oldSectionID"></TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>高亮显示色:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_3") %></SPAN></TD>
          <TD class=altbg2><INPUT size=50 value="" name="highColor"> </TD></TR>
        <TR>
          <TD class=altbg1 vAlign=top width="45%"><B>版块简介:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_4") %></SPAN></TD>
          <TD class=altbg2>
		    <TEXTAREA id="brief" name="brief" rows=3 cols=50 
				style="width:278px"><%= aBoard.brief==null?"":aBoard.brief %></TEXTAREA></TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>版块图标:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_5") %></SPAN></TD>
          <TD class=altbg2><INPUT size=50 name="iconFile" maxlength="100"></TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>本版块关键词:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_6") %></SPAN></TD>
          <TD class=altbg2><INPUT size=50 name="keywords" maxlength="100"></TD></TR>
        <TR>
          <TD class=altbg1 vAlign=top width="45%"><B>特权用户:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_7") %></SPAN></TD>
          <TD class=altbg2>
   <TEXTAREA id="members" name="members" rows=6 cols=50 
	style="width:278px"><%= aBoard.members==null?"":aBoard.members.replace(",",", ") %></TEXTAREA></TD></TR>
	  </TBODY></TABLE><BR>
		<A name=tb03></A>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD colSpan=2>扩展设置<A onClick="collapse_change('tb03','../images')" href="#">
		    <IMG id=menuimg_tb03 style="MARGIN-TOP: -12px; FLOAT: right; MARGIN-RIGHT: 4px" 
             src="../images/menu_reduce.gif" border=0></A></TD></TR>
        <TBODY id=menu_tb03>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>本版块规则:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_8") %></SPAN></TD>
          <TD class=altbg2>
		    <IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('ruleCode', 1)" src="../images/zoomin.gif"> 
			<IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('ruleCode', 0)" src="../images/zoomout.gif">
            <BR><TEXTAREA id="ruleCode" name="ruleCode"  rows=6 cols=50 
				 style="width:278px"><%= aBoard.ruleCode==null?"":aBoard.ruleCode.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;") %></TEXTAREA></TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>界面风格方案:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_9") %></SPAN></TD>
          <TD class=altbg2>
		   	<SELECT name="viewStyle">
<%
	for (int i=0; i<styles.length; i++)
	{
		if (styles[i].name.startsWith("1_"))
		{
%>			
			  <OPTION value="<%= styles[i].name.substring(2) %>"><%= styles[i].value %></OPTION>
<%
		}
	}
%>			
			  </SELECT></TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>是否支持主题分类:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_10") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio value="T" name="isCatOK" id="isCatOK[T]"> 
			支持 &nbsp;&nbsp;
			<INPUT class=radio type=radio CHECKED value="F" name="isCatOK" id="isCatOK[F]"> 
			不支持</TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>是否开启主题评价功能</B><BR><SPAN 
		  	class=smalltxt><%= PageUtils.getString("forum_info_11") %></SPAN></TD>
          <TD class=altbg2>		  
			<INPUT class=radio type=radio value="N" name="scoreType" id="scoreType[N]" checked> 不开启 &nbsp;
			<INPUT class=radio type=radio value="P" name="scoreType" id="scoreType[P]"> 开启&nbsp;-&nbsp;允许游客评价 &nbsp;
			<INPUT class=radio type=radio value="M" name="scoreType" id="scoreType[M]"> 开启&nbsp;-&nbsp;仅会员可以评价 
			</TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>默认主题列表:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_12") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio CHECKED value="all" name="listType" id="listType[all]"> 
			全部主题 &nbsp; 
			<INPUT class=radio type=radio value="hot" name="listType" id="listType[hot]"> 
			热门主题 &nbsp;
			<INPUT class=radio type=radio value="digest" name="listType" id="listType[digest]"> 
			精华主题</TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>主题默认排序方式:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_13") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio CHECKED value="lastPostTime" name="sortField" id="sortField[lastPostTime]"> 
			回复时间&nbsp;-&nbsp;降序 &nbsp; 
			<INPUT class=radio type=radio value="createTime" name="sortField" id="sortField[createTime]"> 
			发布时间&nbsp;-&nbsp;降序<BR>
			<INPUT class=radio type=radio value="A_lastPostTime" name="sortField" id="sortField[A_lastPostTime]"> 
			回复时间&nbsp;-&nbsp;升序 &nbsp; 
			<INPUT class=radio type=radio value="A_createTime" name="sortField" id="sortField[A_createTime]"> 
			发布时间&nbsp;-&nbsp;升序</TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>允许使用 [img] 代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_14") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio CHECKED value="T" name="isImageOK" id="isImageOK[T]"> 是 &nbsp; &nbsp; 
			<INPUT class=radio type=radio value="F" name="isImageOK" id="isImageOK[F]"> 否 </TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>允许使用 [media] 代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_15") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio CHECKED value="T" name="isMediaOK" id="isMediaOK[T]"> 是 &nbsp; &nbsp; 
			<INPUT class=radio type=radio value="F" name="isMediaOK" id="isMediaOK[F]"> 否 </TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>允许游客发贴:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_16") %></SPAN></TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio value="T" name="isGuestPostOK" id="isGuestPostOK[T]"> 是 &nbsp; &nbsp; 
			<INPUT class=radio type=radio CHECKED value="F" name="isGuestPostOK" id="isGuestPostOK[F]"> 否 </TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>页首广告代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_17") %></SPAN></TD>
          <TD class=altbg2>
		    <IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('headAdCode', 1)" src="../images/zoomin.gif"> 
			<IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('headAdCode', 0)" src="../images/zoomout.gif">
            <BR><TEXTAREA id="headAdCode" name="headAdCode" rows=6 cols=50 
				 style="width:278px"><%= aBoard.headAdCode==null?"":aBoard.headAdCode.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;") %></TEXTAREA></TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>页脚广告代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_18") %></SPAN></TD>
          <TD class=altbg2>
		    <IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('footAdCode', 1)" src="../images/zoomin.gif"> 
			<IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('footAdCode', 0)" src="../images/zoomout.gif">
            <BR><TEXTAREA id="footAdCode" name="footAdCode" rows=6 cols=50 
				 style="width:278px"><%= aBoard.footAdCode==null?"":aBoard.footAdCode.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")  %></TEXTAREA> </TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>主题尾部广告代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("forum_info_19") %></SPAN></TD>
          <TD class=altbg2>
		    <IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('topicAdCode', 1)" src="../images/zoomin.gif"> 
			<IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('topicAdCode', 0)" src="../images/zoomout.gif">
            <BR><TEXTAREA id="topicAdCode" name="topicAdCode" rows=6 cols=50 
				 style="width:278px"><%= aBoard.topicAdCode==null?"":aBoard.topicAdCode.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")  %></TEXTAREA> </TD></TR>
	</TBODY></TABLE><BR>
	<A name=tb04></A>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD>版块权限</TD>
          <TD>浏览版块</TD>
          <TD>发新话题</TD>
          <TD>发表回复</TD>
          <TD>下载/查看附件</TD>
          <TD>上传附件</TD></TR>
<%
	if (groups != null)
	{
		GroupVO aGroup = null;
		String checked1 = null;
		String checked2 = null;
		String checked3 = null;
		String checked4 = null;
		String checked5 = null;
		String empty = "";
		String checked = null;
			
		for (int i=0; i<groups.size(); i++)	
		{
			aGroup = (GroupVO)groups.get(i);
			if (aBoard.allowGroups == null 
				|| aBoard.allowGroups.indexOf(String.valueOf(aGroup.groupID)) >= 0)
				checked = "checked";
			else
				checked = "";

			if (PageUtils.isPermitted(aBoard,aGroup,null,IConstants.PERMIT_VISIT_FORUM)) checked1 = "checked"; else checked1 = "";
			if (PageUtils.isPermitted(aBoard,aGroup,null,IConstants.PERMIT_NEW_TOPIC)) checked2 = "checked"; else checked2 = "";
			if (PageUtils.isPermitted(aBoard,aGroup,null,IConstants.PERMIT_NEW_REPLY)) checked3 = "checked"; else checked3 = "";
			if (PageUtils.isPermitted(aBoard,aGroup,null,IConstants.PERMIT_DOWNLOAD)) checked4 = "checked"; else checked4 = "";
			if (PageUtils.isPermitted(aBoard,aGroup,null,IConstants.PERMIT_UPLOAD)) checked5 = "checked"; else checked5 = "";
%>			
        <TR>
          <TD class=altbg1>
		  	<INPUT class=checkbox title=选中 type=checkbox <%= checked %>
				name="allowGroups" id="allowGroups[<%= aGroup.groupID %>]" 
				value="<%= aGroup.groupID %>" onclick="changeGroups('<%= aGroup.groupID %>')"/> <%= aGroup.groupName %></TD>
          <TD class=altbg2>&nbsp;&nbsp;&nbsp;<INPUT class=checkbox title=选中 type=checkbox <%= checked1 %>
				name="visitGroups" id="visitGroups[<%= aGroup.groupID %>]" 
				value="<%= aGroup.groupID %>" onclick="toggleGroups('<%= aGroup.groupID %>')"/></TD>
          <TD class=altbg1>&nbsp;&nbsp;&nbsp;<INPUT class=checkbox title=选中 type=checkbox <%= checked2 %>
				name="topicGroups" id="topicGroups[<%= aGroup.groupID %>]" 
				value="<%= aGroup.groupID %>" onclick="toggleGroups('<%= aGroup.groupID %>')"/></TD>
          <TD class=altbg2>&nbsp;&nbsp;&nbsp;<INPUT class=checkbox title=选中 type=checkbox <%= checked3 %>
				name="replyGroups" id="replyGroups[<%= aGroup.groupID %>]" 
				value="<%= aGroup.groupID %>" onclick="toggleGroups('<%= aGroup.groupID %>')"/></TD>
          <TD class=altbg1>&nbsp;&nbsp;&nbsp;<INPUT class=checkbox title=选中 type=checkbox <%= checked4 %>
				name="downloadGroups" id="downloadGroups[<%= aGroup.groupID %>]" 
				value="<%= aGroup.groupID %>" onclick="toggleGroups('<%= aGroup.groupID %>')"/></TD>
          <TD class=altbg2>&nbsp;&nbsp;&nbsp;<INPUT class=checkbox title=选中 type=checkbox <%= checked5 %>
				name="uploadGroups" id="uploadGroups[<%= aGroup.groupID %>]" 
				value="<%= aGroup.groupID %>" onclick="toggleGroups('<%= aGroup.groupID %>')"/></TD></TR>
<%
		}
	}
%>			
       </TBODY></TABLE><BR>
      <CENTER><INPUT class=button type=submit value="提 交"></CENTER></FORM>
	  </TD></TR></TBODY></TABLE><BR><BR>
<script language="javascript">
function checkfields(theform) {
	if (trim(theform.boardName.value) == '') {
		alert('板块名称不可以为空');
      	theform.sectionName.focus();
		return;
	}
	if ((trim(theform.brief.value)).length > 100) {
		alert('版块简介不能超过100个字符');
      	theform.brief.focus();
		return;
	}
	theform.submit();
}
function toggleGroups(id) {
	if ($('visitGroups['+id+']').checked || $('topicGroups['+id+']').checked
		|| $('replyGroups['+id+']').checked || $('downloadGroups['+id+']').checked || $('uploadGroups['+id+']').checked)
	{
		$('allowGroups['+id+']').checked = true;
	}
	else
	{
		$('allowGroups['+id+']').checked = false;
	}
}
function changeGroups(id) {
	if ($('allowGroups['+id+']').checked)
	{
		$('visitGroups['+id+']').checked = true;
		$('topicGroups['+id+']').checked = true;
		$('replyGroups['+id+']').checked = true;
		$('downloadGroups['+id+']').checked = true;
		$('uploadGroups['+id+']').checked = true;
	}
	else
	{
		$('visitGroups['+id+']').checked = false;
		$('topicGroups['+id+']').checked = false;
		$('replyGroups['+id+']').checked = false;
		$('downloadGroups['+id+']').checked = false;
		$('uploadGroups['+id+']').checked = false;
	}
}
$('settings').sectionID.value = "<%= sectionID %>";
$('settings').oldSectionID.value = "<%= sectionID %>";
$('settings').boardID.value = "<%= aBoard.boardID %>";
$('settings').boardName.value = "<%= aBoard.boardName %>";
$('settings').highColor.value = "<%= aBoard.highColor==null?"":aBoard.highColor %>";
$('state[<%= aBoard.state %>]').checked = true;
$('settings').iconFile.value = "<%= aBoard.iconFile==null?"":aBoard.iconFile %>";
$('settings').keywords.value = "<%= aBoard.keywords==null?"":aBoard.keywords %>";
$('settings').viewStyle.value = "<%= aBoard.viewStyle==null?"default":aBoard.viewStyle %>";
$('sortField[<%= aBoard.sortField==null?"lastPostTime":aBoard.sortField %>]').checked = true;
$('isImageOK[<%= aBoard.isImageOK %>]').checked = true;
$('isMediaOK[<%= aBoard.isMediaOK %>]').checked = true;
$('isGuestPostOK[<%= aBoard.isGuestPostOK %>]').checked = true;
$('isCatOK[<%= aBoard.isCatOK %>]').checked = true;
$('listType[<%= aBoard.listType==null||aBoard.listType.length()==0?"all":aBoard.listType %>]').checked = true;
$('scoreType[<%= aBoard.scoreType %>]').checked = true;
</script>
<%= PageUtils.getAdminFooter(request) %>
</BODY></HTML>
