📄 edituser.jsp
字号:
<%
/**
* $RCSfile: editUser.jsp,v $
* $Revision: 1.3 $
* $Date: 2000/12/18 02:06:21 $
*/
%>
<%@ page import="java.util.*,
java.net.*,
com.coolservlets.forum.*,
com.coolservlets.forum.util.*,
com.coolservlets.forum.util.admin.*"
errorPage="error.jsp"
%>
<jsp:useBean id="adminBean" scope="session"
class="com.coolservlets.forum.util.admin.AdminBean"/>
<% ////////////////////////////////
// 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();
// redirect to error page if we're not a user admin or a system admin
if( !isSystemAdmin ) {
throw new UnauthorizedException("对不起,您不允许修改用户资料。");
}
%>
<% ///////////////////////
// get parameters
boolean saveChanges = ParamUtils.getBooleanParameter(request,"saveChanges");
String username = ParamUtils.getParameter(request,"user");
String name = ParamUtils.getParameter(request,"name",true);
String email = ParamUtils.getParameter(request,"email");
boolean nameVisible = ParamUtils.getBooleanParameter(request,"nameVisible");
boolean emailVisible = ParamUtils.getBooleanParameter(request,"emailVisible");
%>
<% ////////////////
// create a profile manager
ProfileManager manager = forumFactory.getProfileManager();
%>
<% /////////////////
// check for errors
boolean errorEmail = (email==null);
boolean errors = (errorEmail);
%>
<% //////////////////
// save user changes if necessary
if( !errors && saveChanges ) {
User user = manager.getUser(username);
if( name != null ) {
user.setName(name);
}
if( email != null ) {
user.setEmail(email);
}
user.setEmailVisible( emailVisible );
user.setNameVisible( nameVisible );
// redirect to user main page
response.sendRedirect(
response.encodeRedirectURL("users.jsp?msg=修改成功")
);
return;
}
%>
<% //////////////////////
// user properties
User user = manager.getUser(username);
int userID = user.getID();
name = user.getName();
email = user.getEmail();
boolean isEmailVisible = user.isEmailVisible();
boolean isNameVisible = user.isNameVisible();
Enumeration userProperties = user.propertyNames();
%>
<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>
<form action="editUser.jsp">
<input type="hidden" name="saveChanges" value="true">
<input type="hidden" name="user" value="<%= username %>">
<p>
用户<b><%= username %></b>的属性
<p>
<table bgcolor="#666666" cellpadding="0" cellspacing="0" border="0" width="80%" align="center">
<td>
<table bgcolor="#666666" cellpadding="3" cellspacing="1" border="0" width="100%">
<tr bgcolor="#ffffff">
<td>用户ID:</td>
<td colspan="2"><%= userID %></td>
</tr>
<tr bgcolor="#ffffff">
<td>用户名:</td>
<td colspan="2"><%= username %></td>
</tr>
<tr bgcolor="#ffffff">
<td>姓名:</td>
<td colspan="2">
<input type="text" name="name" value="<%= (name!=null)?name:"" %>">
</td>
</tr>
<tr bgcolor="#ffffff">
<td>在论坛中姓名可见</td>
<td>
<input type="radio" name="nameVisible" value="true" id="rb01"<%= isNameVisible?" checked":"" %>>
<label for="rb01">是</label>
</td>
<td>
<input type="radio" name="nameVisible" value="false" id="rb02"<%= !isNameVisible?" checked":"" %>>
<label for="rb02">否</label>
</td>
</tr>
<tr bgcolor="#ffffff">
<td>Email:</td>
<td colspan="2">
<input type="text" name="email" value="<%= (email!=null)?email:"" %>">
</td>
</tr>
<tr bgcolor="#ffffff">
<td>在论坛中Email可见</td>
<td>
<input type="radio" name="emailVisible" value="true" id="rb03"<%= isEmailVisible?" checked":"" %>>
<label for="rb03">是</label>
</td>
<td>
<input type="radio" name="emailVisible" value="false" id="rb04"<%= !isEmailVisible?" checked":"" %>>
<label for="rb04">否</label>
</td>
</tr>
</table>
</td>
</table>
<p>
扩展属性
<p>
<table bgcolor="#666666" cellpadding="0" cellspacing="0" border="0" width="80%" align="center">
<td>
<table bgcolor="#666666" cellpadding="3" cellspacing="1" border="0" width="100%">
<% if( !userProperties.hasMoreElements() ) { %>
<tr bgcolor="#ffffff">
<td align="center"><i>没有设置扩展属性</i></td>
</tr>
<% } %>
<% while( userProperties.hasMoreElements() ) {
String propName = (String)userProperties.nextElement();
String propValue = user.getProperty(propName);
%>
<tr bgcolor="#ffffff">
<td><%= propName %></td>
<td><input type="text" size="30" maxlength="100" value="<%= propValue %>"></td>
</tr>
<% } %>
</table></td></table>
<p>
<center>
<input type="submit" value="保存修改">
</center>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -