<!--#include file="../ACT.Function.asp"-->
<!--#include file="../../act_inc/cls_pageview.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户组管理</title>
<link href="../Images/css1/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
  <tr>
    <td colspan="2" align="center"  class="bg_tr"><strong>会员系统----用户组管理</strong></td>
  </tr>
  <tr>
    <td width="22%" align="right" ><strong>管理选项：</strong></td>
    <td width="78%" ><strong><a href="?">管理首页</a></strong> ┆
	<%	If Not ACTCMS.ChkAdmin() Then  Call Actcms.Alert("对不起，您没有操作权限！","")

	
	Dim rs 
	  Set Rs =ACTCMS.ACTEXE("SELECT ModeID,ModeName FROM ModeUser_Act  order by ModeID asc")
	 If Rs.EOF  Then
	 	Response.Write	"没有记录"
	 Else
		Do While Not Rs.EOF	
			 %>
	<strong><a href="?Action=Add&ModeID=<%=rs("ModeID")%>">新增<%=rs("ModeName")%>组</a></strong>&nbsp;&nbsp;
	 <% 
		Rs.movenext
		Loop
	end if 
	Set Rs = Nothing	%>
	</td>
  </tr>
</table><% 
	Dim ShowErr,Action,ModeID
	Action = Request("Action")
	ModeID = ACTCMS.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=ACTCMS.ChkNumeric(actcms.s("GroupID"))
		Conn.execute "update Group_Act set DefaultGroup=0  where  ModeID="&ModeID&"" 
		Conn.execute "update Group_Act set DefaultGroup=1  where  ModeID="&ModeID&" and GroupID="&GroupID&"" 
		Call actcms.ActErr("操作成功","")
	End Sub 
	
	Sub SaveAdd()
		Dim Sql,Rs,GroupID,ChargeType,GroupSetting
		GroupID = ACTCMS.ChkNumeric(Request("GroupID"))
		ChargeType = ACTCMS.ChkNumeric(Request.Form("ChargeType"))

		IF ChargeType = 0 Then ChargeType = 1

		IF 	Request("GroupSetting1") = "" Then 
			ShowErr = "<li>用户组名称不能为空!</li>"
			Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
	
		GroupSetting=GroupSetting&Request.Form("GroupSetting1")&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting2")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting3"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting4"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting5"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting6"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting7"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting8"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting9")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting10"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting11")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting12"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting13"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting14")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting15"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting16"))&"^@$@^"
		SQL = "Select * From Group_ACT "
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		Do While Not rs.eof 
			If Split(rs("GroupSetting"),"^@$@^")(0)=actcms.rsql(actcms.s("GroupSetting1")) Then 
				ShowErr = "<li>数据库中已经存在此用户组名称!</li>"
				Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
				Response.End
			End IF
		rs.movenext	
		Loop
		

		Rs.addnew
		Rs("GroupSetting")		= GroupSetting
		Rs("ModeID")	    = ModeID
		Rs.update
		Rs.Close:Set Rs=Nothing
		ShowErr = "<li>添加新用户组成功!&nbsp;&nbsp;<a href='User/Group_Admin.asp'><b>返回用户组管理</b></a></li>"
		Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=")
		Response.End
	End Sub	
		
	Sub SaveEdit()
		Dim Sql,Rs,GroupID,ChargeType,GroupSetting
		GroupID = ACTCMS.ChkNumeric(Request("GroupID"))
		ChargeType = ACTCMS.ChkNumeric(Request.Form("ChargeType"))
		
		
		
		IF ChargeType = 0 Then ChargeType = 1
		IF 	Request("GroupSetting1") = "" Then 
			ShowErr = "<li>用户组名称不能为空!</li>"
			Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		GroupSetting=GroupSetting&Request.Form("GroupSetting1")&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting2")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting3"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting4"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting5"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting6"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting7"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting8"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting9")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting10"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting11")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting12"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting13"))&"^@$@^"
		GroupSetting=GroupSetting&Request.Form("GroupSetting14")&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting15"))&"^@$@^"
		GroupSetting=GroupSetting&ACTCMS.ChkNumeric(Request.Form("GroupSetting16"))&"^@$@^"


		
		SQL = "Select * From Group_ACT 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.update
		Else
			ShowErr = "<li>无此用户组，参数传递出错</li>"
			Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		Rs.Close:Set Rs=Nothing
		ShowErr = "<li>用户组修改成功!&nbsp;&nbsp;<a href='User/Group_Admin.asp'><b>返回用户组管理</b></a></li>"
		Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=")
		Response.End
	End Sub	
	Sub Del()
		Conn.Execute ("Delete from Group_ACT Where GroupID=" & ACTCMS.ChkNumeric(Request.QueryString("GroupID")))		
		Set conn=nothing
		ShowErr = "<li>用户组删除成功！</li>"
		Response.Redirect("../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=User/Group_Admin.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]" & _
		" FROM [Group_ACT]" & _
		"ORDER BY [GroupID] ASC"
	sqlCount = "SELECT Count([GroupID])" & _
			" FROM [Group_ACT]"

		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.arrRecordInfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
 %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
      <td colspan="7" class="bg_tr">您现在的位置：管理首页 &gt;&gt; <a href="?"  ><font class="bg_tr">用户组管理</font></a> &gt;&gt;</td>
    </tr>
    <tr>
      <td width="20" align="center" ><STRONG>ID</STRONG></td>
      <td  align="center" ><STRONG>用户组名称</STRONG></td>
	  <td width="13%" align="center" ><STRONG>组模型</STRONG></td>	
      <td  align="center" nowrap><STRONG>属性</STRONG></td>
      <td align="center" nowrap><STRONG>会员数量</STRONG></td>
      <td   align="center"  nowrap><strong>管理操作</strong></td>
    </tr>
	 <%
		Dim bgColor
		If IsArray(arrU) Then
			For i = 0 to UBound(arrU, 2)

		GroupSettingSet=Split(arrU(1,i),"^@$@^")
	%>
    <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
      <td align="center"  ><%= arrU(0,i) %></td>
	  <td align="center"  ><%=GroupSettingSet(0)%></td>
      <td align="center"  ><%
	  Dim rs2,IFD
	  Set rs2=Conn.Execute("Select ModeName,ModeTable From ModeUser_Act 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 	  
	  response.write ModeName%></td>
      <td align="center"  >
	
	  <%IF arrU(3,i) = "1" Then Response.Write "<font color=green>默认注册组</font>" Else Response.Write "正常" %>	  </td>						
      <td align="center"  >
	  <%If ifd=2 Then 
		response.write Conn.Execute("Select Count(UserID) From "&rs2("ModeTable")&" 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="User_Admin.asp?UserSearch=6&GroupID=<%= arrU(0,i) %>">列出会员</A></td>
    </tr>
	<% 
	Next
	End If
	%>
    
    <tr >
      <td height="25" colspan="7" align="center" ><%= strPageInfo%></td>
    </tr>
  </table>

<script language="javascript">
function SelectIterm(form,sign){
	for (var i=0; i<form.elements.length;i++ ){
		if (form.elements[i].type == "checkbox"){
				var e=form.elements[i];
					if (sign==0) e.checked= true;
					if (sign==1) e.checked= !e.checked;
					if (sign==2) e.checked= false;
		}
	} 
}
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
</script>
<% 
 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 = ACTCMS.ChkNumeric(Request.QueryString("GroupID"))
		IF GroupID = 0 Then Response.Write "请指定要修改的用户组ID":Response.End
		Set Rs=Conn.Execute("Select * from Group_ACT Where GroupID=" & GroupID)
			if Rs.Bof And Rs.EOF then
				 Response.Write "不存在此用户组！"
				Exit Sub
			End IF	
		GroupSetting = Rs("GroupSetting")	
		GroupSettingSet=Split(GroupSetting,"^@$@^")
		GroupName=GroupSettingSet(0)
		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(15)


		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_Admin.asp">
    <tr>
      <td width="22%" align="right" >用户组名称：</td>
      <td width="78%" ><input name="GroupSetting1" type="text" id="GroupSetting1" value="<%= GroupName %>"></td>
    </tr>
    <tr>
      <td align="right" >用户组简介：</td>
      <td ><textarea name="GroupSetting2" cols="50" rows="8" id="GroupSetting2"><%= Description %></textarea></td>
    </tr>
    <tr>
      <td align="right" >评论权限：?</td>
      <td ><INPUT type="checkbox"  <%if fbpl= "1" Then Response.Write "Checked "%> value="1" id="GroupSetting33" name="GroupSetting3"><label for="GroupSetting33">
        在禁止发表评论的栏目里仍然可发表评论</label><BR>
       <label for="GroupSetting44"> <INPUT <%if sh= 1 Then Response.Write "Checked "%>  type="checkbox"  id="GroupSetting44"  value="1" name="GroupSetting4">
        在评论需要审核的栏目里发表评论不需要审核</label></td>
    </tr>
    <tr>
      <td align="right" >短消息权限：?</td>
      <td >最大容量为
        <INPUT size="10" value="<%= smssize %>" name="GroupSetting5">
条,短信内容最多字符数
<INPUT size="10" value="<%= smszf %>" name="GroupSetting6">
个字符<BR>
群发限制人数
<INPUT size="10" value="<%= smsrs %>" name="GroupSetting7">
人</td>
    </tr>

    <tr>
      <td align="right" >fckeditor显示菜单：?</td>
      <td >
	<input name="GroupSetting14" id="GroupSetting14" type="text" 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 ><input type="text" value="<%= dianshu %>"  name="GroupSetting15">
	  （为0时不赠送）</td>
    </tr> 
	
      <tr>
      <td align="right" >会员发布文章赠送的点数：?</td>
      <td ><input type="text" value="<%= tgdianshu %>"  name="GroupSetting16">
	  （为0时不加）</td>
    </tr> 

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


    <tr>
      <td align="right" >会员文件上传目录：?</td>
      <td ><input type="text" value="<%= scml %>"  name="GroupSetting9"></td>
    </tr>
    <tr>
      <td align="right" >允许上传的最大文件大小：?</td>
      <td ><input type="text" 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 ><input type="text" size="40"  value="<%= wjlx %>"  name="GroupSetting11">多种文件类型之间以"|"分隔</td>
    </tr>
    <tr>
      <td align="right" >发布的信息是否需要审核：?</td>
      <td >
	    <INPUT id="GroupSetting12" type="radio" <%if fbsh= "1" Then Response.Write "Checked "%> value="1" name="GroupSetting12"><LABEL for="GroupSetting12">是</LABEL>
        <INPUT id="GroupSetting121" type="radio" <%if fbsh= "0" Then Response.Write "Checked "%>  value="0" name="GroupSetting12"><LABEL for="GroupSetting121">否</LABEL>
		</td>
    </tr>
    <tr>
      <td align="right" >注册认证：?</td>
      <td >
	    <INPUT id="GroupSetting13" type="radio" <%if zcrz= "1" Then Response.Write "Checked "%> value="1" name="GroupSetting13"><LABEL for="GroupSetting13">不验证</LABEL>
        <INPUT id="GroupSetting131" type="radio" <%if zcrz= "2" Then Response.Write "Checked "%>  value="2" name="GroupSetting13"><LABEL for="GroupSetting131">邮件验证</LABEL>
        <INPUT id="GroupSetting1312" type="radio" <%if zcrz= "3" Then Response.Write "Checked "%>  value="3" name="GroupSetting13"><LABEL for="GroupSetting1312">后台验证</LABEL>
	</td>
    </tr>
<!--     <tr>
      <td align="right" >发布的信息是否需要审核</td>
      <td >&nbsp;</td>
    </tr>
    <tr>
      <td align="right" ><DIV align="right">计费??方式：</DIV></td>
      <td ><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><INPUT  <%if ChargeType = 1 Then Response.Write "Checked"%> type="radio" value="1" id="ChargeType1" name="ChargeType">
<label for="ChargeType1">扣点数<BR></label>
  &nbsp;&nbsp;&nbsp;&nbsp; 默认&nbsp;&nbsp;&nbsp;&nbsp;点数：  
   <INPUT id="GroupPoint" maxLength="5" size="6" value="<%= GroupPoint %>" name="GroupPoint">
点</td>
        </tr>
        <tr>
          <td><INPUT  <%if ChargeType = 2 Then Response.Write "Checked"%> type="radio"  value="2" id="ChargeType2" name="ChargeType">
<label for="ChargeType2">有效期<BR></label>
  &nbsp;&nbsp;&nbsp;&nbsp; 默认有效期：
<INPUT   id="ValidDays" maxLength="5" size="6" value="<%= ValidDays %>" name="ValidDays">
天</td>
        </tr>
        <tr>
          <td><INPUT <%if ChargeType= 3  Then Response.Write "Checked"%>  type="radio" id="ChargeType3" value="3" name="ChargeType">
<label for="ChargeType3"><font color="red">无限期(永不过期)</font></label></td>
        </tr>
      </table></td>
    </tr> -->
    <tr>
      <td align="right" >&nbsp;</td>
      <td >
	  <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="ACT_btn"   onclick=CheckInfo()  name=Submit value=" 保存 " />&nbsp;&nbsp;
      <input type="reset" class="ACT_btn"   name="Submit2" value=" 取 消" />	</td>
    </tr></form>
  </table>

<SCRIPT language=javascript>
		function CheckInfo()
		{
		  if(document.form1.GroupSetting1.value=="")
			{
			  form1.Submit.disabled=true;	
			  form1.Submit2.disabled=true;	
			  alert("用户组名不能为空！");
			  document.form1.GroupSetting1.focus();
			  form1.Submit.disabled=false;	
			  form1.Submit2.disabled=false;	
			  return false;
			}
		form1.Submit.value="正在提交数据,请稍等...";
		form1.Submit.disabled=true;	
		form1.Submit2.disabled=true;	
	    form1.submit();
        return true;
		}
		</script>

<%

End Sub 
 CloseConn %>
<br>
<br> </body>
</html>
