<!-- #include file="Setup.asp" --><%
if SiteSettings("AdminPassword")<>session("pass") then response.redirect "Admin_Default.asp?menu=Login"
Log("")
Roleid=HTMLEncode(Request("Roleid"))
RoleName=HTMLEncode(Request("RoleName"))
Description=HTMLEncode(Request("Description"))

AdminTop

select case Request("menu")
case ""
Default

case "CreateRole"
if RoleName=empty then error2("您没有输入角色名称")
Conn.Execute("insert into [BBSXP_Roles] (Name) values ('"&RoleName&"')")
Default

case "ViewRole"
ViewRole

case "UpRole"
if RoleName=empty then error2("您没有输入角色名称")
<!-----附件分组设置------>
if not IsNumeric(Request("Maxup")) then error2("上传容量应为数字")
Maxup=int(Request("Maxup"))
if not IsNumeric(Request("Maxup2")) then error2("单贴附件大小应为数字")
Maxup2=int(Request("Maxup2"))
<!-----附件分组设置------>
Conn.execute("update [BBSXP_Roles] set Name='"&RoleName&"',Description='"&Description&"',Maxup="&Maxup&",Maxup2="&Maxup2&" where id="&Roleid&"")
%>编辑成功<br><br><a href=javascript:history.back()>&lt; 返 回 &gt;</a><%

case "DelRole"
if Roleid<4 then error2("该角色为系统内置角色，无法删除")
if Not Conn.Execute("Select ID From [BBSXP_Users] where UserRoleID="&Roleid&"" ).eof then error2("只能删除没有成员的角色组！")


Conn.execute("Delete from [BBSXP_Roles] where id="&Roleid&"")
%>删除成功<br><br><a href=javascript:history.back()>&lt; 返 回 &gt;</a><%

end select

sub Default
%><b>角色管理</b><br>创建/编辑角色，用来控制一个用户在制定版块的权限。<br>
<table cellspacing="1" cellpadding="2" width="100%" border="0" class="a2" align="center">
	<tr class="a1">
		<td align="center" height="25">角色管理</td>
	</tr>
	<%
sql="select * from [BBSXP_Roles] order by id"
Set Rs=Conn.Execute(sql)
Do While Not Rs.EOF 
%>
	<tr class="a4">
		<td height="25"><a href="?menu=ViewRole&RoleId=<%=Rs("id")%>">
		<b><%=Rs("Name")%></b></a><br>
		<%=Rs("Description")%></td>
	</tr>
	<%
Rs.MoveNext
loop
Rs.Close
%>
	<tr class="a4">
		<td>
		<form name="form" method="POST" action="?menu=CreateRole">
			<input name="RoleName" onKeyUp="ValidateTextboxAdd(this, 'RoleName1')" onpropertychange="ValidateTextboxAdd(this, 'RoleName1')" size="50"><input type="submit" value="创建" id="RoleName1" disabled>
		</td>
	</tr></form>
</table>
<%
end sub

sub ViewRole

if  RoleId<4 then PostDisabled="disabled"

Rs.Open "select * from [BBSXP_Roles] where id="&RoleId&"",Conn,1
%><form name="form" method="POST" action="?menu=UpRole&RoleId=<%=RoleId%>">
	<table cellspacing="1" cellpadding="2" width="100%" border="0" class="a2" align="center">
		<tr class="a1">
			<td align="center" height="25" colspan="2">角色管理</td>
		</tr>
		<tr class="a4">
			<td height="25">ID</td>
			<td width="50%" height="25"><%=Rs("id")%></td>
		</tr>
		<tr class="a3">
			<td height="25">名称</td>
			<td width="50%" height="25">
			<input name="RoleName" size="50" value="<%=Rs("Name")%>"></td>
		</tr>
		<tr class="a4">
			<td height="25">描述</td>
			<td width="50%" height="25">
			<input name="Description" size="50" value="<%=Rs("Description")%>"></td>
		</tr>

		<tr class="a3">
			<td colspan="2" align="right">
			<input <%=PostDisabled%> type="button" value="删除" onClick="document.location.href='?menu=DelRole&amp;RoleId=<%=RoleId%>'"><input type="submit" value="保存"></td>
		</tr>
	</table>
</form><a href=javascript:history.back()>&lt; 返 回 &gt;</a>
<%
Rs.close

end sub

htmlend

%>