📄 editgroup.jsp
字号:
<%
/**
* $RCSfile: editGroup.jsp,v $
* $Revision: 1.3.2.1 $
* $Date: 2001/05/22 17:59:54 $
*/
%>
<%@ page import="java.util.*,
com.coolservlets.forum.*,
com.coolservlets.forum.util.*,
com.coolservlets.forum.util.admin.*"%>
<jsp:useBean id="adminBean" scope="session"
class="com.coolservlets.forum.util.admin.AdminBean"/>
<% try { %>
<% ////////////////////////////////
// Jive authorization check
// check the bean for the existence of an authorization token.
// Its existence proves the user is valid. If it's not found, redirect
// to the login page
Authorization authToken = adminBean.getAuthToken();
if( authToken == null ) {
response.sendRedirect( "/mainctrl/bbs/admin" );
return;
}
%>
<% ////////////////////
// Security check
// make sure the user is authorized to administer users:
ForumFactory forumFactory = ForumFactory.getInstance(authToken);
boolean isSystemAdmin = ((Boolean)session.getValue("jiveAdmin.systemAdmin")).booleanValue();
boolean isGroupAdmin = ((Boolean)session.getValue("jiveAdmin.groupAdmin")).booleanValue();
// redirect to error page if we're not a group admin or a system admin
if( !isGroupAdmin && !isSystemAdmin ) {
request.setAttribute("message","您没有权限管理用户组!");
response.sendRedirect("error.jsp");
return;
}
%>
<% ////////////////////
// get parameters
int groupID = ParamUtils.getIntParameter(request,"group",-1);
String newGroupName = ParamUtils.getParameter(request,"groupName");
String newGroupDescription = ParamUtils.getParameter(request,"groupDescription",true);
boolean doEdit = ParamUtils.getBooleanParameter(request,"doEdit");
%>
<% ////////////////////
//
boolean noGroupSpecified = (groupID<0);
%>
<% //////////////////////////////////
// global error variables
String errorMessage = "";
boolean errorGroupName = (newGroupName == null);
boolean errorGroupAlreadyExists = false;
boolean errorNoPermissionToEdit = false;
boolean errorGroupNotFound = false;
boolean errors = (noGroupSpecified);
%>
<% ////////////////////////////////////////////////////////////////
// if there are no errors at this point, start the process of
// adding the user
ProfileManager manager = forumFactory.getProfileManager();
Group thisGroup = null;
if( !errors ) {
try {
thisGroup = manager.getGroup(groupID);
} catch( GroupNotFoundException gnfe ) {
errorGroupNotFound = true;
System.err.println( "groupNotFoundException" );
}
}
errors = (errors || (thisGroup==null));
if( !errors && doEdit ) {
// get a profile manager to edit user properties
try {
thisGroup.setName( newGroupName );
if( newGroupDescription != null ) {
thisGroup.setDescription( newGroupDescription );
}
}
catch( UnauthorizedException ue ) {
errorNoPermissionToEdit = true;
}
}
String name = null;
String description = null;
if( !errors ) {
name = thisGroup.getName();
description = thisGroup.getDescription();
}
%>
<% /////////////////////
// overall error check
errors = (errorGroupName || errorGroupAlreadyExists
|| errorNoPermissionToEdit);
%>
<% ////////////////////
// set error messages
if( errors ) {
if( errorGroupName ) {
errorMessage = "请输入用户组名称。";
}
else if( errorGroupAlreadyExists ) {
errorMessage = "此用户组名称已经存在,请选择另一个名称。";
}
else if( errorNoPermissionToEdit ) {
errorMessage = "对不起,您没有权限修改用户组属性。";
}
else if( errorGroupNotFound ) {
errorMessage = "此用户组不存在。";
}
else {
errorMessage = "发生一般错误。";
}
}
%>
<% //////////////////////////////////////////////////////////////////////
// if a group was edited was successfully created, say so and return (to stop the
// jsp from executing
if( !errors ) {
request.setAttribute("message","用户组修改成功!");
response.sendRedirect("groups.jsp");
return;
}
%>
<html>
<head>
<title></title>
<link rel="stylesheet" href="style/global.css">
</head>
<body background="images/shadowBack.gif" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<% ///////////////////////
// pageTitleInfo variable (used by include/pageTitle.jsp)
String[] pageTitleInfo = { "用户组 : 修改用户组" };
%>
<% ///////////////////
// pageTitle include
%><%@ include file="include/pageTitle.jsp" %>
<p>
<% ////////////////////
// display a list of groups to edit if no group was specified:
if( noGroupSpecified ) {
String formAction = "edit";
%>
<%@ include file="groupChooser.jsp"%>
<% out.flush();
return;
}
%>
<%-- form --%>
<form action="editGroup.jsp" method="post">
<input type="hidden" name="group" value="<%= groupID %>">
<input type="hidden" name="doEdit" value="true">
<b>修改用户组信息:</b>
<p>
<table bgcolor="#999999" cellspacing="0" cellpadding="0" border="0" width="95%" align="right">
<td>
<table bgcolor="#999999" cellspacing="1" cellpadding="3" border="0" width="100%">
<%-- name row --%>
<tr bgcolor="#ffffff">
<td><font size="-1">用户组名称:</i></font></td>
<td><input type="text" name="groupName" size="30" maxlength="100"
value="<%= (name!=null)?name:"" %>">
</td>
</tr>
<%-- description row --%>
<tr bgcolor="#ffffff">
<td><font size="-1">用户组描述:<br>(可选)</i></font></td>
<td>
<textarea name="groupDescription" wrap="virtual" cols="40" rows="5"
><%= (description!=null)?description:"" %></textarea>
</td>
</tr>
</table>
</td>
</table>
<br clear="all"><br>
<p>
<center>
<input type="submit" value="修改用户组信息">
<input type="submit" value="取消" onclick="location.href='groups.jsp';return false;">
</center>
</form>
<%-- /form --%>
</body>
</html>
<% } catch( Exception e ) {
System.err.println(e);
e.printStackTrace();
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -