<!--#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 id,act,adminname,PassWord,UserType,roleArr,classlimit,classids
act=request.QueryString("act")
id=Cint(request("id"))
if(act="mod") 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")
	rs.open "select * from role where rolename='"&rolename&"' and id<>"&id,conn,3,1
	if not rs.eof then
		response.Write("<script>alert(""该角色已存在!"");history.back();</script>")
		response.End()
	end if
	rs.close
	sql="select top 1 * from role where id="&id&" order by id desc "
	rs.open sql,conn,3,3	
	rs("rolename")=rolename
	rs("privilege")=privilege
	rs("classlimit")=classlimit
	rs("classids")=classids
	rs("moditime")=now	
	rs.update
	rs.close
	set rs=nothing
	response.Write("修改角色成功~!<p>")
	response.Write("<br><p><center><a href=role_manage.asp>返回</a></center>")
else
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 rolename,privilege,classlimit,classids from role where id="&id&" order by id desc "
	rs.open sql,conn,3,1	
	if rs.eof or rs.bof then
		response.Write("没有找到ID为"&id&"的记录！")
		response.End()
	else
		roleArr=rs.GetRows()
	end if
	rs.close
	set rs=nothing
%>
<FORM method="POST" name="form1" action="role_mod.asp?act=mod" 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" value="<%=roleArr(0,0)%>"></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" <%if instr(1,roleArr(1,0),"p01",1)<>0 then response.Write("checked") %>>
   栏目管理</p>   
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilege2" value="p02" <%if instr(1,roleArr(1,0),"p02",1)<>0 then response.Write("checked") %> onClick="chanClassLimit(this);">
 新闻总管理</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext1" value="pext01" <%if instr(1,roleArr(1,0),"pext01",1)<>0 then response.Write("checked") %> onClick="chanClassLimit(this);">
 新闻添加</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext2" value="pext02" <%if instr(1,roleArr(1,0),"pext02",1)<>0 then response.Write("checked") %> onClick="chanClassLimit(this);">
 新闻修改</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext3" value="pext03" <%if instr(1,roleArr(1,0),"pext03",1)<>0 then response.Write("checked") %> onClick="chanClassLimit(this);">
 新闻删除</p>
 <p style="margin:0px;">
    <input name="privilege" type="checkbox" id="privilegeext4" value="pext04" <%if instr(1,roleArr(1,0),"pext04",1)<>0 then response.Write("checked") %> onClick="chanClassLimit(this);">
 新闻审核</p>
 <p style="margin:0px;">
 <input name="privilege" type="checkbox" id="privilegeext5" value="pext05" <%if instr(1,roleArr(1,0),"pext05",1)<>0 then response.Write("checked") %>>
 新闻回收站</p>
 <div id="limitset" style="margin:0px; display:block;">
      <input name="classlimit" type="radio" value="0" <%if(Cint(roleArr(2,0))=0) then response.Write("checked=""checked""") end if%> onClick="hidclassids(this)">
	拥有所有栏目权限<br>
    <input name="classlimit" type="radio" value="1" <%if(Cint(roleArr(2,0))=1) then response.Write("checked=""checked""") end if%>  onClick="showclassids(this)">
拥有指定栏目权限<br>
<div id="classidsdiv" style="display:none;">
<textarea name="classids" cols="50" rows="5" id="classids"><%=roleArr(3,0)%><%if(roleArr(3,0)<>0) then response.Write(",") end if%></textarea>
    &gt;&gt;<a href="#" onClick="selectClass();">选择拥有管理权限的栏目</a>
</div>
</div>
    <p>
    <input name="privilege" type="checkbox" id="privilege3" value="p03" <%if instr(1,roleArr(1,0),"p03",1)<>0 then response.Write("checked") %>>
 模板管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege4" value="p04" <%if instr(1,roleArr(1,0),"p04",1)<>0 then response.Write("checked") %>>
 标签管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege5" value="p05" <%if instr(1,roleArr(1,0),"p05",1)<>0 then response.Write("checked") %>>
 发布站点</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege6" value="p06" <%if instr(1,roleArr(1,0),"p06",1)<>0 then response.Write("checked") %>>
 管理员管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege7" value="p07" <%if instr(1,roleArr(1,0),"p07",1)<>0 then response.Write("checked") %>>
 评论管理</p>
    <p>
    <input name="privilege" type="checkbox" id="privilege8" value="p08" <%if instr(1,roleArr(1,0),"p08",1)<>0 then response.Write("checked") %>>
 友情链接</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege9" value="p09" <%if instr(1,roleArr(1,0),"p09",1)<>0 then response.Write("checked") %>>
 信息采集</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege10" value="p10" <%if instr(1,roleArr(1,0),"p10",1)<>0 then response.Write("checked") %>>
 数据库管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege11" value="p11" <%if instr(1,roleArr(1,0),"p11",1)<>0 then response.Write("checked") %>>
系统配置管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege12" value="p12" <%if instr(1,roleArr(1,0),"p12",1)<>0 then response.Write("checked") %>>
日志管理</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege13" value="p13" <%if instr(1,roleArr(1,0),"p13",1)<>0 then response.Write("checked") %>>
      投票管理
</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege14" value="p14" <%if instr(1,roleArr(1,0),"p14",1)<>0 then response.Write("checked") %>>
      广告管理
</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege15" value="p15" <%if instr(1,roleArr(1,0),"p15",1)<>0 then response.Write("checked") %>>
任务计划</p>
    <p>
      <input name="privilege" type="checkbox" id="privilege16" value="p16" <%if instr(1,roleArr(1,0),"p16",1)<>0 then response.Write("checked") %>>
资源管理</p>
	<p>
      <input name="privilege" type="checkbox" id="privilege17" value="p17" <%if instr(1,roleArr(1,0),"p17",1)<>0 then response.Write("checked") %>>
直播管理</p>
	<p>
      <input name="privilege" type="checkbox" id="privilege18" value="p18" <%if instr(1,roleArr(1,0),"p18",1)<>0 then response.Write("checked") %>>
自定义表单管理</p>
	<p>
      <input name="privilege" type="checkbox" id="privilege19" value="p19" <%if instr(1,roleArr(1,0),"p19",1)<>0 then response.Write("checked") %>>
下载管理</p>
	<p>
      <input name="privilege" type="checkbox" id="privilege20" value="p20" <%if instr(1,roleArr(1,0),"p20",1)<>0 then response.Write("checked") %>>
会员管理</p>
<p>
      <input name="privilege" type="checkbox" id="privilege24" value="p24" <%if instr(1,roleArr(1,0),"p24",1)<>0 then response.Write("checked") %>>
问答管理</p>
<p>
      <input name="privilege" type="checkbox" id="privilege25" value="p25" <%if instr(1,roleArr(1,0),"p25",1)<>0 then response.Write("checked") %>>
PK管理</p>
<p>
      <input name="privilege" type="checkbox" id="privilege26" value="p26" <%if instr(1,roleArr(1,0),"p26",1)<>0 then response.Write("checked") %>>
模型管理</p>
<p>
      <input name="privilege" type="checkbox" id="privilege27" value="p27" <%if instr(1,roleArr(1,0),"p27",1)<>0 then response.Write("checked") %>>
旅游线路管理</p>
<p>
      <input name="privilege" type="checkbox" id="privilege28" value="p27" <%if instr(1,roleArr(1,0),"p27",1)<>0 then response.Write("checked") %>>
酒店管理</p>
<p>
      <input name="privilege" type="checkbox" id="privilege29" value="p29" <%if instr(1,roleArr(1,0),"p29",1)<>0 then response.Write("checked") %>>
景点门票管理</p>
  </div></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD align=right>&nbsp;	  </TD>
    <TD align=right><div align="left"> 
	<input type="hidden" name="id" value="<%=id%>">
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
%>
<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]+',';
		}
  	}	
}
<%
if(instr(1,roleArr(1,0),"p02",1)<>0) then
	response.Write("document.getElementById('limitset').style.display='block';")
end if
if(Cint(roleArr(2,0))=1) then
	response.Write("document.getElementById('classidsdiv').style.display='block';")
end if
%>
</script>
</BODY>
</HTML>
<%
call connclose()
%>