⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yazdstate.java

📁 Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   * Set the users currently selected message
   * as session state information
   */
  public final void setMessageID(int id)
  {
    messageID=id;
  }

  /**
   * Get the users currently selected message
   * from session state information
   *
   * @return messageID
   */
  public final int getMessageID()
  {
    return messageID;
  }

  /**
   * Under construction.
   */
  public final void setParentID(int id)
  {
    parentID=id;
  }

  /**
   * Under construction.
   */
  public final int getParentID()
  {
    return parentID;
  }

  /**
   * Set the Date of the users last visit to Yazd
   */
  public final void setLastVisit(Date d)
  {
    lastVisit = d;
  }

  /**
   * Get the Date of the users last visit to Yazd
   *
   * @return Date of users last Yazd visit
   */
  public final Date getLastVisit()
  {
    return lastVisit;
  }

  /**
   * Used by <b>forum</b> tag to set the Date of the users last visit to a forum.
   * This is saved as an extended user property when the
   * user logs out or the users session times out.  If the
   * users nextForumVisit setting is new, send a cookie.
   *
   * @param PageContext for request
   */
  public final void setNextForumVisitDate(PageContext pc, int forumid)
  {
    StringBuffer fid = new StringBuffer();
    fid.append(LAST_FORUM_VISIT + forumid);
    if( nextForumVisit.get(fid.toString()) == null ) {
      Date now = new Date();
      HttpServletRequest req = (HttpServletRequest)pc.getRequest();
      Cookie cookie = new Cookie(fid.toString(), "" + now.getTime());
      cookie.setPath(req.getContextPath());
      cookie.setMaxAge(COOKIE_EXPIRE);
      HttpServletResponse res = (HttpServletResponse)pc.getResponse();
      res.addCookie(cookie);
      nextForumVisit.put(fid.toString(), now);
    }
  }

  /**
   * Set the Date of the users last visit to a forum in the users
   * YazdState information.
   *
   * Used by <b>authorize</b> and <b>login</b> tag.
   *
   * @param String lastForumVisit property name
   * @param Date of last visit to forum
   */
  public final void setLastForumVisitDate(String prop, Date date)
  {
    lastForumVisit.put(prop,date);
  }

  /**
   * Used by <b>login</b> tag to reset the users lastForumVisit
   * based on their user extended properties.
   */
  public final void resetLastForumVisitDate(YazdRequest jr)
  {
    // Get the User data
    try {
      ProfileManager pm = jr.getProfileManager();
      User user = null;
      try {
        user = pm.getUser(getAuthorization().getUserID());
      } catch( UserNotFoundException ex ) {
      }
      if( user != null && !user.isAnonymous() ) {
        String tmp;
        String value;
	Date last;
	Enumeration enum = user.propertyNames();
	while( enum.hasMoreElements() ) {
	  tmp = (String)enum.nextElement();
	  if( tmp.startsWith(LAST_FORUM_VISIT) ) {
            value = user.getProperty(tmp);
	    if( value != null ) {
	      long last_time = Long.valueOf(value).longValue();
              last = new Date(last_time);
              lastForumVisit.put(tmp,last);
	    }
	  }
        }
      }
    } catch(JspException e) {}
  }

  /**
   * Used by forum tag to get the Date of the users last visit to a forum.
   *
   * @return Date of users last forum visit
   */
  public final Date getLastForumVisitDate(Forum cf, YazdRequest jr)
  {
    StringBuffer fid = new StringBuffer();
    fid.append(LAST_FORUM_VISIT + cf.getID());
    Date last = (Date)lastForumVisit.get(fid.toString());
    if( last == null ) {
      // If all else fails, use the forum creation date
      last = cf.getCreationDate();
    }
    return last;
  }

  /**
   * Set the Date of the users next lastVisit to the forum.
   * This is saved as an extended user property when the
   * user logs out or the users session times out.  If the
   * users nextVisit setting is new, send a cookie.
   *
   * Used by the <b>authorize</b> and <b>logout</b> tags.
   *
   * @param PageContext for request
   */
  public final void setNextVisit(PageContext pc)
  {
    if( nextVisit == null ) {
      nextVisit = new Date();
      HttpServletRequest req = (HttpServletRequest)pc.getRequest();
      Cookie cookie = new Cookie(LAST_VISIT,"" + nextVisit.getTime());
      cookie.setPath(req.getContextPath());
      cookie.setMaxAge(COOKIE_EXPIRE);
      HttpServletResponse res = (HttpServletResponse)pc.getResponse();
      res.addCookie(cookie);
    }
  }

  /**
   * Set the users login status flag.
   */
  public final void setLoggedIn(boolean l)
  {
    logged_in = l;
  }

  /**
   * Get the users login status flag.
   *
   * @return true if user is logged in, false if user is anonymous
   */
  public final boolean getLoggedIn()
  {
    return logged_in;
  }

  /**
   * Get the users current session messageDepth display preference.
   *
   * @return messageDepth
   */
  public final int getMessageDepth()
  {
    return message_depth;
  }

  /**
   * Set the users current session messageDepth display preference.
   */
  public final void setMessageDepth(int d)
  {
    message_depth = d;
  }

  /**
   * Get the users current session threadDepth display preference.
   *
   * @return threadDepth
   */
  public final int getThreadDepth()
  {
    if( thread_depth < message_depth )
      return message_depth;
    return thread_depth;
  }

  /**
   * Set the users current session threadDepth display preference.
   */
  public final void setThreadDepth(int d)
  {
    thread_depth = d;
  }

  /**
   * Get the users current session itemsPerPage display preference.
   *
   * @return itemsPerPage
   */
  public final int getItemsPerPage()
  {
    return items_per_page;
  }

  /**
   * Set the users current session itemsPerPage display preference.
   */
  public final void setItemsPerPage(int d)
  {
    items_per_page = d;
  }

  /**
   * Add an HREF to the message paging stack for a forum/thread.
   *
   */
  public final void addMessagePage(String currentPage, String nextPage)
  {
    String key = "" + forumID + "_" + threadID;
    Map map = (Map)prevMessages.get(key);
    if( map == null ) {
      map = new HashMap();
      prevMessages.put(key,map);
    }
    map.put(nextPage,currentPage);
  }

  /**
   * Get the HREF of a previous message page list.
   *
   * @return an HREF string
   */
  public final String getMessagePage(String currentPage)
  {
    String key = "" + forumID + "_" + threadID;
    Map map = (Map)prevMessages.get(key);
    if( map != null ) {
      String tmp = (String)map.get(currentPage);
      if( tmp != null )
        return tmp;
    }
    return "";
  }
}

⌨️ 快捷键说明

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