📄 accounttag.java
字号:
// Harvest the input parameters for any required extended properties for( Iterator it=required.keySet().iterator(); it.hasNext(); ) { prop = (String)it.next(); if( (tmp = req.getParameter(prop)) != null && tmp.length() > 0 ) { required.put(prop,tmp); } else { required.put(prop,""); extended_required = false; } } // Harvest the input parameters for any optional extended properties for( Iterator it=properties.keySet().iterator(); it.hasNext(); ) { prop = (String)it.next(); if( (tmp = req.getParameter(prop)) != null ) { properties.put(prop,tmp); } } // Validate email address, error string comes from jive.tag.properties if( email == null || email.length() == 0 || !extended_required ) { jr.addError(TagPropertyManager.getTagProperty("jive.tag.account.required")); return EVAL_BODY_INCLUDE; } // Validate password confirmation if a password change is being made, // and confirm is true. Error string comes from jive.tag.properties if( password != null && password.length() > 0 ) { if( confirm_password && (confirm == null || !password.equals(confirm)) ) { password = null; confirm = null; jr.addError(TagPropertyManager.getTagProperty("jive.tag.account.confirm_password")); return EVAL_BODY_INCLUDE; } } try { // Save standard user data if changed if( password != null && password.length() > 0 ) { user.setPassword(password); if( properties.get("password") != null ) { ForumPermissions perms = jr.getForumFactory().getPermissions(js.getAuthorization()); if( !perms.get(ForumPermissions.SYSTEM_ADMIN) && !perms.get(ForumPermissions.FORUM_ADMIN) && !perms.get(ForumPermissions.GROUP_ADMIN) && !perms.get(ForumPermissions.USER_ADMIN) ) { user.setProperty( "password", (String)properties.get("password")); } } } if( name != null && name.length() > 0 ) { user.setName( name ); } if( nameVisible != null && nameVisible.length() > 0) { user.setNameVisible( true ); } else { user.setNameVisible( false ); } if( email != null && email.length() > 0 ) { user.setEmail( email ); } if( emailVisible != null && emailVisible.length() > 0 ) { user.setEmailVisible( true ); } else { user.setEmailVisible( false ); } // Save any extended user properties // thread_depth, message_depth, and items_per_page are special // extended properties used for display preferences for( Iterator it=properties.keySet().iterator(); it.hasNext(); ) { tmp = (String)it.next(); if( !tmp.equals("password") ) user.setProperty( tmp, (String)properties.get(tmp)); if( tmp.equals(JiveState.MESSAGE_DEPTH) ) js.setMessageDepth(Integer.valueOf((String)properties.get(tmp)).intValue()); if( tmp.equals(JiveState.THREAD_DEPTH) ) js.setThreadDepth(Integer.valueOf((String)properties.get(tmp)).intValue()); if( tmp.equals(JiveState.ITEMS_PER_PAGE) ) js.setItemsPerPage(Integer.valueOf((String)properties.get(tmp)).intValue()); } // Save any extended required user properties // thread_depth, message_depth, and items_per_page are special // extended properties used for display preferences for( Iterator it=required.keySet().iterator(); it.hasNext(); ) { tmp = (String)it.next(); if( !tmp.equals("password") ) user.setProperty( tmp, (String)required.get(tmp)); if( tmp.equals(JiveState.MESSAGE_DEPTH) ) js.setMessageDepth(Integer.valueOf((String)required.get(tmp)).intValue()); if( tmp.equals(JiveState.THREAD_DEPTH) ) js.setThreadDepth(Integer.valueOf((String)required.get(tmp)).intValue()); if( tmp.equals(JiveState.ITEMS_PER_PAGE) ) js.setItemsPerPage(Integer.valueOf((String)required.get(tmp)).intValue()); } } catch(UnauthorizedException e) { throw new JspException("Jive account tag, user with id " + user.getID() + " is not authorized to set user values."); } // All done, the body of the account tag can now redirect the // user some where else if needed. return EVAL_BODY_INCLUDE; } /** * Set a flag indicating that password changes should be confirmed * (Optional attribute). */ public final void setConfirm(String name) { if( name.equals("true") ) confirm_password = true; } // Get methods for standard user data which is made // availabe to JSP author via a script variable /** * User Email address property which can be obtained by the JSP page * using <jsp:getProperty name=<i>"id"</i> property="email"/> * * @return String - user email address */ public final String getEmail() { if( email == null ) return ""; return email; } /** * User Username (userid) property which can be obtained by the JSP page * using <jsp:getProperty name=<i>"id"</i> property="username"/> * * @return String - user username (forum userid) */ public final String getUsername() { if( username == null ) return ""; return username; } /** * Password entered in previous HTML form submisson which can be * obtained by the JSP page using * <jsp:getProperty name=<i>"id"</i> property="password"/> * * @return String - password the user entered in the HTML form submitted */ public final String getPassword() { if( password == null ) return ""; return password; } /** * Confirm Password entered in previous HTML form submisson which can be * obtained by the JSP page using * <jsp:getProperty name=<i>"id"</i> property="confirm"/> * * @return String - confirm password the user entered in the HTML form submitted */ public final String getConfirm() { if( confirm == null ) return ""; return confirm; } /** * User Name (real name) property which can be obtained by the JSP page * using <jsp:getProperty name=<i>"id"</i> property="name"/> * * @return String - user name (real name) */ public final String getName() { if( name == null ) return ""; return name; } /** * User NameVisible (real name) property which can be obtained by the * JSP Page using <jsp:getProperty name=<i>"id"</i> property="nameVisible"/> * * @return <b>checked</b> if user real name should be visible. */ public final String getNameVisible() { if( nameVisible != null ) return "checked"; return ""; } /** * User EmailVisible (email address) property which can be obtained by the * JSP Page using <jsp:getProperty name=<i>"id"</i> property="emailVisible"/> * * @return <b>checked</b> if user email address should be visible. */ public final String getEmailVisible() { if( emailVisible != null ) return "checked"; return ""; } /** * Method used by the getJiveProperty tag to get an extended User * property from the account tag script variable. * * @return String - value of the property */ public final String getProperty(String name) { String tmp = (String)properties.get(name); if( tmp != null ) return tmp; tmp = (String)required.get(name); if( tmp != null ) return tmp; return ""; } /** * Method used by the setJiveProperty tag to set an extended User * property from the account tag script variable. */ public final void setProperty(String name, String value) { user.setProperty(name,value); if( properties.containsKey(name) ) properties.put(name,value); else if( required.containsKey(name) ) properties.put(name,value); } /** * Method used to determine if user is a member of a jive Group. * * @return true if a member, false if not a member */ public final boolean isMember(String name) throws JspException { // Get the group data ProfileManager pm = jr.getProfileManager(); try { Group group = pm.getGroup(name); return group.isMember(user); } catch( GroupNotFoundException ex ) { } return false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -