settings.jsp

来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· JSP 代码 · 共 649 行 · 第 1/2 页

JSP
649
字号
<%/** *	$RCSfile: settings.jsp,v $ *	$Revision: 1.11 $ *	$Date: 2002/07/19 20:42:30 $ */%><%@ page import="java.net.*,                 java.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*"    errorPage="error.jsp"%><%@ include file="global.jsp" %><%  // Put the request URI and query string in the session as an attribute.    // This is done so the error.jsp and auth.jsp pages can figure out what    // page sent it an error and redirect appropriately.    setRedirectURL(request);%><%  // Same deal for timezones - the SkinUtils class keeps an internal array    // of the timezoens:    String[][] timeZones = SkinUtils.getTimeZoneList();    Locale[] locales = Locale.getAvailableLocales();    Arrays.sort(locales, new Comparator() {        public int compare(Object o1, Object o2) {            Locale loc1 = (Locale)o1;            Locale loc2 = (Locale)o2;            return loc1.getDisplayName().compareTo(loc2.getDisplayName());        }    });    // Parameters    long userID = ParamUtils.getLongParameter(request,"user",-1L);    String username = ParamUtils.getParameter(request,"user");	String referrer = ParamUtils.getParameter(request,"referrer");	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);	boolean nameVisible = ParamUtils.getBooleanParameter(request,"nameVisible");	boolean emailVisible = ParamUtils.getBooleanParameter(request,"emailVisible");    boolean updated = ParamUtils.getBooleanParameter(request,"updated");    // Watch params    boolean autoAddEmailWatch = ParamUtils.getBooleanParameter(request,"autoAddEmailWatch");    boolean autoWatchNewTopics = ParamUtils.getBooleanParameter(request,"autoWatchNewTopics");    boolean autoWatchReplies = ParamUtils.getBooleanParameter(request,"autoWatchReplies");    String skinCancel = SkinUtils.getLocalizedString("skin.default.global.cancel",locale);    String skinSaveReturn = SkinUtils.getLocalizedString("skin.default.settings.save_return",locale);    // Try to load a user (try by userID first, then try username)    UserManager userManager = forumFactory.getUserManager();    User user = null;    try {        user = userManager.getUser(userID);    }    catch (UserNotFoundException unfe) {        try {            user = userManager.getUser(username);        }        catch (UserNotFoundException ignored) {}    }	// Setup the correct values for the referrer	if (skinCancel.equals(saveButton) && referrer == null) {		referrer = "index.jsp";	}	else if (referrer == null) {		referrer = request.getHeader("REFERER");	}    if (skinCancel.equals(saveButton)) {        response.sendRedirect(referrer);        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 (localeCode != null                    && ("true".equals(JiveGlobals.getJiveProperty("skin.default.usersChooseLocale"))))            {                Locale tempLocale = SkinUtils.localeCodeToLocale(localeCode);                if (tempLocale == null) {                    // Remove their locale in this case so the default                    // Jive locale will be used                    user.deleteProperty("jiveLocale");                }                else {                    user.setProperty("jiveLocale", localeCode);                }            }			// 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);			}			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.setCookie(response,"jiveThreadRange",                    new Integer(threadRange).toString());			}			if (messageRange > -1) {                SkinUtils.setCookie(response,"jiveMessageRange",                    new Integer(messageRange).toString());			}			if (timeZoneID != null) {                SkinUtils.setCookie(response,"jiveTimeZoneID",timeZoneID);			}            if (localeCode != null                    && ("true".equals(JiveGlobals.getJiveProperty("skin.default.usersChooseLocale"))))            {                Locale tempLocale = SkinUtils.localeCodeToLocale(localeCode);                if (tempLocale == null) {                    SkinUtils.deleteCookie(response, SkinUtils.getCookie(request, "jiveLocale"));                }                else {                    SkinUtils.setCookie(response, "jiveLocale", localeCode);                }            }		}		// Redirect to the appropriate page:		String redirectURL = "settings.jsp?";		if (referrer != null) {            redirectURL += "referrer=" + URLEncoder.encode(referrer);		}		if (skinSaveReturn.equals(saveButton)) {			redirectURL = referrer;		}		else if (skinCancel.equals(saveButton) && referrer == null) {			redirectURL = "index.jsp";		}		else if (skinCancel.equals(saveButton) && referrer != null) {			redirectURL = referrer;		}		else { // just a normal save			if (user != null) {				redirectURL += "&user=" + user.getID() + "&updated=true";			}		}        response.sendRedirect(redirectURL);        return;	} // end save%><%  String title = SkinUtils.getLocalizedString("skin.default.settings.title",locale); %><%@ 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;		}		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.getCookie(request,"jiveThreadRange").getValue().trim());		} catch (Exception e) {}		try {            messageRange = Integer.parseInt(                    SkinUtils.getCookie(request,"jiveMessageRange").getValue().trim());		} catch (Exception e) {}        try {            timeZoneID = SkinUtils.getCookie(request,"jiveTimeZoneID").getValue().trim();        } catch (Exception e) {}	}	// 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") %>"     ><%= SkinUtils.getLocalizedString("skin.default.global.home",locale) %></a>    &raquo;    <a href="index.jsp" title="<%= SkinUtils.getLocalizedString("skin.default.global.go_back_to_forum_list",locale) %>"     ><%= SkinUtils.getLocalizedString("skin.default.global.forums",locale) %></a>    &raquo;    <%= SkinUtils.getLocalizedString("skin.default.settings.your_settings",locale) %>    </b>    </font>    <p>    <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"     face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%= SkinUtils.getLocalizedString("skin.default.settings.description1",locale) %>    <% if (user != null) { %>        <%= SkinUtils.getLocalizedString("skin.default.settings.description2",locale) %>    <%  } %>    </font>    </td>    <td valign="top" width="1%" align="center">    <%@ include file="loginbox.jsp" %>    </td></tr></table><p><%  if (updated) { %>    <table cellpadding="0" cellspacing="0" border="0" width="500" align="center">    <tr><td>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <i><%= SkinUtils.getLocalizedString("skin.default.settings.updated",locale) %></i>        </font>    </td></tr>    </table><%  } %><form action="settings.jsp" method="post"><%  if (referrer != null) { %><input type="hidden" name="referrer" value="<%= referrer %>"><%  } %><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%">

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?