<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.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"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 会员管理</div>
    <div class="opers">
    	 <a href="?" class="btn <%If request("Action")="" Then echo " btn_primary" %>" >管理首页</a>

	<%	If Not fycms.ChkAdmin() Then  Call fycms.Alert("对不起，您没有操作权限！","")

	
	Dim rs 
	  Set Rs =fycms.ACTEXE("SELECT ModeID,ModeName FROM ModeUser_fy  order by ModeID asc")
	 If Rs.EOF  Then
	 	echo	"没有记录"
	 Else
		Do While Not Rs.EOF	
			 %>
	<a  class="btn <%If request("Action")="Add" Then echo " btn_primary" %>" href="?Action=Add&ModeID=<%=rs("ModeID")%>">新增<%=rs("ModeName")%>组</a> 
	 <% 
		Rs.movenext
		Loop
	end if 
	Set Rs = Nothing	%>







    </div>
   <% 
	Dim ShowErr,Action,ModeID
	Action = Request("Action")
	ModeID = ChkNumeric(Request("ModeID"))
	Select Case Action
			Case "Edit","Add"
				Call Edit()
			Case "SaveAdd"
				Call SaveAdd
			Case "SaveEdit"
				Call SaveEdit
			Case "del"
				Call Del()
			Case "DefaultGroup"
				Call DefaultGroup()
			Case Else
				Call Main()
	End Select

	Sub DefaultGroup()
		Dim GroupID
		GroupID=ChkNumeric(fycms.s("GroupID"))
		Conn.execute "update Group_fy set DefaultGroup=0  where  ModeID="&ModeID&"" 
		Conn.execute "update Group_fy set DefaultGroup=1  where  ModeID="&ModeID&" and GroupID="&GroupID&"" 
		Call fycms.ActErr("操作成功","","")
	End Sub 
	
	Sub SaveAdd()
		Dim Sql,Rs,GroupID,ChargeType,GroupSetting
		GroupID = ChkNumeric(Request("GroupID"))
		ChargeType = ChkNumeric(Request.Form("ChargeType"))

		IF ChargeType = 0 Then ChargeType = 1

		IF 	Request("GroupSetting1") = "" Then 
			ShowErr = "<li>用户组名称不能为空!</li>"
			Call fycms.ActErr(ShowErr,"","1")
			Response.End
		End IF
	
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting1"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting2")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting3"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting4"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting5"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting6"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting7"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting8"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting9")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting10"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting11")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting12"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting13"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting14")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting15"))&"^@$@^"
 		SQL = "Select * From Group_fy "
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		Do While Not rs.eof 
			If rs("GroupName")=RSQL(fycms.s("GroupName")) Then 
				ShowErr = "<li>数据库中已经存在此用户组名称!</li>"
				Call fycms.ActErr(ShowErr,"","1")
				Response.End
			End IF
		rs.movenext	
		Loop
		

		Rs.addnew
		Rs("GroupSetting")		= GroupSetting
		Rs("ModeID")	    = ModeID
		Rs("GroupName")	    = fycms.s("GroupName")

		Rs.update
		Rs.Close:Set Rs=Nothing
 		Call fycms.ActErr("添加新用户组成功","User/Group.fy.asp","")
 		Response.End
	End Sub	
		
	Sub SaveEdit()
		Dim Sql,Rs,GroupID,ChargeType,GroupSetting
		GroupID = ChkNumeric(Request("GroupID"))
		ChargeType = ChkNumeric(Request.Form("ChargeType"))
		
		
		
		IF ChargeType = 0 Then ChargeType = 1
		IF 	Request("GroupSetting1") = "" Then 
			ShowErr = "<li>用户组名称不能为空!</li>"
			Call fycms.ActErr(ShowErr,"","1")
			Response.End
		End IF
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting1"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting2")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting3"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting4"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting5"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting6"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting7"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting8"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting9")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting10"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting11")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting12"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting13"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting14")&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting15"))&"^@$@^"
		GroupSetting=GroupSetting&ChkNumeric(Request.Form("GroupSetting16"))&"^@$@^"


		
		SQL = "Select * From Group_fy Where GroupID="&GroupID
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		IF Not (Rs.Eof And Rs.Bof) Then
			Rs("GroupSetting")		= GroupSetting
			Rs("ChargeType")	= ChargeType
			Rs("GroupName")	    = fycms.s("GroupName")
			Rs.update
		Else
			ShowErr = "<li>无此用户组，参数传递出错</li>"
			Call fycms.ActErr(ShowErr,"","1")
			Response.End
		End IF
		Rs.Close:Set Rs=Nothing
		Call fycms.ActErr("用户组修改成功","User/Group.fy.asp","")
 		Response.End
	End Sub	
	Sub Del()
		Conn.Execute ("Delete from Group_fy Where GroupID=" & ChkNumeric(Request.QueryString("GroupID")))		
		Set conn=nothing
		Call fycms.ActErr("用户组删除成功","User/Group.fy.asp","")
   		Response.End
    End Sub
		
 Sub Main
	Dim strLocalUrl,ModeName
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	
	Dim intPageNow
	intPageNow = request.QueryString("page")
	
	Dim intPageSize, strPageInfo
	intPageSize = 30
	
	Dim arrU, i,GroupSettingSet
	Dim sql, sqlCount
	sql = "SELECT [GroupID], [GroupSetting],[ModeID],[DefaultGroup],[GroupName]" & _
		" FROM [Group_fy]" & _
		"ORDER BY [GroupID] ASC"
	sqlCount = "SELECT Count([GroupID])" & _
			" FROM [Group_fy]"

		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = "page"
		clsRecordInfo.objConn = Conn		
		arrU = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
 %>
	
 	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>ID</th>
	  <th>用户组名称</th>
	  <th>组模型</th>
	  <th>属性</th>
	  <th>会员数量</th>
	  <th>管理操作</th>
	  </tr>
    </thead>
      <%
		If IsArray(arrU) Then
			For i = 0 to UBound(arrU, 2)

 	%> <tr >
      <td align="center"  ><%= arrU(0,i) %></td>
	  <td align="center"  ><%=arrU(4,i)%></td>
      <td align="center"  ><%
	  Dim rs2,IFD
	  Set rs2=Conn.Execute("Select ModeName,ModeTable From ModeUser_fy Where ModeID=" & arrU(2,i))
	  If rs2.eof Then 
		ModeName= "<font color=red>错误,该组模型已被删除</font>"
		IFD=1
	  Else 
		ModeName= "<font color=red>"&rs2("ModeName")&"</font>"
		IFD=2
	  End If 	  
	  echo ModeName%></td>
      <td align="center"  >
	
	  <%IF arrU(3,i) = "1" Then echo "<font color=green>默认注册组</font>" Else echo "正常" %>	  </td>						
      <td align="center"  >
	  <%If ifd=2 Then 
		echo Conn.Execute("Select Count(UserID) From User_fy Where GroupID=" & arrU(0,i))(0)
		End If %></td>
      <td  align="center" >
	 <a href="?Action=DefaultGroup&ModeID=<%=arrU(2,i)%>&GroupID=<%=arrU(0,i)%>">设置为<font color=red><%=ModeName%></font>模型默认的注册用户组</a>
	 <a href="?Action=Edit&GroupID=<%=arrU(0,i)  %>">修改</a>┆
	 <a href="?Action=del&GroupID=<%= arrU(0,i) %>" onClick="return confirm('确认删除此用户组吗?')">删除</a>┆
	 <A href="index.asp?UserSearch=6&GroupID=<%= arrU(0,i) %>">列出会员</A></td>
    </tr>
	<% 
	Next
	End If
	%>
    
    </table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>



<% 
 End Sub

Sub Edit()
	Dim GroupID,Rs,GroupName,Description,ChargeType,GroupPoint,ValidDays,frmAction,GroupSetting,tgdianshu
	Dim GroupSettingSet,fbpl,sh,smsrs,smszf,smssize,scwj,scml,scdx,wjlx,fbsh,zcrz,Simple,dianshu
	IF Action = "Edit" Then
		GroupID = ChkNumeric(Request.QueryString("GroupID"))
		IF GroupID = 0 Then echo "请指定要修改的用户组ID":Response.End
		Set Rs=Conn.Execute("Select * from Group_fy Where GroupID=" & GroupID)
			if Rs.Bof And Rs.EOF then
				 echo "不存在此用户组！"
				Exit Sub
			End IF	
		GroupSetting = Rs("GroupSetting")	
		GroupSettingSet=Split(GroupSetting,"^@$@^")
		GroupName=rs("GroupName")
		Description=GroupSettingSet(1)
		fbpl=GroupSettingSet(2)
		sh=GroupSettingSet(3)
		smssize=GroupSettingSet(4)
		smszf=GroupSettingSet(5)
		smsrs=GroupSettingSet(6)
		scwj=GroupSettingSet(7)
		scml=GroupSettingSet(8)
		scdx=GroupSettingSet(9)
		wjlx=GroupSettingSet(10)
		fbsh=GroupSettingSet(11)
		zcrz=GroupSettingSet(12)
		Simple=GroupSettingSet(13)
		dianshu=GroupSettingSet(14)
		tgdianshu=GroupSettingSet(0)
 		frmAction		= "Edit"
	Else
		smssize=100:smszf=1000:smsrs=10:fbsh=1:zcrz=1:dianshu=0:tgdianshu=0
		scml="UpFiles/User":scwj=0:scdx=1024:wjlx="jpg/gif/bmp/png/swf/rar/exe":Simple="Simple"
		GroupName = ""	
		Description = ""
		ChargeType = 1
		GroupPoint = 0
		ValidDays = 0
		frmAction		= "Add"
	End If
%>


  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
<form name="form1" method="post" action="Group.fy.asp">
    <tr>
      <td width="22%" align="right" >用户组名称：</td>
      <td width="78%" class="tl"><input name="GroupName"  type="text" class="Ainput" id="GroupName" value="<%= GroupName %>"></td>
    </tr>
    <tr>
      <td align="right" >用户组简介：</td>
      <td class="tl"><textarea name="GroupSetting2" cols="50" rows="8" id="GroupSetting2"><%= Description %></textarea></td>
    </tr>
    <tr>
      <td align="right" >评论权限：</td>
      <td class="tl"><INPUT type="checkbox"  <%if fbpl= "1" Then echo "Checked "%> value="1" id="GroupSetting33" name="GroupSetting3"><label for="GroupSetting33">
        在禁止发表评论的栏目里仍然可发表评论</label><BR>
       <label for="GroupSetting44"> <INPUT <%if sh= 1 Then echo "Checked "%>  type="checkbox"  id="GroupSetting44"  value="1" name="GroupSetting4">
        在评论需要审核的栏目里发表评论不需要审核</label></td>
    </tr>
    <tr>
      <td align="right" >短消息权限：</td>
      <td class="tl">最大容量为
        <INPUT size="10" value="<%= smssize %>" type="text" name="GroupSetting5">
条,短信内容最多字符数
<INPUT size="10" value="<%= smszf %>" name="GroupSetting6" type="text">
个字符<BR>
群发限制人数
<INPUT size="10" value="<%= smsrs %>" name="GroupSetting7" type="text">
人</td>
    </tr>

    <tr>
      <td align="right" >fckeditor显示菜单：</td>
      <td class="tl">
	<input name="GroupSetting14" id="GroupSetting14"  type="text" class="Ainput" title="在这里填写默认值" value="<%=Simple%>" size="20">
	<select name="select"   onchange="document.form1.GroupSetting14.value=this.value">
          <option selected>-- 请选择 --</option>
          <option value="UserMode">简洁</option>
          <option value="Simple">超简洁</option>
          <option value="Default">默认</option>
        </select>自己定义菜单名称,请手工配置editor/fckeditor/fckconfig.js 文件		
		</td>
    </tr>

      <tr>
      <td align="right" >新会员注册时赠送的点数：</td>
      <td class="tl"><input  type="text" class="Ainput" value="<%= dianshu %>"  name="GroupSetting15">
	  （为0时不赠送）</td>
    </tr> 
	
      <tr>
      <td align="right" >会员发布文章赠送的点数：</td>
      <td class="tl"><input  type="text" class="Ainput" value="<%= tgdianshu %>"  name="GroupSetting1">
	  （为0时不加）</td>
    </tr> 

	<tr>
      <td align="right" >上传文件：</td>
      <td class="tl"><INPUT id="GroupSetting88" type="radio" <%if scwj= "1" Then echo "Checked "%>  value="1" name="GroupSetting8"><LABEL for="GroupSetting88">允许</LABEL>
        <INPUT id="GroupSetting78" type="radio"  <%if scwj= "0" Then echo "Checked "%>  value="0" name="GroupSetting8"><LABEL for="GroupSetting78">不允许</LABEL></td>
    </tr>


    <tr>
      <td align="right" >会员文件上传目录：</td>
      <td class="tl"><input  type="text" class="Ainput" value="<%= scml %>"  name="GroupSetting9"></td>
    </tr>
    <tr>
      <td align="right" >允许上传的最大文件大小：</td>
      <td class="tl"><input  type="text" class="Ainput" value="<%= scdx %>"  name="GroupSetting10">KB 　 <font color="#FF6600">提示：1 KB = 1024 Byte，1 MB = 1024 KB</font></td>
    </tr>
    <tr>
      <td align="right" >允许上传的文件类型：<BR>
      <FONT color="red"></FONT></td>
      <td class="tl"><input  type="text" class="Ainput" size="40"  value="<%= wjlx %>"  name="GroupSetting11">多种文件类型之间以"|"分隔</td>
    </tr>
    <tr>
      <td align="right" >发布的信息是否需要审核：</td>
      <td class="tl">
	    <INPUT id="GroupSetting12" type="radio" <%if fbsh= "1" Then echo "Checked "%> value="1" name="GroupSetting12"><LABEL for="GroupSetting12">是</LABEL>
        <INPUT id="GroupSetting121" type="radio" <%if fbsh= "0" Then echo "Checked "%>  value="0" name="GroupSetting12"><LABEL for="GroupSetting121">否</LABEL>
		</td>
    </tr>
    <tr>
      <td align="right" >注册认证：</td>
      <td class="tl">
	    <INPUT id="GroupSetting13" type="radio" <%if zcrz= "1" Then echo "Checked "%> value="1" name="GroupSetting13"><LABEL for="GroupSetting13">不验证</LABEL>
        <INPUT id="GroupSetting131" type="radio" <%if zcrz= "2" Then echo "Checked "%>  value="2" name="GroupSetting13"><LABEL for="GroupSetting131">邮件验证</LABEL>
        <INPUT id="GroupSetting1312" type="radio" <%if zcrz= "3" Then echo "Checked "%>  value="3" name="GroupSetting13"><LABEL for="GroupSetting1312">后台验证</LABEL>
	</td>
    </tr>
 
    <tr>
      <td align="right" >&nbsp;</td>
      <td class="tl">
	  <input name="GroupID" type="hidden" value="<%=GroupID%>">
	  <input name="ModeID" type="hidden" value="<%=ModeID%>">
	  <input name="Action" type="hidden" id="Action" value="Save<%=frmAction%>">
	  <input type=button class="btn btn_primary"   onclick=CheckInfo()  name=Submit value=" 保存 " />&nbsp;&nbsp;
      <input type="reset" class="btn btn_primary"   name="Submit2" value=" 取 消" />	</td>
    </tr></form>
  </table>



<SCRIPT language=javascript>
		function CheckInfo()
		{
		  if(document.form1.GroupSetting1.value=="")
			{
			  alert("用户组名不能为空！");
			  document.form1.GroupSetting1.focus();
			  return false;
			}
	    form1.submit();
        return true;
		}
		</script>



<%

End Sub 
 CloseConn %>



</div>
</body>
</html>
