<!--#INCLUDE FILE="setup.asp" -->
<!--#INCLUDE FILE="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<!--#INCLUDE FILE="include/char.asp" -->
<%Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1  
Response.cachecontrol = "no-cache"

Locat="班级管理"

If membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=login.asp>登录</a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
Else
	Dim ClsID,Degree,ClassName
	ClsID=Request("ClassID")
	joinstatus=chkjoinclass(ClsID)
	If joinstatus<>"" Then
		Call top(1,1)
		Call Error("Exclamation",joinstatus)
	Else
		If Request("About")="Pronouncement" Then
			act="修改班级宣言"
			Call top(3,1)
			Call Pronouncement()
		ElseIf Request("Action")="modifypron" Then
			act="修改班级宣言"
			Call top(3,1)
			Call ModifyPron()
		ElseIf Request("Action")="update" Then
			act="修改班级属性"
			Call top(3,1)
			Call update()
		ElseIf Request("Action")="Main" Then
			Call top(2,1)
			Call Main()
		Else 
			act="修改班级属性"
			Call top(3,1)
			Call classinfo()
		End If
	End If
End If


Sub Main()
%>

<br><br>
<table cellpadding=5 cellspacing=1 border=0 width=700 align=center Class=TableBorder>
<TR align=middle><Th colspan=2><b>班级管理员权利和义务</b></Th></TR>
<tr><td rowspan=2 width=140 Class=DarkTableBody valign=top align=center>
<a href=ClsAdm_Class.asp?ClassID=<%=ClsID%>><IMG SRC=Images/setting.gif BORDER=0 vspace=4><BR>设置班级属性</a><BR><BR>
<a href=ClsAdm_Rights.asp?ClassID=<%=ClsID%>><IMG SRC=Images/rights.gif BORDER=0 vspace=4><BR>管理班委权限</a><BR><BR>
<a href=ClsAdm_Member.asp?ClassID=<%=ClsID%>><IMG SRC=Images/member.gif BORDER=0 vspace=4><BR>班级人事管理</a><BR><BR>
<a href=ClsAdm_Class.asp?ClassID=<%=ClsID%>&About=Pronouncement><IMG SRC=Images/pron.gif BORDER=0 vspace=4><BR>班级宣言管理</a><BR><BR>
<a href=Misc.asp?ClassID=<%=ClsID%>&Action=ViewLog><IMG SRC=Images/log.gif BORDER=0 vspace=4><BR>班级管理日志</a>
<BR><BR></td>
<TD Class=LightTableBody  valign=center class=mp><p><li>遵守同学录用户协议，管理班级成员不传输任何非法的、骚扰性的、中伤他人的、辱骂性的、恐吓性的、伤害性的、庸俗的，淫秽等信息资料。若任何班级成员的行为不符合以上条款，将作出独立判断立即取消用户服务帐号，并视情节的严重性付诸于法律。<BR><BR>
<li>有权将班级的名称进行合理更改，使其更容易查询，方便其他同学注册。
<BR><BR><li>有权修改班级主页地址，或为你们的班级建立起网上交流的家园。
<BR><BR><li> 有权将不参与班级活动和班级更新维护的班委成员降级为普通班级成员。有权将经常不参与班级活动，违反用户协议的，对班级造成不良影响的普通班级成员从本班级中除名。
<BR><BR><li>有权将经常参与班级活动或为班级发展作出贡献的普通班级成员任命为班委成员，并授予一定的管理权限，协助管理班级事务，扩大班级人数。
<BR><BR><li>班级管理员可以将自己的管理权利转交给另一位班级成员，自己降级为普通成员。
<BR><BR><li>普通班级成员可以通过班级管理日志对管理员进行监督，如果有三个以上班级成员对管理员进行投诉，系统管理员有权力将他降级成为普通成员，并由班内重新推荐一位班级管理员。 

	</TD>
   </TR>  
</TABLE>
</FORM><BR>
<%
End Sub


Sub ModifyPron()

	Dim pron
	pron=Checkstr(rtrim(Request("pronouncement")))
	If pron="" Then
		ErrMsg=ErrMsg+"<br><li>请输入班级宣言！"
		Call Error("Information",ErrMsg)
	ElseIf strLength(pron)>200 Then
		ErrMsg=ErrMsg+"<br><li>班级宣言不能多于200个字符！"
		Call Error("Information",ErrMsg)
	ElseIf ChkRights(3)=False Then
		ErrMsg=ErrMsg+"<br><li>对不起，您不是本班的班委成员或班长没有赋予你此项操作的权限！"
		Call Error("Information",ErrMsg)
	Else
		Conn.Execute("update class Set pronouncement='"&pron&"' where classid="&ClsID)

		'write log
		IP=Request.ServerVariables("REMOTE_ADDR") 
		sql="insert into log (userid,content,classid,ip)"&_
			" values('"&membername&"','重新撰写班级宣言',"&ClsID&",'"&IP&"')"
		Conn.Execute(sql)

		stitle="班级信息管理"
		smsg="恭喜您，班级宣言修改成功！"
		Call success(stitle,smsg)
	End If

End Sub



Sub Pronouncement()

	If ChkRights(3)=False Then
		ErrMsg=ErrMsg+"<br><li>对不起，您不是本班的班委成员或班长没有赋予你此项操作的权限！"
		Call Error("Information",ErrMsg)
	Else

	Dim Rs
	Set Rs=Conn.Execute("Select pronouncement from class where classid="&ClsID)
	Response.Write "<br><br>"&_
		"<FORM action=ClsAdm_Class.asp?ClassID="&ClsID&" method=post>"&_
		"<input type=hidden name=Action value=modifypron>"&_
		"<table cellpadding=5 cellspacing=1 border=0 width=600 align=center Class=TableBorder>"&_
		"<TR align=middle><Th height=24><b>修改班级宣言</b></Th></TR>"&_
		"<TR Class=LightTableBody><TD align=center height=150>"&_
		"<TEXTAREA name=pronouncement rows=8 wrap=PHYSICAL cols=60 class=txt>"&Rs(0)&"</TEXTAREA>"&_
		"</TD></TR>"&_
		"<TR align=middle Class=DarkTableBody><TD><INPUT value=提交修改 type=submit class=button></TD></TR>"&_
		"</TABLE>"&_
		"</FORM>"
	Set Rs=Nothing

	End If

End Sub



Sub classinfo()

If Degree=1 and not sysadmin Then
	ErrMsg=ErrMsg+"<br><li>对不起，您没有此项操作的权限！"
	Call Error("Information",ErrMsg)
Else

Dim Rs
Set Rs=Conn.Execute("Select classname,enyear,homepage,isappendshow,openlevel,classpwd from class where classid="&ClsID)

Response.Write "<br><br>"&_
"<FORM action=ClsAdm_Class.asp?ClassID="&ClsID&" method=post>"&_
"<input type=hidden name=action value=update>"&_
"<table cellpadding=5 cellspacing=1 border=0 width=700 align=center Class=TableBorder>"&_
"<TR align=middle><Th colSpan=2 height=24><b>修改班级属性</b></Th></TR>"&_
"<tr Class=LightTableBody><td width=""100%"">"&_
	"<table border=0 cellspacing=5 cellpadding=14><tr><td width=""50%"">"&_
		"<fieldset style=""padding:10""><legend>基本信息</legend>"&_
		"<table cellspacing=1 cellpadding=5 border=0>"&_
			"<TR><TD><BR>请为你的班级起个最合适名字，方便其他同学查找和注册。<BR>"&_
				"<INPUT maxLength=16 size=30 name=classname  value="""&Rs(0)&""">"&_
				"<input type=hidden name=oldclassname value="""&rs(0)&""">"&_			
				"</TD></TR>"&_
			"<TR><TD>您的班级是哪一年入学的?<BR>"&_
				"<input type=hidden name=oldenyear value="""&rs(1)&""">"&_
				"<Select name=enyear size=1 style=""width:90pt"">"
				thisyear=cint(year(date()))
				startyear=thisyear-50
				for i=startyear to thisyear
					Response.Write "<option value="&i
					If i=cint(Rs(1)) Then Response.Write " selected"
					Response.Write ">"&i&"</option>"
				next
				Response.Write "</Select></TD></TR>"&_
			"<TR><TD>如果您的班级有主页，请填写地址。<BR>"&_
				"<INPUT maxLength=50 size=35 name=homepage value="""&Rs(2)&""">"&_
				"<input type=hidden name=oldhomepage value="""&rs(2)&""">"&_
				"</TD></TR>"&_
		"</table>"&_
		"</fieldset>"&_
		"<fieldset style=""padding: 10""><legend>可选项</legend>"&_
		"<table cellspacing=1 cellpadding=5 border=0><tr><td><BR>"&_
			"<input type=checkbox name=isappendshow id=isas value=1"
			If Rs(3)=True Then Response.Write " checked"
			Response.Write "><label for=isas>班级首页显示附加通讯录联接</label></td></tr>"&_
		"</table>"&_
		"</fieldset></td>"&_
	"<td>"&_
		"<fieldset style=""padding: 10;height:216pt""><legend>开放级别</legend>"&_
		"<table cellspacing=1 cellpadding=5 border=0><tr><td style=""line-height:130%"">"&_
			"<input type=hidden name=oldopenlevel value="""&rs(4)&""">"&_
			"<INPUT TYPE=radio NAME=openlevel id=l1 value=0"
			If Rs(4)=0 Then Response.Write " checked"
			Response.Write " onclick=""classpwd.disabled=true""><label for=l1>完全开放</label>&nbsp;&nbsp;&nbsp;&nbsp;"&_
			"任何注册用户都可以加入这个班级成为这个班级的一员。<BR></td></tr>"&_
			"<tr><td style=""line-height:130%""><INPUT TYPE=radio NAME=openlevel id=l2 value=1"
			If Rs(4)=1 Then Response.Write " checked"
			Response.Write "  onclick=""classpwd.disabled=false""><label for=l2>密码验证</label>&nbsp;&nbsp;&nbsp;&nbsp;"&_
			"注册用户只有向班级管理员索取班级密码，才能注册这个班级。<BR>"&_
			"&nbsp;&nbsp;&nbsp;班级密码：<INPUT type=text maxLength=16 size=20 name=classpwd"
			If Rs(4)<>1 Then Response.Write " disabled"
			Response.Write " value="""&Rs(5)&"""></td></tr>"&_
			"<tr><td style=""line-height:130%""><INPUT TYPE=radio NAME=openlevel id=l3 value=2"
			If Rs(4)=2 Then Response.Write " checked"
			Response.Write "  onclick=""classpwd.disabled=true""><label for=l3>班长审核</label>&nbsp;&nbsp;&nbsp;&nbsp;"&_
			"班外同学向班级管理员提出加入班级的请求后，由班长和授权班委决定是否将其加入班级。</td></tr>"&_
			"<tr><td style=""line-height:130%""><INPUT TYPE=radio NAME=openlevel id=l4 value=3"
			If Rs(4)=3 Then Response.Write " checked"
			Response.Write "  onclick=""classpwd.disabled=true""><label for=l4>锁定班级</label>&nbsp;&nbsp;&nbsp;&nbsp;"&_
			"如果你的同学已经全部加入到这个班级或者不想让其他班的同学来打扰，可以设为此项。</td></tr>"&_
		"</table>"&_
		"</fieldset>"&_
	"</td></tr></table>"&_
"</td></tr>"&_
"<TR align=middle Class=DarkTableBody><TD colSpan=2>"&_
	"<button style=""WIDTH: 70px;height:24px"" type=submit><span style=""color:green;FONT-SIZE: 11pt""><strong>√</strong></span>确定</button>&nbsp;&nbsp;&nbsp;&nbsp;"&_
	"<button style=""WIDTH: 70px;height:24px"" onclick=""javascript:history.go(-1)""><span style=""color:brown;FONT-SIZE: 11pt""><font color=><strong>×</strong></span>取消</button></TD></TR>"&_
"</table></FORM>"

End If

End Sub



Sub update()

	Dim Rs,sql
	Dim openlevel,classpwd
	Dim NewClassName,enyear,isappendshow,homepage
	Dim Thislog
	Dim ModiFlag

	If not (Degree>6 or sysadmin) Then
		ErrMsg=ErrMsg+"<br><li>对不起，您没有此项操作的权限！"
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End If

	NewClassName=replace(trim(Request.form("classname")),"'","")

	If NewClassName="" Then
		ErrMsg=ErrMsg+"<br><li>请输入班级名称！"
		FoundErr=True
	ElseIf strlength(NewClassName)<5 or strlength(NewClassName)>25 Then
		ErrMsg=ErrMsg+"<br><li>请输入班级名5-25个字符！"
		FoundErr=True
	Else
		if StrVar(3)<>"" then
			RestrictWords=split(StrVar(3),"|")
			for i=0 to ubound(RestrictWords)
				if instr(NewClassName,RestrictWords(i))=0 then
					ErrMsg=ErrMsg+"<br>"+"<li>"+"班级名称必须包含指定的限定词！"
					founderr=True
					exit for
				end if
			next
		else
			sql="Select classid from class where classname='"&NewClassName&"' and classid<>"&ClsID
			Set Rs=Conn.Execute(sql)
			If not (Rs.eof and Rs.bof) Then
				ErrMsg=ErrMsg+"<br>"+"<li>"+"您输入的班级名已经存在，请重新输入其他班级名！"
				FoundErr=True
			End If
		end if
	End If

	enyear=trim(Request.form("enyear"))

	thisyear=cint(year(date()))
	startyear=thisyear-50

	If not isinteger(enyear) or not (cint(enyear)>=startyear and cint(enyear)<=thisyear ) Then
			ErrMsg=ErrMsg+"<br>"+"<li>"+"您输入的入学年份不正确！"
			FoundErr=True
	End If

	If Request("isappendshow")="1" Then
		isappendshow=True
	Else
		isappendshow=False
	End If

	homepage=trim(Request.form("homepage"))
	openlevel=Request.form("openlevel")

	If openlevel=1 Then
		classpwd=trim(Request("classpwd"))
		If classpwd="" Then
			ErrMsg=ErrMsg+"<br><li>如果您选择班级开放等级为密码验证，则需输入班级密码！"
			FoundErr=True
		ElseIf strlength(classpwd)<6 or strlength(classpwd)>10 Then
			ErrMsg=ErrMsg+"<br>"+"<li>请输入班级密码6-10个字符!"
			FoundErr=True
		ElseIf isValidstring(classpwd)<>"" Then
			If isValidstring(classpwd)=" " Then invld="空格" Else invld=isValidstring(classpwd)
			ErrMsg=ErrMsg+"<br>"+"<li>密码中含有非法字符&nbsp;<font color=#cc0000>"&invld&"</font>&nbsp;。"
			FoundErr=True
		End If
	Else
		classpwd=null
	End If


	If FoundErr=True Then
		Call Error("Information",ErrMsg)
		Exit Sub
	End If

	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "Select classname,enyear,openlevel,homepage,isappendshow,classpwd from class where classid="&ClsID
	Rs.open SQL,Conn,1,3

	If not (Rs.eof and Rs.bof) Then

		'	If Rs("openlevel")=2 and (openlevel=0) Then
		'
		'		Conn.Execute("update student set point=point+"&PointSet(10)&" where userid"&_
		'		" in(select userid from joinclass where isauditing=true and classid="&ClsID&")")
		'		Set studpass=Conn.Execute("select count(userid) from joinclass where isauditing=True and classid="&ClsID)
		'		Conn.Execute("update class set studcount=studcount+"&studpass(0)&" where classid="&ClsID)
		'		Conn.Execute("update joinclass set isauditing=false,jointime=now(),lastvisit=now() where isauditing=True and classid="&ClsID)
		'
		'
		'	ElseIf Rs("openlevel")=2 and (openlevel=3 or openlevel=1) Then
		'		Conn.Execute("update student Set classcount=classcount-1 where userid"&_
		'		" in(Select userid from joinclass where isauditing=true and classid="&ClsID&")")
		'		Conn.Execute("delete from joinclass where isauditing=true and classid="&ClsID)
		'
		'	End If

		thislog="修改班级属性:"
		if request.form("oldclassname")<>NewClassName then
			Rs("classname")=NewClassName
			thislog=thislog&"设定班级名称为“"&NewClassName&"”"
			ModiFlag=true
		end if
		if request.form("oldenyear")<>enyear then
			Rs("enyear")=cint(enyear)
			thislog=thislog&",修改入学年份为"&enyear
			ModiFlag=true
		end if
		if request.form("oldhomepage")<>homepage then
			If homepage="" Then homepage=null
			Rs("homepage")=homepage
			thislog=thislog&",修改班级主页为"&homepage
			ModiFlag=true
		end if
		if Rs("isappendshow")<>isappendshow then
			Rs("isappendshow")=isappendshow
			ModiFlag=true
		end if
		if request.form("oldopenlevel")<>openlevel then
			Rs("openlevel")=cint(openlevel)
			if openlevel=1 then Rs("classpwd")=classpwd
			thislog=thislog&",设定班级开放级别“"&openlevel&"”"
			ModiFlag=true
		elseif request.form("oldopenlevel")=1 and openlevel=1 and Rs("classpwd")<>classpwd then
			Rs("classpwd")=classpwd 
			thislog=thislog&",修改班级通行密码"
			ModiFlag=true
		end if

		Rs.Update

		if ModiFlag then
			'write log
			IP=Request.ServerVariables("REMOTE_ADDR") 
			thislog=replace(thislog,":,",":")
			if right(thislog,1)=":" then thislog="修改班级属性"
			sql="insert into log(userid,content,classid,ip)"&_
				" values('"&membername&"','"&thislog&"',"&ClsID&",'"&IP&"')"
			Conn.Execute(sql)
		end if

		stitle="修改班级属性"
		smsg="恭喜您，班级属性修改成功！"
		Call success(stitle,smsg)

	End If

	Rs.close
	set Rs=nothing

End Sub


%>
<!--#INCLUDE FILE="include/validate.asp" -->

<%Call footer%>
