<!--#include file="../fy.Function.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>权限管理</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
</head>
<body>
<div class="content"> 
	   <%
 If Not fycms.ChkAdmin() Then '超级管理员检测
	Call fycms.fycmsErr("")
 End If 
	Dim Purview,Admin_Name
	Public Function fycms_QX(QXLX,QXID,ACT)
	dim arrTemp,i,L,ACT_ClassID
	arrTemp=split(QXLX,",")
	For I=LBound(arrTemp) To Ubound(arrTemp)
		if InStr(arrTemp(I),QXID) > 0 Then
			ACT_ClassID=split(arrTemp(I),"-")
				If  ACT_ClassID(ACT)>0 then
					fycms_QX=True
				Else
					fycms_QX=False
				End if
		End  If 
	next 
	End Function
	
	Dim AdminID,Rs,HQQXLX
	AdminID = ChkNumeric(fycms.S("AdminID"))
	IF AdminID  = 1 Then
		Call fycms.alert("非法操作,系统创建者禁止修改!" ,"")
	End If 
	Set RS=fycms.ActExe("Select * from Admin_fy Where Id = "&AdminID&" order by ID desc")
	if rs.eof then
		Call fycms.Alert("参数错误","")
		response.End
	Else
		HQQXLX=rs("fycms_QXLX")
		Purview=rs("Purview")
		Admin_Name=rs("Admin_Name")
	End  If
	Public Function fycms_HQQX(HQQXID,HQACT)
	If Trim(HQQXLX)="" Then Exit Function 
	On Error Resume Next
	Dim HQarrTemp,HQi,HQL,HQACT_ClassID
	HQarrTemp=split(HQQXLX,",")'
		For HQI=LBound(HQarrTemp) To Ubound(HQarrTemp)'遍历
			if InStr(HQarrTemp(HQI),HQQXID) > 0 Then
				HQACT_ClassID=Split(HQarrTemp(HQI),"-")
				If UBound(HQACT_ClassID)>0 Then 
					If HQACT_ClassID(1)=HQACT Then
						fycms_HQQX=True
						Exit Function
					Else	
						fycms_HQQX=False
					End If 
				End if
			End  If 
		Next 
	End Function
  If fycms.S("Action")= "Save" Then
	  Dim AdminRS,AdminSql,CountM,I,Purviews
	  AdminID = AdminID
	  CountM=fycms.ACTEXE("Select Count(ModeID) From Mode_fy")(0)
	For I=1 To CountM
		Purviews=Purviews& Replace(request.Form("Purview-" & I &""),",","") & ","
	Next
	  Set AdminRS = Server.CreateObject("adodb.recordset")
	  AdminSql = "select * from Admin_fy Where ID="&AdminID
	  AdminRS.Open AdminSql, Conn, 1, 3
	  AdminRS("fycms_QXLX") = Replace(fycms.S("fycms_QXLX") , " ", "")
	  AdminRS("SuperTF") = ChkNumeric(fycms.S("SuperTF"))
	  AdminRS("Purview") = Purviews
	  AdminRS("ACT_Other") = Replace(fycms.S("ACT_Other") , " ", "")
	  AdminRS.Update
	  AdminRS.Close:Set AdminRS = Nothing	
  	  Call fycms.ActErr("管理员权限修改成功","admin/index.asp","")
 	End If 
%> <div class="breadnav">当前位置：<a href="#">后台首页</a> >> 修改 <%=Admin_Name%> 管理权限</div>

<form name="ClassForm" method="post" action="?Action=Save&AdminID=<%=ChkNumeric(fycms.S("AdminID"))%>">
    <div class="divtable"> 
        <dl>
            <dt>用 户 名：</dt>
            <dd>
             <%= rs("Admin_Name") %> 
	  
	  <input <% IF rs("SuperTF") = 1 Then echo " checked=""checked""" %> type="checkbox" id="SuperTF" name="SuperTF" value="1">
      <LABEL for="SuperTF"><font color=red>超级管理员 拥有所有权限</font></LABEL>
            </dd>
         </dl>

		 <% 
Dim ModeName,ModeID,Rs1
Set Rs1 =fycms.ACTEXE("SELECT ModeID, ModeName,ModeTable, ModeStatus, IFmake,ModeNote  FROM Mode_fy where ModeStatus=0 order by ModeID asc")
	 If Rs1.EOF  Then
	 	echo	"<tr><td colspan=""6"" align=""center"">没有记录</td></tr>"
	 Else
		Dim q:q=1
		Do While Not Rs1.EOF	
		ModeName=Rs1("ModeName")
		ModeID=Rs1("ModeID")
			 %>
        <dl>
            <dt><%= ModeName %>系统权限设置：</dt>
            <dd>
              <input <% IF fycms.FoundInArr(rs("Purview"),"ACT"&Rs1("ModeID")&"-ACT",",") Then echo " checked" %>  type="radio" name="Purview-<%=q%>"   id="Purview1<%=Rs1("ModeID")%>" onClick="SuperTFT<%=Rs1("ModeID")%>.style.display='none';"  value="<%="ACT"&Rs1("ModeID")%>-ACT">
       <LABEL for="Purview1<%=Rs1("ModeID")%>"> 在<%= ModeName %>系统无任何管理权限(屏蔽)</LABEL><br>
          <input <% IF fycms.FoundInArr(rs("Purview"),"TCJ"&Rs1("ModeID")&"-TCJ",",") Then echo " checked" %> type="radio" name="Purview-<%=q%>"  onclick="SuperTFT<%=Rs1("ModeID")%>.style.display='none';"  id="Purview2<%=Rs1("ModeID")%>" value="<%="TCJ"&Rs1("ModeID")%>-TCJ">
     <LABEL for="Purview2<%=Rs1("ModeID")%>">模型管理员：拥有此模型的所有管理权限(相当于对<%= ModeName %>系统没有任何限制)</LABEL>
      <br>
	 <input <% IF fycms.FoundInArr(rs("Purview"),"DXR"&Rs1("ModeID")&"-DXR",",") Then echo " checked" %> type="radio" name="Purview-<%=q%>" value="<%="DXR"&Rs1("ModeID")%>-DXR"  id="Purview3<%=Rs1("ModeID")%>"   onclick="SuperTFT<%=Rs1("ModeID")%>.style.display='';"    >
	 <LABEL for="Purview3<%=Rs1("ModeID")%>">栏目管理员：需要详细指定每个栏目的权限</LABEL>

            </dd>
         </dl>
 <dl  id="SuperTFT<%=Rs1("ModeID")%>" <% IF fycms.FoundInArr(rs("Purview"),"DXR"&Rs1("ModeID")&"-DXR",",")=false Then echo " style=""display:none""" %>>
   <dt>栏目权限设置</dt>
	
            <dd>
             <%=ClassPurview(Rs1("ModeID"))&"</table>"%>

            </dd>
         </dl>


		 <% 
		q=q+1
		Rs1.movenext
		Loop
	End if	 %>
       
	   
        <dl>
            <dt>其他权限设置</dt>
            <dd>
             <input <% IF Instr(rs("ACT_Other"),"editmypassword")>0 Then echo " checked=""checked""" %>  type="checkbox" name="ACT_Other" value="editmypassword">
          修改自己密码
        <input <% IF Instr(rs("ACT_Other"),"rzgl")>0 Then echo " checked=""checked""" %>  type="checkbox" name="ACT_Other" value="rzgl">
          日志管理
       <input <% IF Instr(rs("ACT_Other"),"sjkwh")>0 Then echo " checked=""checked""" %> type="checkbox" name="ACT_Other" value="sjkwh">
          数据库维护
       <input <% IF Instr(rs("ACT_Other"),"zxtgl")>0 Then echo " checked=""checked""" %> type="checkbox" name="ACT_Other" value="zxtgl">
          子系统管理
             <input <% IF Instr(rs("ACT_Other"),"bqxt")>0 Then echo " checked=""checked""" %> type="checkbox" name="ACT_Other" value="bqxt">
          标签系统
            </dd>
         </dl>
      
    
       
        <dl>
            <dt>插件系统</dt>
            <dd>
             <%= CheckPlus("ACT_Other",rs("ACT_Other"),3) %>

            </dd>
         </dl>
      
       
 
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
				<input type="Submit"  class="btn btn_primary"  name=Submit1 value="保存" />
 				<input class="btn" type="reset" name="Submit2" value="重置">
            </dd>
         </dl>
        
    </div>
    </form>


</div>
  <%Function ClassPurview(ModeID) %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
	
		<tr class="bg_tr">
			<td width="5%" height="25" class="bg_tr">
				<div align="center">ID</div>			</td>
			<td width="30%" >
				<div align="center">栏名称</div>			</td>
		  <td align="center"  width="500">权限类型</td>
	    </tr>
		<%
	Dim Article_rs,Article_rs_1,ChangesLink
	Set Article_rs = Server.CreateObject("adodb.recordset")
	Article_rs.Open "Select Orderid,id,ClassID,ClassName,enname,ClassEName, actlink,ismenu,tg from Class_fy where rootid=0  And ModeID="&ModeID&"    Order by Orderid asc,ID asc",Conn,1,1
	if Article_rs.eof then
	   echo"<TR  ><TD colspan=""5""   height=""40"">没有记录</TD></TR>"
	else
	
	do while not Article_rs.eof
			if Article_rs.eof Then exit do
	%>
		<tr>
			<td height="22" ><div align="center"><%= Article_rs("ID") %></div></td>
			<td height="22" >
				<% 
			echo  "<img src=""../images/-.gif"" />"&Article_rs("ClassName")
		Set Article_rs_1 = server.CreateObject("adodb.recordset")
		%></td>
				<td  align="center">
<input <%If fycms_HQQX(Article_rs("ClassID"),"1")=true Then echo "Checked "%> name="fycms_QXLX" type="checkbox" id="fycms_QXLX1<%= Article_rs("ID") %>" value="<%=Article_rs("ClassID")&"-1"%>">
<label for="fycms_QXLX1<%=Article_rs("ID") %>">管理</label>  
<input <%If fycms_HQQX(Article_rs("ClassID"),"2")=true Then echo "Checked "%> name="fycms_QXLX" type="checkbox" id="fycms_QXLX2<%= Article_rs("ID") %>" value="<%=Article_rs("ClassID")&"-2"%>">
<label for="fycms_QXLX2<%= Article_rs("ID") %>">增加</label>    
<input <%If fycms_HQQX(Article_rs("ClassID"),"3")=true Then echo "Checked "%> name="fycms_QXLX" type="checkbox" id="fycms_QXLX3<%= Article_rs("ID") %>" value="<%=Article_rs("ClassID")&"-3"%>">
<label for="fycms_QXLX3<%= Article_rs("ID") %>">修改</label>    
<input <%If fycms_HQQX(Article_rs("ClassID"),"4")=true Then echo "Checked "%> name="fycms_QXLX" type="checkbox" id="fycms_QXLX4<%= Article_rs("ID") %>" value="<%=Article_rs("ClassID")&"-4"%>">
<label for="fycms_QXLX4<%= Article_rs("ID") %>">删除</label>   
<input <%If fycms_HQQX(Article_rs("ClassID"),"5")=true Then echo "Checked "%> name="fycms_QXLX" type="checkbox" id="fycms_QXLX5<%= Article_rs("ID") %>" value="<%=Article_rs("ClassID")&"-5"%>">
<label for="fycms_QXLX5<%= Article_rs("ID") %>">审核</label></td>
		</tr>
		<%
		echo(GetClassValue(Article_rs("ClassID"),""))
		Article_rs.MoveNext
	Loop
	Article_rs.close
	End if
	End Function 
	Public Function GetClassValue(TypeID,CompatStr)  
		Dim tg,ismenu,ClassRs,TempStr,CMS_isUrl
		Set ClassRs = Conn.Execute("Select id,ismenu,orderid,ClassName,tg,ClassEName,enname,ClassID,actlink from Class_fy where rootid=" & TypeID & "  order by Orderid desc,id desc" )
		TempStr =CompatStr & "<img src=""../images/L.gif""></img>"
		do while Not ClassRs.Eof
	  		GetClassValue = GetClassValue & "<tr >"&Chr(13) & Chr(10)
			GetClassValue = GetClassValue & "<td  align=""center"">"& ClassRs("id")&"</td>" & Chr(13) & Chr(10)
			CMS_isUrl = "&nbsp;["& ModeName &"："&Conn.Execute("Select Count(id) From Article Where Classid=" & ClassRs("ClassID")&"")(0)&"]"
			GetClassValue = GetClassValue & "<td >"& TempStr &"<Img src=""../images/-.gif"" />"&ClassRs("ClassName")&" </td>" & Chr(13) & Chr(10) 
			GetClassValue = GetClassValue & "<td  align=""center"">"& vbCrLf
			GetClassValue = GetClassValue & "<input "
			If fycms_HQQX(ClassRs("ClassID"),"1")=true Then GetClassValue = GetClassValue & " Checked "
			GetClassValue = GetClassValue & "name=""fycms_QXLX"" type=""checkbox"""
			GetClassValue = GetClassValue & " id=""fycms_QXLX1"&ClassRs("ID")&""" value="""&ClassRs("ClassID")&"-1"""
			GetClassValue = GetClassValue & ">"&vbCrLf&"<label for=""fycms_QXLX1"&ClassRs("ID")&""">管理</label>"&vbCrLf
			GetClassValue = GetClassValue & "<input "
			If fycms_HQQX(ClassRs("ClassID"),"2")=true Then GetClassValue = GetClassValue & " Checked "
			GetClassValue = GetClassValue & "name=""fycms_QXLX"" type=""checkbox"""
			GetClassValue = GetClassValue & " id=""fycms_QXLX2"&ClassRs("ID")&""" value="""&ClassRs("ClassID")&"-2"""
			GetClassValue = GetClassValue & ">"&vbCrLf&"<label for=""fycms_QXLX2"&ClassRs("ID")&""">增加</label>"&vbCrLf
			GetClassValue = GetClassValue & "<input "
			If fycms_HQQX(ClassRs("ClassID"),"3")=true Then GetClassValue = GetClassValue & " Checked "
			GetClassValue = GetClassValue & "name=""fycms_QXLX"" type=""checkbox"""
			GetClassValue = GetClassValue & " id=""fycms_QXLX3"&ClassRs("ID")&""" value="""&ClassRs("ClassID")&"-3"""
			GetClassValue = GetClassValue & ">"&vbCrLf&"<label for=""fycms_QXLX3"&ClassRs("ID")&""">修改</label>"& vbCrLf 
			GetClassValue = GetClassValue & "<input "
			If fycms_HQQX(ClassRs("ClassID"),"4")=true Then GetClassValue = GetClassValue & " Checked "
			GetClassValue = GetClassValue & "name=""fycms_QXLX"" type=""checkbox"""
			GetClassValue = GetClassValue & " id=""fycms_QXLX4"&ClassRs("ID")&""" value="""&ClassRs("ClassID")&"-4"""
			GetClassValue = GetClassValue & ">"&vbCrLf&"<label for=""fycms_QXLX4"&ClassRs("ID")&""">删除</label>"& vbCrLf
			GetClassValue = GetClassValue & "<input "
			If fycms_HQQX(ClassRs("ClassID"),"5")=true Then GetClassValue = GetClassValue & " Checked "
			GetClassValue = GetClassValue & "name=""fycms_QXLX"" type=""checkbox"""
			GetClassValue = GetClassValue & " id=""fycms_QXLX5"&ClassRs("ID")&""" value="""&ClassRs("ClassID")&"-5"""
			GetClassValue = GetClassValue & ">"&vbCrLf&"<label for=""fycms_QXLX5"&ClassRs("ID")&""">审核</label>"&vbCrLf
			GetClassValue = GetClassValue & "</td>" & Chr(13) & Chr(10)
			GetClassValue = GetClassValue & "</tr>" & Chr(13) & Chr(10)
			GetClassValue = GetClassValue &GetClassValue(ClassRs("ClassID"),TempStr)
			ClassRs.MoveNext
		loop
		ClassRs.Close
		Set ClassRs = Nothing
	End Function



 	Public Function CheckPlus(OptionName,SelectArr,RowNum)
	   Dim n:n=0
	   Dim br,ii
	   ii=1
	   Dim ACT_Plus:Set ACT_Plus=Server.CreateObject("Adodb.Recordset")
	   IF RowNum<=0 Then RowNum=3
	   ACT_Plus.Open "Select ID,PlusName,PlusID From Plus_fy",Conn,1,1
 	   Do While Not ACT_Plus.Eof
 	     For N=1 To RowNum
	   	If ii Mod 8 =0 Then br="<br />" Else br=""
		ii=ii+1
 			If Instr(SelectArr,ACT_Plus(2))<>0 Then
			 CheckPlus=CheckPlus & "<input id="& OptionName&ACT_Plus(0)&" type=""checkbox"" checked name=""" & OptionName & """ value=""" & ACT_Plus(2) & """><label for="& OptionName&ACT_Plus(0) &">" & ACT_Plus(1) & "</label>"&vbCrLf&br
			Else
			 CheckPlus=CheckPlus & "<input id="& OptionName&ACT_Plus(0)&" type=""checkbox"" name=""" & OptionName & """ value=""" & ACT_Plus(2) & """><label for="& OptionName&ACT_Plus(0) &">" & ACT_Plus(1) & "</label>"&vbCrLf&br
			End IF
 		 		ACT_Plus.MoveNext
				If ACT_Plus.Eof Then Exit For
			
		Next
		
	
 		If ACT_Plus.Eof Then Exit Do
	   Loop
      	   ACT_Plus.Close:Set ACT_Plus=Nothing
	End Function 

%>
		
</body>
</html>
