<!--#include file=../conn.asp-->
<!-- #include file="inc/const.asp" -->
<!-- #include file=Groupshow.asp-->
<%Head()
	dim admin_flag,GroupID,action
	admin_flag=",13,"
	if not master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=../"&LoginUrl&" target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		call Ms_error()
	Else
		call Main()
		call Footer()
	End If
	Sub Main()
	Select Case Request("action")
	Case "editgroup"
		EditGroup()
	Case "saveusergroup"
		SaveUserGroup()
	Case "savesysgroup"
		SaveSysGroup()
	Case "delusergroup"
		DelUserGroup()
	Case Else
		UserGroup()
	End Select
End Sub

Sub UserGroup()
%>
<table width="98%" border="0" cellspacing="1" cellpadding="3" class="tableBorder">
  <tr align="center"> 
    <th height=25 id=tabletitlelink>用户组管理</th>
  </tr>
  <tr> 
    <td height="35" class="forumRow"> <B>说明</B>：<br>
      <li>交友系统用户组分为系统用户组、特殊用户组、注册用户组三种类型 <br>
          <li>系统用户组为内置固定用户组，不能添加，供系统管理之用，不能随意更改，如删除则会引起系统运行异常 <br>
          <li>特殊用户组不随用户等级升降而变更，通常建立来分配给一些对交友有特殊贡献或操作的人员 <br>
          <li>注册用户组即为传统的用户等级，每个组(等级)可设定不同的权限 <br>
          <li>默认权限为添加新的用户组时使用其中一些定义好的权限设置，通常新添加用户组后都要再次定义其权限 </li>
      </td>
  </tr>
  <tr>
    <td height="24" class="forumRow">快捷操作：<a href="admin_group.asp#1">系统组</a> 
      | <a href="admin_group.asp#2">注册用户组</a> | <a href="admin_group.asp#3">特殊组</a> 
      | <a href="admin_group.asp#4">Vip组管理</a></td>
  </tr>
</table>
<br><a name="1"></a>
<table width="98%" border="0" cellspacing="1" cellpadding="3" class="tableBorder">
<FORM METHOD=POST ACTION="?action=savesysgroup">
  <tr align="center"> 
      <th height=25 colspan="6" align="left" id=tabletitlelink>系统用户组管理[<a href="#top">顶部</a>]</th>
  </tr>
  <tr> 
    <td height="35" colspan="6" class="forumRow">小提示：点击权限您可以分别设定每个系统用户组分别拥有不同的权限，系统组头衔和图标显示在前台用户信息中</td>
  </tr>
  <tr> 
      <td width="7%" height="23" class=forumrowHighlight><B>组ID</B></td>
      <td width="17%" height="23" class=forumrowHighlight><B>系统组头衔</B></td>
      <td width="17%" class=forumrowHighlight><B>系统中名称</B></td>
      <td width="32%" height="23" class=forumrowHighlight><B>系统组图标</B></td>
      <td width="7%" height="23" class=forumrowHighlight><B>用户数</B></td>
      <td width="20%" class=forumrowHighlight><B>操作</B></td>
  </tr>
  <input type=hidden value="1" name="ParentID">
<%
Set Rs=Conn.Execute("Select * From Ms_usergroups Where ParentGID=1 Order By UserGroupID")
Do While Not Rs.Eof
%>
<input type=hidden value="<%=rs("UserGroupID")%>" name="usertitleid">
<input value="<%=rs("title")%>" name="title" type=hidden>
<input type=hidden value="<%=rs("IsSetting")%>" name="issetting">
  <tr> 
    <td class=Forumrow align=center><%=Rs("UserGroupID")%></td>
    <td height="23" class=Forumrow><input size=15 value="<%=rs("usertitle")%>" name="usertitle" type=text></td>
    <td class=Forumrow><%=Rs("Title")%></td>
    <td class=Forumrow><input size=15 value="<%=rs("grouppic")%>" name="titlepic" type=text> 
      <img src="../<%=rs("grouppic")%>" border="0"> </td>
    <td align="center" class=Forumrow> <B><%=rs("Useradd")%></B> </td>
    <td class=Forumrow><a href="?action=editgroup&groupid=<%=rs("UserGroupID")%>">编辑</a> 
      | <a href="admin_user.asp?action=userSearch&userSearch=10&usergroupid=<%=rs("usergroupid")%>">列出用户</a></td>
  </tr>
  <%
Rs.MoveNext
Loop
Set Rs=Nothing
%>
<tr align=center>
<td colspan=6 height=25 class="forumrowHighlight">
<input type=submit name=submit value="提交更改">
</td></tr>
</FORM>
</table>
<br>
<a name="2" id="2"></a> 
<table width="98%" border="0" cellspacing="1" cellpadding="3" class="tableBorder">
  <FORM METHOD=POST ACTION="?action=saveusergroup">
    <tr align="center"> 
      <th height=25 colspan="8" align="left" id=tabletitlelink>注册用户组(等级)管理[<a href="#top">顶部</a>]</th>
    </tr>
    <tr> 
      <td height="35" colspan="8" class="forumRow">小提示：点击权限您可以分别设定每个注册用户组(等级)分别拥有不同的系统权限 
      </td>
    </tr>
    <tr> 
      <td width="5%" height="23" class=forumrowHighlight><B>组ID</B></td>
      <td width="15%" height="23" class=forumrowHighlight><B>用户组名称</B></td>
      <td width="5%" align="center" class=forumrowHighlight><B>文章</B></td>
      <td width="5%" align="center" class=forumrowHighlight><B>日记</B></td>
      <td width="5%" align="center" class=forumrowHighlight><b>相册</b></td>
      <td width="25%" height="23" class=forumrowHighlight><B>组(等级)图片</B></td>
      <td width="6%" height="23" class=forumrowHighlight><B>用户数</B></td>
      <td width="17%" class=forumrowHighlight><B>操作</B></td>
    </tr>
    <%
Set Rs=Conn.Execute("Select * From Ms_UserGroups Where ParentGID=3 Order By MinArticle")
Do While Not Rs.Eof
%>
    <input type=hidden value="<%=rs("UserGroupID")%>" name="usertitleid">
    <tr> 
      <td class=Forumrow align=center><%=Rs("UserGroupID")%></td>
      <td height="11" class=Forumrow><input size=15 value="<%=rs("usertitle")%>" name="usertitle" type=text></td>
      <td align="left" class=Forumrow> <input size=5 value="<%=rs("MinArticle")%>" name="minarticle" type=text></td>
      <td align="left" class=Forumrow><input name="Udiary" type="text" size="5" value="<%=rs("Udiary")%>"></td>
      <td align="left" class=Forumrow><input name="Uphoto" type="text" size="5" value="<%=rs("Uphoto")%>"></td>
      <td class=Forumrow><input size=15 value="<%=rs("grouppic")%>" name="titlepic" type=text> 
        <img src="../<%=rs("grouppic")%>" border="0"> 
      </td>
      <td align="center" class=Forumrow> <B><%=rs("Useradd")%></B> </td>
      <td class=Forumrow><a href="?action=editgroup&groupid=<%=rs("UserGroupID")%>">编辑</a> 
        | <a href="admin_user.asp?action=userSearch&userSearch=10&usergroupid=<%=rs("usergroupid")%>">列出用户</a> 
        | <a href="?action=delusergroup&id=<%=rs("UserGroupID")%>" onclick="{if(confirm('删除操作将会自动更新一部分用户的等级，并且不可恢复，确定吗?')){return true;}return false;}">删除</a></td>
    </tr>
    <%
Rs.MoveNext
Loop
Set Rs=Nothing
%>
    <input type=hidden value="0" name="usertitleid">
    <tr> 
      <td class=Forumrow align=center><font color=blue>新</font></td>
      <td height="23" class=Forumrow><input size=15 value="" name="usertitle" type=text></td>
      <td class=Forumrow><input size=5 value="0" name="minarticle" type=text ></td>
      <td class=Forumrow><input name="Udiary" type="text" value="0" size="5"></td>
      <td class=Forumrow><input name="Uphoto" type="text" value="0" size="5"></td>
      <td class=Forumrow><input size=15 value="images/star/level0.gif" name="titlepic" type=text> 
      </td>
      <td align="center" class=Forumrow> <B>0</B></td>
      <td class=Forumrow></td>
    </tr>
    <tr align=center> 
      <td colspan=8 height=25 class="forumrowHighlight"> <input type=submit name=submit value="提交更改"> 
      </td>
    </tr>
  </FORM>
</table>
<br>
<a name="3" id="3"></a> 
<table width="98%" border="0" cellspacing="1" cellpadding="3" class="tableBorder">
  <tr align="center"> 
    <th height=25 colspan="6" align="left" id=tabletitlelink>特殊用户组管理[<a href="#top">顶部</a>]</th>
  </tr>
  <tr> 
    <td height="35" colspan="6" class="forumRow">小提示：点击权限您可以分别设定每个特殊用户组分别拥有不同的系统权限，通常建立来分配给系统上比较特殊的用户群体，特殊组头衔和图标显示在前台用户信息中 
    </td>
  </tr>
  <tr> 
    <td class=forumrowHighlight><B>组ID</B></td>
    <td width="17%" height="23" class=forumrowHighlight><B>特殊组头衔</B></td>
    <td class=forumrowHighlight><B>系统中名称</B></td>
    <td class=forumrowHighlight><B>特殊组图片</B></td>
    <td height="23" class=forumrowHighlight><B>用户数</B></td>
    <td class=forumrowHighlight><B>操作</B></td>
  </tr>
  <FORM METHOD=POST ACTION="?action=savesysgroup">
    <input type=hidden value="2" name="ParentID">
    <%
Set Rs=Conn.Execute("Select * From Ms_UserGroups Where ParentGID=2 Order By UserGroupID")
Do While Not Rs.Eof
%>
    <input type=hidden value="<%=rs("UserGroupID")%>" name="usertitleid">
    <input type=hidden value="<%=rs("IsSetting")%>" name="issetting">
    <tr> 
      <td width="7%" align=center class=Forumrow><%=Rs("UserGroupID")%></td>
      <td width="17%" height="11" class=Forumrow><input size=15 value="<%=rs("usertitle")%>" name="usertitle" type=text></td>
      <td width="17%" align="left" class=Forumrow><input size=15 value="<%=rs("title")%>" name="title" type=text> 
      </td>
      <td width="32%" class=Forumrow><input size=15 value="<%=rs("grouppic")%>" name="titlepic" type=text> 
        <img src="../<%=rs("grouppic")%>" border="0"> 
      </td>
      <td width="7%" align="center" class=Forumrow> <B><%=rs("Useradd")%></B> </td>
      <td width="20%" class=Forumrow><a href="?action=editgroup&groupid=<%=rs("UserGroupID")%>">编辑</a> 
        | <a href="admin_user.asp?action=userSearch&userSearch=10&usergroupid=<%=rs("usergroupid")%>">列出用户</a> 
        | <a href="?action=delusergroup&id=<%=rs("UserGroupID")%>" onclick="{if(confirm('删除操作将会自动更新一部分用户的等级，并且不可恢复，确定吗?')){return true;}return false;}">删除</a></td>
    </tr>
    <%
Rs.MoveNext
Loop
Set Rs=Nothing
%>
    <input type=hidden value="0" name="usertitleid">
	<input type=hidden value="" name="issetting">
    <tr> 
      <td class=Forumrow align=center><font color=blue>新</font></td>
      <td height="23" class=Forumrow><input size=15 value="" name="usertitle" type=text></td>
      <td class=Forumrow><input size=15 value="" name="title" type=text ></td>
      <td class=Forumrow><input size=15 value="images/star/level0.gif" name="titlepic" type=text></td>
      <td align="center" class=Forumrow> <B>0</B></td>
      <td class=Forumrow></td>
    </tr>
    <tr align=center> 
      <td colspan=6 height=25 class="forumrowHighlight"> <input type=submit name=submit value="提交更改"> 
      </td>
    </tr>
  </FORM>
</table>
<br>
<%
Dim FoundVipGroup
FoundVipGroup = False
%>
<a name="4" id="4"></a> 
<table width="98%" border="0" cellspacing="1" cellpadding="3" class="tableBorder">
  <tr> 
    <th height="23" align=left colspan="6"  id=tabletitlelink>Vip用户组管理[<a href="#top">顶部</a>]</th>
</tr>
<tr><td colspan=6 height=25 class="Forumrow">
小提示：VIP用户将有权限限期控制，当该用户的使用权限过期，系统将会自动将会员转到默认注册组。
</td></tr>
<tr>
    <td width="7%" class=forumrowHighlight><B>组ID</B></td>
<td height="23" width="15%" class=forumrowHighlight><B>特殊组头衔</B></td>
    <td width="17%" class=forumrowHighlight><B>系统中名称</B></td>
    <td width="32%" class=forumrowHighlight><B>特殊组图片</B></td>
    <td height="23" width="7%" class=forumrowHighlight><B>用户数</B></td>
<td width="20%" class=forumrowHighlight><B>操作</B></td>
</tr>
<FORM METHOD=POST ACTION="?action=savesysgroup">
<input type=hidden value="5" name="ParentID">
<%
Set Rs=Conn.Execute("Select * From Ms_UserGroups Where ParentGID=5 Order By UserGroupID")
Do While Not Rs.Eof
FoundVipGroup = True
%>
<input type=hidden value="<%=rs("UserGroupID")%>" name="usertitleid">
<input type=hidden value="<%=rs("IsSetting")%>" name="issetting">
<tr>
<td class=Forumrow align=center><%=Rs("UserGroupID")%></td>
<td height="23" class=Forumrow><input size=15 value="<%=rs("usertitle")%>" name="usertitle" type=text></td>
<td class=Forumrow><input size=15 value="<%=rs("title")%>" name="title" type=text></td>
<td class=Forumrow><input size=15 value="<%=rs("grouppic")%>" name="titlepic" type=text>
<img src="../<%=rs("grouppic")%>" border="0">
</td>
      <td width="7%" align="center" class=Forumrow> <B><%=rs("Useradd")%></B> </td>
<td class=Forumrow><a href="?action=editgroup&groupid=<%=rs("UserGroupID")%>">编辑</a> | <a href="admin_user.asp?action=userSearch&userSearch=10&usergroupid=<%=rs("usergroupid")%>">列出用户</a> | <a href="?action=delusergroup&id=<%=rs("UserGroupID")%>" onclick="{if(confirm('删除后VIP用户将失去相关的VIP权限，并且不可恢复，确定吗?')){return true;}return false;}">删除</a></td>
</tr>
<%
Rs.MoveNext
Loop
Set Rs=Nothing
%>
<input type=hidden value="0" name="usertitleid">
<input type=hidden value="" name="issetting">
<tr>
<td class=Forumrow align=center><font color=blue>新</font></td>
<td height="23" class=Forumrow><input size=15 value="" name="usertitle" type=text></td>
<td class=Forumrow><input size=15 value="Vip用户组" name="title" type=text ></td>
<td class=Forumrow><input size=15 value="images/star/level0.gif" name="titlepic" type=text></td>
      <td align="center" class=Forumrow> <B>0</B></td>
<td class=Forumrow></td>
</tr>
<tr align=center>
<td colspan=6 height=25 class="forumrowHighlight">
<input type=submit name=submit value="提交更改">
</td></tr>
</FORM>
</table>
<%end sub

Sub EditGroup()
	If Not IsNumeric(Replace(Request("groupid"),",","")) Then
		Errmsg = ErrMsg + "<BR><li>请选择对应的用户组。"
		Ms_Error()
		Exit Sub
	End If

if request("groupaction")="yes" then
	dim GroupSetting,Groupidq
	if request.form("title")="" then
	response.write "请输入用户组名称！"
	exit sub
	end if
	GroupSetting=GetGroupPermission
	Set rs= Server.CreateObject("ADODB.Recordset")
	sql="select UserTitle,GroupSetting,titlepic from Ms_usergroups where usergroupid="&Clng(request("groupid"))&""
	rs.open sql,conn,1,3
	Do While Not Rs.Eof
	rs("UserTitle")=request.form("title")
	rs("GroupSetting")=GroupSetting
	rs("titlepic")=request("grouppic")
	Rs.update
		Rs.MoveNext
		Loop
		Rs.close
		Set Rs=Nothing
		Ms_suc("用户组（等级）资料修改成功！")
Else
		Dim reGroupSetting
		Set Rs=Conn.Execute("Select * From Ms_Usergroups Where UserGroupID="&Clng(request("groupid")))
		If Rs.Eof And Rs.Bof Then
			Errmsg = ErrMsg + "<BR><li>未找到该用户组！"
			Ms_Error()
			Exit Sub
		End If
		reGroupSetting=Split(Rs("GroupSetting"),",")
%>

<table width="98%" border="0" cellspacing="1" cellpadding="3" class="tableBorder">
  <FORM METHOD=POST ACTION="?action=editgroup" name="TheForm">
    <tr> 
      <th height="23" colspan="3"> 用户组权限设置 </th>
    </tr>
    <tr> 
      <td colspan=3 height=25 class="Forumrow"><B>说明</B>： <BR>
        ①在这里您可以设置各个用户组（等级）在系统中的默认权限; <BR>
        ②可以删除和编辑新添加的用户组; </td>
    </tr>
    <tr> 
      <th height="23" colspan="3" align=left> <a name="setting1"></a> 编辑用户组(等级)资料信息 
      </th>
    </tr>
    <tr> 
      <td colspan=3 height=25 class="bodytitle"> <B><a href="?">用户组(等级)管理</a> 
        >> <%=Rs("UserTitle")%></B> <input name="groupid" type="hidden" value="<%=Request("groupid")%>"> 
      </td>
    </tr>
    <tr> 
      <td height="23" class=Forumrow>用户组(等级)名称</td>
      <td height="23" class=Forumrow colspan=2><input size=35 name="title" type=text value="<%=Rs("UserTitle")%>"></td>
    </tr>
    <tr> 
      <td height="23" class=Forumrow>用户组(等级)图片</td>
      <td height="23"class=Forumrow colspan=2><input size=35 name="grouppic" type=text value="<%=rs("grouppic")%>"></td>
    </tr>
    <%
GroupPermission(rs("GroupSetting"))
%>
    <input type=hidden value="yes" name="groupaction">
  </FORM>
</table>
<%
		Set Rs=Nothing
	End If
End Sub

'保存注册用户组(等级)批量更改信息
Sub SaveUserGroup()
	Server.ScriptTimeout=99999999
	Dim UserTitleID,UserTitle,MinArticle,TitlePic,Udiary,Uphoto
	For i=1 To Request.Form("usertitleid").Count
		UserTitleID=Replace(Request.Form("usertitleid")(i),"'","")
		UserTitle=Replace(Request.Form("usertitle")(i),"'","")
		MinArticle=Replace(Request.Form("minarticle")(i),"'","")
		TitlePic=Replace(Request.Form("titlepic")(i),"'","")
		Udiary=Replace(Request.Form("Udiary")(i),"'","")
		Uphoto=Replace(Request.Form("Uphoto")(i),"'","")
		If IsNumeric(UserTitleID) And UserTitle<>"" And IsNumeric(MinArticle) And TitlePic<>"" Then
			Set Rs=Conn.Execute("Select * From Ms_UserGroups Where ParentGID=3 And UserGroupID="&UserTitleID)
			If Not (Rs.Eof And Rs.Bof) Then
				If Rs("UserTitle")<>Trim(UserTitle) Or Rs("GroupPic")<>Trim(TitlePic) Then
					Conn.Execute("Update [Ms_User] Set UserClass='"&UserTitle&"',TitlePic='"&TitlePic&"' Where UserGroupID="&UserTitleID)
				End If
				Conn.Execute("Update Ms_UserGroups Set UserTitle='"&UserTitle&"',MinArticle="&MinArticle&",GroupPic='"&TitlePic&"',Uphoto="&Uphoto&",Udiary="&Udiary&" Where UserGroupID="&UserTitleID)
			End If
			'新加入用户组(等级)
			If Clng(UserTitleID) = 0 Then
				Set Rs=Conn.Execute("Select * From Ms_UserGroups Where UserGroupID=4")
				Conn.Execute("Insert Into Ms_UserGroups (Title,UserTitle,GroupSetting,Orders,MinArticle,TitlePic,GroupPic,ParentGID,Uphoto,Udiary) Values ('"&Rs("Title")&"','"&UserTitle&"','"&Rs("GroupSetting")&"',0,"&MinArticle&",'"&Rs("TitlePic")&"','"&TitlePic&"',3,"&Uphoto&","&Udiary&")")
			End If
		End If
	Next
	Ms_suc("批量更新用户组（等级）资料成功！")
	Set Rs=Nothing
	LoadGroupSetting
End Sub

'保存系统、特殊、多属性用户组批量更改信息
Sub SaveSysGroup()
	Server.ScriptTimeout=99999999
	Dim UserTitleID,UserTitle,TitlePic,ParentID,Title,IsSetting,FoundIsSetting,mIsSetting,GroupIDList,k
	SQL = "Select UserGroupID From Ms_UserGroups"
	Set Rs = Conn.Execute(SQL)
		GroupIDList = Rs.GetString(,, "", ",", "")
	Rs.close
	Set Rs = Nothing
	GroupIDList = "," & GroupIDList
	GroupIDList = Replace(GroupIDList,",","|")
	ParentID = Request.Form("ParentID")
	If Not IsNumeric(ParentID) Or ParentID="" Then
		Errmsg = ErrMsg + "<BR><li>非法的用户组参数。"
		Ms_Error()
		Exit Sub
	End If
	ParentID = Cint(ParentID)
	FoundIsSetting = True
	For i=1 To Request.Form("usertitleid").Count
		UserTitleID=Replace(Request.Form("usertitleid")(i),"'","")
		UserTitle=Replace(Request.Form("usertitle")(i),"'","")
		Title=Replace(Request.Form("title")(i),"'","")
		TitlePic=Replace(Request.Form("titlepic")(i),"'","")
		IsSetting=Replace(Request.Form("issetting")(i),"'","")
		If IsNumeric(UserTitleID) And UserTitle<>"" And TitlePic<>"" Then
			Set Rs=Conn.Execute("Select * From Ms_UserGroups Where ParentGID="&ParentID&" And UserGroupID="&UserTitleID)
			If Not (Rs.Eof And Rs.Bof) Then
				If Rs("UserTitle")<>Trim(UserTitle) Or Rs("GroupPic")<>Trim(TitlePic) Then
					Conn.Execute("Update [Ms_User] Set UserClass='"&UserTitle&"',TitlePic='"&TitlePic&"' Where UserGroupID="&UserTitleID)
				End If
			End If
			If ParentID = 4 And Trim(IsSetting)<>"" Then
				mIsSetting = Split(IsSetting,"|")
				For k = 0 To Ubound(mIsSetting)
					'多属性用户组，填写的UserGroupID不存在则不更新
					If InStr(GroupIDList,"|" & mIsSetting(k) & "|") = 0 Then
						FoundIsSetting = False
						Exit For
					End If
				Next
				If FoundIsSetting Then
					Conn.Execute("Update Ms_UserGroups Set Title='"&Title&"',UserTitle='"&UserTitle&"',GroupPic='"&TitlePic&"',IsSetting='"&IsSetting&"' Where UserGroupID="&UserTitleID)
					'新加入用户组
					If Clng(UserTitleID) = 0 Then
						Set Rs=Conn.Execute("Select * From Ms_UserGroups Where UserGroupID=4")
						Conn.Execute("Insert Into Ms_UserGroups (Title,UserTitle,GroupSetting,Orders,MinArticle,TitlePic,GroupPic,ParentGID,IsSetting) Values ('"&Title&"','"&UserTitle&"','"&Rs("GroupSetting")&"',0,0,'"&Rs("TitlePic")&"','"&TitlePic&"',"&ParentID&",'"&IsSetting&"')")
					End If
				Else
					Conn.Execute("Update Ms_UserGroups Set Title='"&Title&"',UserTitle='"&UserTitle&"',GroupPic='"&TitlePic&"' Where UserGroupID="&UserTitleID)
				End If
				FoundIsSetting = True
			Else
				Conn.Execute("Update Ms_UserGroups Set Title='"&Title&"',UserTitle='"&UserTitle&"',GroupPic='"&TitlePic&"' Where UserGroupID="&UserTitleID)
				'新加入用户组
				If Clng(UserTitleID) = 0 Then
					Set Rs=Conn.Execute("Select * From Ms_UserGroups Where UserGroupID=4")
					Conn.Execute("Insert Into Ms_UserGroups (Title,UserTitle,GroupSetting,Orders,MinArticle,TitlePic,GroupPic,ParentGID) Values ('"&Title&"','"&UserTitle&"','"&Rs("GroupSetting")&"',0,0,'"&Rs("TitlePic")&"','"&TitlePic&"',"&ParentID&")")
				End If
			End If
		End If
	Next
	Ms_suc("批量用户组资料成功！")
	Set Rs=Nothing
End Sub

'删除注册用户组(等级)信息
Sub DelUserGroup()
	Dim UserTitleID,tRs
	UserTitleID = Request("id")
	If Not IsNumeric(UserTitleID) Or UserTitleID = "" Then
		Errmsg = ErrMsg + "<BR><li>请指定要删除的用户组(等级)。"
		Ms_Error()
		Exit Sub
	End If
	UserTitleID = Clng(UserTitleID)
	'检测用户组是否存在以及取得临近用户组的信息
	'如果用户组为特殊、多属性组，则更新其用户信息为最低等级，用户登陆后会自动重新更新
	Set Rs=Conn.Execute("Select * From Ms_UserGroups Where (Not ParentGID=1) And UserGroupID = " & UserTitleID)
	If Rs.Eof And Rs.Bof Then
		Errmsg = ErrMsg + "<BR><li>指定要删除的用户组(等级)不存在。"
		Ms_Error()
		Exit Sub
	ElseIf Not Rs("UserGroupID") = 8 And Rs("ParentGID") = 2 Then
		Set tRs = Conn.Execute("SELECT TOP 1 * FROM Ms_UserGroups WHERE ParentGID = 3 ORDER BY MinArticle Desc")
		If tRs.Eof And tRs.Bof Then
			Errmsg = ErrMsg + "<BR><li>注册用户组(等级)为空，不能删除，请先添加至少一个注册用户组(等级)。"
			Ms_Error()
			Exit Sub
		Else
			Conn.Execute("UPDATE Ms_User SET UserClass = '" & tRs("UserTitle") & "', TitlePic = '" & tRs("GroupPic") & "', UserGroupID = " & tRs("UserGroupID") & " WHERE UserGroupID = " & UserTitleID)
			Conn.Execute("DELETE FROM Ms_UserGroups WHERE UserGroupID = " & UserTitleID)
		End If
	Else
		Set tRs=Conn.Execute("Select Top 1 * From Ms_UserGroups Where ParentGID=3 And (Not UserGroupID="&UserTitleID&") And MinArticle<="&Rs("MinArticle")&" Order By MinArticle Desc")
		If tRs.Eof And tRs.Bof Then
			Errmsg = ErrMsg + "<BR><li>该用户组(等级)为最后一个注册用户组，不能删除。"
			Ms_Error()
			Exit Sub
		Else
			Conn.Execute("Update Ms_User Set UserClass='"&tRs("UserTitle")&"',TitlePic='"&tRs("GroupPic")&"',UserGroupID="&tRs("UserGroupID")&" Where UserGroupID="&UserTitleID)
			Conn.Execute("Delete From Ms_UserGroups Where UserGroupID = " & UserTitleID)
		End If
		Set tRs=Nothing
	End If
	Ms_suc("用户组（等级）资料删除成功！")
	Set Rs=Nothing
End Sub%>