|
Jive Forums API (5.5.20.2-oracle) Developer Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jivesoftware.forum.util.SkinUtils
public class SkinUtils
A collection of utility methods for use in Jive Skins. Because these methods make skin development much easier, skin authors should study them carefully.
Five major areas of functionality are provided:
Method Summary | |
---|---|
static java.lang.String |
dateToText(javax.servlet.http.HttpServletRequest request,
User user,
java.util.Date date)
Returns an English sentence which describes the Date
parameter relative to the current time. |
static boolean |
emailResetPasswordInstructions(java.lang.String username,
javax.servlet.http.HttpServletRequest request)
This method will send the user specified an email with instructions on how to reset their password. |
static java.util.Iterator |
filterPendingMessages(java.util.Iterator messages)
Assumes index of iterator is at front of iterator (ie, iterator hasn't been used). |
static java.lang.String |
formatDate(javax.servlet.http.HttpServletRequest request,
User user,
java.util.Date date)
Formats a date for a user, according to their locale and time zone preferences. |
static java.lang.String |
getCommunityName()
Returns the name of the community or "Support Forums" (English only) as the default. |
static java.lang.String |
getCommunityName(java.lang.String i18nDefaultKey)
Returns the name of the community or the value of the given i18n key as the default. |
static java.lang.String |
getDisplayName(User user)
A simple method to check whether to display a user's full name or their username. |
static long |
getLastVisited(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns the Date the user last visited. |
static java.util.List |
getParentCategories(Forum forum)
Returns a list of parent categories for the given forum in top-down order. |
static java.lang.String |
getSkinProperty(Forum forum,
java.lang.String name)
Searches for the property name in the given forum. |
static java.lang.String |
getTheme()
Returns the current skin theme or the string "default" to denote the default theme. |
static boolean |
isNew(ForumCategory category,
java.util.Date time)
Returns true if the category has been modified since the specified time. |
static boolean |
isNew(Forum forum,
java.util.Date time)
Returns true if the forum has been modified since the specified time. |
static boolean |
isNew(ForumMessage message,
java.util.Date time)
Returns true if the forum message has been modified since the specified time. |
static boolean |
isNew(ForumThread thread,
java.util.Date time)
Returns true if the forum thread has been modified since the specified time. |
static boolean |
isSlimLayout()
Used to tell if we should user a slimmer layout |
static boolean |
isValidPasswordToken(long userId,
java.lang.String token)
Returns true is the supplied token is valid for the userId given. |
static java.lang.String |
quoteOriginal(java.lang.String body,
java.lang.String delimiter,
int lineLength)
Formats the unfiltered body of a message to make it appear in the "quote original" format. |
static boolean |
resetUserPassword(long userId,
java.lang.String token,
java.lang.String newPassword)
This method is used in conjunction with the emailResetPasswordInstructions method to reset a user's password. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String formatDate(javax.servlet.http.HttpServletRequest request, User user, java.util.Date date)
request
- the servlet request object.user
- the User that the date is being formatted for.date
- the Date object we're comparing the current time with.
public static java.lang.String quoteOriginal(java.lang.String body, java.lang.String delimiter, int lineLength)
This method uses message.getUnfilteredBody() in order to get the body of the message. This usually yields better results for the formatting required by this method. However, it also has the potential of being a security risk if malicious HTML code is embedded in the body. Therefore, you should always filter HTML from the result of this method before showing it in an environment where HTML is interpreted. If you are showing the results of this method in an HTML <textarea>, there is no need to worry about malicious HTML.
body
- the message body to quote.delimiter
- a String that will start each line of the quoted
message. For example, "> ";lineLength
- the desired length of each line in the quoted message.
public static boolean isNew(ForumCategory category, java.util.Date time)
category
- the category to check.time
- the time to reference the category against.
public static boolean isNew(Forum forum, java.util.Date time)
forum
- the forum to check.time
- the time to reference the forum against.
public static boolean isNew(ForumThread thread, java.util.Date time)
thread
- the thread to check.time
- the time to reference the thread against.
public static boolean isNew(ForumMessage message, java.util.Date time)
message
- the message to check.time
- the time to reference the message against.
public static java.util.List getParentCategories(Forum forum)
forum
- the forum to return parent categories.
public static java.lang.String getSkinProperty(Forum forum, java.lang.String name)
This is a useful method for skin writers if they want to apply per-forum or per-category level UI changes. For example, the property for the forum page background color is stored as the global property "skin.default.bgColor". To apply a forum-level background color, simply create an extended property of the forum named "skin.default.bgColor" and call this method when retrieving the property from the skin.
forum
- the Forum where we begin searching for the property. If the property is not
found in the forum, this forum's category is checked and failing that, then global property
list is checked. If this is null then this method simply calls
JiveGlobals.getJiveProperty(String)
.name
- the name of the property we're looking for.
public static long getLastVisited(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- the HttpServletRequest object, known as "request" on
a JSP page.response
- the HttpServletRequest object, known as "response" on
a JSP page.
public static java.util.Iterator filterPendingMessages(java.util.Iterator messages)
messages
-
public static boolean emailResetPasswordInstructions(java.lang.String username, javax.servlet.http.HttpServletRequest request) throws java.lang.IllegalArgumentException
If the user has already been sent a password reset email in the last 72 hours, the token will not be regenerated but will instead be reused in the instructional email. Conversely, if the user has been sent an email prior to the last 72 hours, the token will be regenerated and saved. In either case, no more than 1 email every 24 hours will be sent. Attempts to send more than 1 email per 24 hours will result in this method returning false.
You can insert the following tokens into the subject or body of the email message and they'll be dynamically replaced with the appropriate values when the email is sent: {userID}, {username}, {name}, {email}, {token}, {requestIP}, {host}, {port} and {webAppDir}.
The details of the email can be changed using the Jive admin skin, the default email is below:
{host} - Jive Forums reset password request.
We have received a request from {requestIP} to reset your password. If you have requested to reset your password, please follow the instructions below. If you do not wish to reset your password, please simply disregard this message.
To reset your Jive password at {host} you can either:
- Click the following url:
http://{host}:{port}{webAppDir}/resetPassword.jsp?userid={userID}&token={token}
- Goto http://{host}:{port}{webAppDir}/resetPassword.jsp and enter the following information into the fields provided:
UserID: {userID}
Token: {token}
username
- the usename of the user for whom we wish to send an email
with instructions on how to reset their passwordrequest
- the servlet request object
java.lang.IllegalArgumentException
- if either username or request is nullpublic static boolean isValidPasswordToken(long userId, java.lang.String token)
userId
- the id of the user for whom we are validating the password
reset token.token
- the password reset token associated with the above user.
public static boolean resetUserPassword(long userId, java.lang.String token, java.lang.String newPassword)
userId
- the id of the user for whom the password should be changed.token
- the password reset token associated with the above user.newPassword
- the password to use for the specified user.
public static java.lang.String dateToText(javax.servlet.http.HttpServletRequest request, User user, java.util.Date date)
Date
parameter relative to the current time. For instance, if the passed
in date was 39 seconds ago, this method returns:"Less than 1 min ago"
Similiarly, a date 1 ago would be:
"Yesterday at 3:53 PM"
The method obeys user preferences for time zone if they exist.
request
- the servlet request object.user
- the User that the date is being formatted for, or null
if an anonymmous user.date
- the Date object we're comparing the current time with.public static java.lang.String getDisplayName(User user)
user
- the user to return the display name for
public static java.lang.String getCommunityName()
The name of the community will prefix titles by default so it should be something short like "XYZ Support Forums" or "My Company Support".
public static java.lang.String getCommunityName(java.lang.String i18nDefaultKey)
i18nDefaultKey
- the i18n key to use as the default value for the community name.
public static java.lang.String getTheme()
public static boolean isSlimLayout()
|
Jive Forums Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |