📄 settings.jsp
字号:
<%@ page contentType="text/html;charset=ISO8859_1" %>
<%
/**
* $RCSfile: settings.jsp,v $
* $Revision: 1.4 $
* $Date: 2002/10/08 14:16:27 $
*/
%>
<%@ page import="java.util.*,
com.jivesoftware.forum.*,
com.jivesoftware.forum.util.*"
errorPage="error.jsp"
%>
<%@ include file="global.jsp" %>
<%! private static Locale[] locales = Locale.getAvailableLocales();
%>
<%
int DEFAULT_THREAD_RANGE = 15;
// default number of messages to show
int DEFAULT_MESSAGE_RANGE = 15;
int[] THREAD_RANGES = {15, 30, 50, 100};
// possible values for message ranges
int[] MESSAGE_RANGES = {5, 15, 30, 50, 100};
// Timezones
String[][] timeZones = SkinUtils.getTimeZoneList();
// Parameters
//签名
String signature = ParamUtils.getParameter(request,"signature");
long userID = ParamUtils.getLongParameter(request,"user",-1L);
String username = ParamUtils.getParameter(request,"user");
String referer = ParamUtils.getParameter(request,"referer");
boolean save = ParamUtils.getBooleanParameter(request,"doSave");
String saveButton = ParamUtils.getParameter(request,"saveButton");
String localeCode = ParamUtils.getParameter(request,"locale");
String timeZoneID = ParamUtils.getParameter(request,"timeZone");
int threadRange = ParamUtils.getIntParameter(request,"threadRange",DEFAULT_THREAD_RANGE);
int messageRange = ParamUtils.getIntParameter(request,"messageRange",DEFAULT_MESSAGE_RANGE);
String name = ParamUtils.getParameter(request,"name");
String email = ParamUtils.getParameter(request,"email");
String occupation = ParamUtils.getParameter(request,"occupation",true);
String location = ParamUtils.getParameter(request,"location",true);
String homepage = ParamUtils.getParameter(request,"homepage",true);
String icon = ParamUtils.getParameter(request,"icon",true);
boolean nameVisible = ParamUtils.getBooleanParameter(request,"nameVisible");
boolean emailVisible = ParamUtils.getBooleanParameter(request,"emailVisible");
// Watch params
boolean autoAddEmailWatch = ParamUtils.getBooleanParameter(request,"autoAddEmailWatch");
boolean autoWatchNewTopics = ParamUtils.getBooleanParameter(request,"autoWatchNewTopics");
boolean autoWatchReplies = ParamUtils.getBooleanParameter(request,"autoWatchReplies");
// Try to load a user (try by userID first, then try username)
UserManager userManager = myEnv.getForumFactory().getUserManager();
User user = null;
try {
user = userManager.getUser(userID);
}
catch (UserNotFoundException unfe) {
try {
user = userManager.getUser(username);
}
catch (UserNotFoundException ignored) {}
}
// Get the default locale
Locale locale = JiveGlobals.getLocale();
// Setup the correct values for the referer
if ("取 消".equals(saveButton) && referer == null) {
referer = "index.jsp";
}
else if (referer == null) {
referer = request.getHeader("REFERER");
}
if ("取 消".equals(saveButton)) {
response.sendRedirect(referer);
return;
}
// Security check: make sure the user using this page is the same as the
// loaded user. If they're different, set user=null so the rest of the
// page will think that we're working with a guest user.
if ((user != null) && (pageUser != null) && (user.getID() != pageUser.getID())) {
user = null;
isGuest = true;
}
// save user settings
if (save) {
// Save user settings
if (user != null) {
// Save the thread range, message range and timezone
if (threadRange > -1) {
user.setProperty("jiveThreadRange",new Integer(threadRange).toString());
}
if (messageRange > -1) {
user.setProperty("jiveMessageRange",new Integer(messageRange).toString());
}
if (timeZoneID != null) {
user.setProperty("jiveTimeZoneID",timeZoneID);
}
//保存签名
if (signature != null) {
user.setProperty("jiveUserSignature",signature);
}
// Save all other user profile properties (for users only)
if (name != null) {
user.setName(name);
}
if (email != null) {
user.setEmail(email);
}
if (occupation != null && occupation.equals("")) {
user.deleteProperty("jiveOccupation");
} else if (occupation != null) {
user.setProperty("jiveOccupation",occupation);
}
if (location != null && location.equals("")) {
user.deleteProperty("jiveLocation");
} else if (location != null) {
user.setProperty("jiveLocation",location);
}
if (homepage != null && homepage.equals("")) {
user.deleteProperty("jiveHomepage");
} else if (homepage != null) {
user.setProperty("jiveHomepage",homepage);
}
if (icon != null && icon.equals("")) {
user.deleteProperty("jiveIcon");
} else if (icon != null) {
user.setProperty("jiveIcon",icon);
}
user.setNameVisible(nameVisible);
user.setEmailVisible(emailVisible);
// set watch settings
user.setProperty("jiveAutoAddEmailWatch", ""+autoAddEmailWatch);
user.setProperty("jiveAutoWatchNewTopics", ""+autoWatchNewTopics);
user.setProperty("jiveAutoWatchReplies", ""+autoWatchReplies);
}
// Save guest settings
else {
if (threadRange > -1) {
SkinUtils.store(request,response,"jiveThreadRange",
new Integer(threadRange).toString(),60*60*24*30);
}
if (messageRange > -1) {
SkinUtils.store(request,response,"jiveMessageRange",
new Integer(messageRange).toString(),60*60*24*30);
}
if (timeZoneID != null) {
SkinUtils.store(request,response,"jiveTimeZoneID",timeZoneID,60*60*24*30);
}
}
// Redirect to the appropriate page:
String redirectURL = null;
if (referer != null) {
redirectURL = "settings.jsp?referer=" + java.net.URLEncoder.encode(referer);
}
if ("保存/返回".equals(saveButton)) {
redirectURL = referer;
}
else if ("取 消".equals(saveButton) && referer == null) {
redirectURL = "index.jsp";
}
else if ("取 消".equals(saveButton) && referer != null) {
redirectURL = referer;
}
else {
if (user != null) {
redirectURL += "&user=" + user.getID();
}
}
response.sendRedirect(redirectURL);
return;
} // end save
%>
<% String title = "论坛 - 用户参数设置"; %>
<%@ include file="header.jsp" %>
<% // Getting to this point means there were no user settings to save, so
// we should load up settings from the user object or from the session
// (in the case of a guest)
// User settings
if (user != null) {
try {
threadRange = Integer.parseInt(user.getProperty("jiveThreadRange"));
} catch (Exception e) {}
try {
messageRange = Integer.parseInt(user.getProperty("jiveMessageRange"));
} catch (Exception e) {}
timeZoneID = user.getProperty("jiveTimeZoneID");
// load up other user profile properties
String nameProp = user.getName();
if (nameProp != null) {
name = nameProp;
}
String emailProp = user.getEmail();
if (emailProp != null) {
email = emailProp;
}
String occupationProp = user.getProperty("jiveOccupation");
if (occupationProp != null) {
occupation = occupationProp;
}
String locationProp = user.getProperty("jiveLocation");
if (locationProp != null) {
location = locationProp;
}
String homepageProp = user.getProperty("jiveHomepage");
if (homepageProp != null) {
homepage = homepageProp;
}
String iconProp = user.getProperty("jiveIcon");
if (iconProp != null) {
icon = iconProp;
}
nameVisible = user.isNameVisible();
emailVisible = user.isEmailVisible();
autoAddEmailWatch = "true".equals(user.getProperty("jiveAutoAddEmailWatch"));
autoWatchNewTopics = "true".equals(user.getProperty("jiveAutoWatchNewTopics"));
autoWatchReplies = "true".equals(user.getProperty("jiveAutoWatchReplies"));
}
// Guest settings
else if (isGuest) {
try {
threadRange = Integer.parseInt(
SkinUtils.retrieve(request,response,"jiveThreadRange").trim()
);
} catch (Exception e) {}
try {
messageRange = Integer.parseInt(
SkinUtils.retrieve(request,response,"jiveMessageRange").trim()
);
} catch (Exception e) {}
timeZoneID = SkinUtils.retrieve(request,response,"jiveTimeZoneID");
}
// one more check for the timezone -- if the code is null, that means no
// value was retrieved, so set it to the default:
if (timeZoneID == null) {
timeZoneID = JiveGlobals.getTimeZone().getID();
}
%>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td valign="top" width="99%">
<%-- Breadcrumbs --%>
<font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">
<b>
<a href="<%= JiveGlobals.getJiveProperty("skin.default.homeURL") %>"
>首页</a>
»
<a href="index.jsp" title="返回论坛列表"
>论坛</a>
»
您的设置
</b>
</font>
<p>
<font size="-1" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
修改您的显示参数方便您浏览论坛!
<% if (user != null) { %>
改变您的配置文件以设置您对别的用户可不可见,您也可以不设置任何参数。
<% } %>
</font>
</td>
<td valign="top" width="1%" align="center">
<%@ include file="loginbox.jsp" %>
</td>
</tr>
</table>
<p>
<script>
function MM_openBrWindow(theURL,features) { //v2.0
window.open(theURL,"upload",features);
}
</script>
<form action="settings.jsp" name="form1">
<input type="hidden" name="referer" value="<%= ((referer!=null)?referer:"") %>">
<input type="hidden" name="doSave" value="true">
<% if (user != null) { %>
<input type="hidden" name="user" value="<%= userID %>">
<% } %>
<table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>"
cellspacing="0" cellpadding="0" border="0" width="500" align="center">
<td>
<table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>"
cellspacing="1" cellpadding="3" border="0" width="100%">
<tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.prefsHeaderBgColor") %>">
<td>
<font class=p3 face="<%= JiveGlobals.getJiveProperty("skin.default.headerFontFace") %>"
color="<%= JiveGlobals.getJiveProperty("skin.default.prefsHeaderTextColor") %>">
<b>显示参数</b>
</font>
</td>
</tr>
<tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.prefsBgColor") %>">
<td align="center">
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td align="right" width="50%">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -