<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<HTML>
<HEAD>
<TITLE>添加角色</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p0000")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,adminname,PassWord,UserType,classlimit,classids
act=request.QueryString("act")

if(act="add") then	
	rolename=trim(request.Form("rolename"))
	privilege=request.Form("privilege")
	classlimit=Cint(request.Form("classlimit"))
	if(classlimit=0) then
		classids="0"
	else
		classids=request.Form("classids")
		if(right(classids,1)=",") then
			classids=left(classids,len(classids)-1)
		end if
	end if
	'添加到库
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from role where rolename='"&rolename&"' order by id desc "
	rs.open sql,conn,3,3
	if not rs.eof then
		response.Write("<script>alert(""该角色已存在!"");history.back();</script>")
		response.End()
	else		
		rs.addnew
		rs("rolename")=rolename
		rs("privilege")=privilege
		rs("classlimit")=classlimit
		rs("classids")=classids
		rs("moditime")=now	
		rs.update	
		response.Write("<p align=""center"">添加角色成功~!</p>")
		response.Write("<p align=""center""><br><a href=role_add.asp>返回</a></p>")
	end if
	rs.close
	set rs=nothing
else
%>
<FORM method="POST" name="form1" action="role_add.asp?act=add" style="margin:0 0 0 0;">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style1">添加角色</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="14%"><div align="center">角色名称：</div></TD>
  <TD width="86%"><input name="rolename" type="text" id="rolename" size="30"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">角色权限：</div></TD>
  <TD><div align="left">
    <p>
     <input name="privilege" type="checkbox" id="privilege" value="p01">
   栏目管理</p>    
	<p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilege2" value="p02" onClick="chanClassLimit(this);">
 新闻总管理</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext1" value="pext01" onClick="chanClassLimit(this);">
 新闻添加</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext2" value="pext02" onClick="chanClassLimit(this);">
 新闻修改</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext3" value="pext03" onClick="chanClassLimit(this);">
 新闻删除</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext4" value="pext04" onClick="chanClassLimit(this);">
 新闻审核</p>
 <p style="margin:0px;">
 <input name="privilege" type="checkbox" id="privilegeext5" value="pext05">
 新闻回收站</p>
 <div id="limitset" style="margin:0px; display:none;">
      <input name="classlimit" type="radio" value="0" checked="checked" onClick="hidclassids(this)">
	拥有所有栏目权限<br>
    <input name="classlimit" type="radio" value="1" onClick="showclassids(this)">
拥有指定栏目权限<br>
<div id="classidsdiv" style="display:none;">
<textarea name="classids" cols="50" rows="5" id="classids"></textarea>
    &gt;&gt;<a href="#" onClick="selectClass();">选择拥有管理权限的栏目</a>
	</div></div>
    <p>
    <input name="privilege" type="checkbox" id="privilege3" value="p03">
 模板管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege4" value="p04">
 标签管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege5" value="p05">
 发布站点</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege6" value="p06">
 管理员管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege7" value="p07">
 评论管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege8" value="p08">
 友情链接</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege9" value="p09">
 信息采集</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege10" value="p10">
 数据库管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege11" value="p11">
系统配置管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege12" value="p12">
日志管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege13" value="p13">
      投票管理 </p>
    <p>
      <input name="privilege" type="checkbox" id="privilege16" value="p14"> 
      广告管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege17" value="p15">
      任务计划 </p>
    <p>
      <input name="privilege" type="checkbox" id="privilege16" value="p16">
资源管理</p>
	<p>
      <input name="privilege" type="checkbox" id="privilege17" value="p17">
直播管理</p>
    <p>
	 <input name="privilege" type="checkbox" id="privilege18" value="p18">
自定义表单管理</p>
	<p>
<input name="privilege" type="checkbox" id="privilege19" value="p19">
下载管理</p>
<p>
<input name="privilege" type="checkbox" id="privilege20" value="p20">
会员管理</p>

<input name="privilege" type="checkbox" id="privilege24" value="p24">
问答管理</p>
<p>
<input name="privilege" type="checkbox" id="privilege25" value="p25">
PK管理</p>
<p>
<input name="privilege" type="checkbox" id="privilege26" value="p26">
模型管理</p>
<p><input name="privilege" type="checkbox" id="privilege27" value="p27">
旅游线路管理</p>
<p><input name="privilege" type="checkbox" id="privilege28" value="p28">
酒店管理</p>
<p><input name="privilege" type="checkbox" id="privilege29" value="p29">
景点门票管理</p>
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<script language="javascript">
function chanClassLimit(obj){
	if(obj.checked==true){
		document.getElementById('limitset').style.display='block';
	}else{
		document.getElementById('limitset').style.display='none';
	}
}
function hidclassids(obj){
	if(obj.checked==true){
		document.getElementById('classidsdiv').style.display='none';
	}else{
		document.getElementById('classidsdiv').style.display='block';
	}
}
function showclassids(obj){
	if(obj.checked==true){
		document.getElementById('classidsdiv').style.display='block';
	}else{
		document.getElementById('classidsdiv').style.display='none';
	}
}
function selectClass(){
	var arr = showModalDialog("tree_container.asp", "", "dialogWidth:410px; dialogHeight:420px; status:0");
	var classids=document.form1.classids.value;
  	if (arr != null){ 
		var tempArr = new Array();
		if(classids!=""){
			tempArr=classids.split(",");
			for(i=0;i<tempArr.length;i++){
				if(tempArr[i]==arr[0]){
					alert("该栏目已经添加过了!");
					return;
				}
			}
			document.form1.classids.value+=arr[0]+',';
		}else{
			document.form1.classids.value=arr[0]+',';
		}
  	}	
}
</script>
<%
end if
%>
</BODY>
</HTML>
<%
call connclose()
%>