📄 watches.jsp
字号:
<%/* * $RCSfile: watches.jsp,v $ * $Revision: 1.8 $ * $Date: 2002/06/10 14:42:46 $ */%><%@ page import="java.util.*, com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.util.*, java.net.URLEncoder"%><%@ include file="global.jsp" %><% // Get parameters long forumID = ParamUtils.getLongParameter(request,"forum",-1L); long threadID = ParamUtils.getLongParameter(request,"thread",-1L); int start = ParamUtils.getIntParameter(request,"start",0); int range = ParamUtils.getIntParameter(request,"range",10); int type = ParamUtils.getIntParameter(request,"type",WatchManager.NORMAL_WATCH); boolean add = ParamUtils.getBooleanParameter(request,"add"); boolean remove = ParamUtils.getBooleanParameter(request,"remove"); boolean deleteWatch = ParamUtils.getBooleanParameter(request,"deleteWatch"); boolean flat = ParamUtils.getBooleanParameter(request,"flat",true); boolean edit = ParamUtils.getBooleanParameter(request,"edit"); boolean save = ParamUtils.getBooleanParameter(request,"save"); boolean doExpire = ParamUtils.getBooleanParameter(request,"doExpire"); boolean expire = ParamUtils.getBooleanParameter(request,"expire"); String redirect = ParamUtils.getParameter(request,"redirect"); // thread IDs of threads we want to add email watches to String[] emailNotifyThreadIDs = request.getParameterValues("emailNotifyThreadID"); // thread IDs of threads we want to add email watches to (the previous value) String[] oldEmailNotifyThreadIDs = request.getParameterValues("oldEmailNotifyThreadID"); // thread IDs of the threads we want to remove all watches on String[] deleteWatchThreadIDs = request.getParameterValues("deleteWatchThreadID"); // thread IDs of the threads we want to make un-deletable String[] saveWatchThreadIDs = request.getParameterValues("saveWatchThreadID"); // Check if email watches are enabled. This value is checked when new // watches are added, but not when deleted. boolean emailWatchesEnabled = "true".equals(JiveGlobals.getJiveProperty("watches.emailNotifyEnabled")); // null checks if (emailNotifyThreadIDs == null) { emailNotifyThreadIDs = new String[0]; } if (oldEmailNotifyThreadIDs == null) { oldEmailNotifyThreadIDs = new String[0]; } if (deleteWatchThreadIDs == null) { deleteWatchThreadIDs = new String[0]; } if (saveWatchThreadIDs == null) { saveWatchThreadIDs = new String[0]; } // go back if requested if (request.getParameter("back") != null) { // Get the last page we visited (before this one) from the session: String lastPage = (String)session.getAttribute("jive.redirect"); if (lastPage == null) { // go back to the index page if the last page was not found: lastPage = "index.jsp"; } response.sendRedirect(lastPage); return; } // check to see if the user wants to automatically add an email notification boolean alwaysEmailNotify = false; try { alwaysEmailNotify = Boolean.valueOf( pageUser.getProperty("alwaysEmailNotify")).booleanValue(); } catch (Exception e) {} // status message to the user String message = (String)session.getAttribute("message"); if (message != null) { session.removeAttribute("message"); } // The forum we're interested in Forum forum = null; // Get the forum if (forumID > -1L) { forum = forumFactory.getForum(forumID); } // The watch manager lets us work with the watches WatchManager watchManager = forumFactory.getWatchManager(); // Get an iterator of watched threads for this user Iterator watchedThreads = null; if (forumID > -1L) { watchedThreads = watchManager.getWatchedForumThreads(forum, pageUser, WatchManager.NORMAL_WATCH); } else { watchedThreads = watchManager.getWatchedForumThreads(pageUser, WatchManager.NORMAL_WATCH); } // All forums Iterator forums = forumFactory.forums(); // total number of watches int watchCount = 0; if (forumID > -1L) { watchCount = watchManager.getWatchCount(forum, pageUser, WatchManager.NORMAL_WATCH); } else { watchCount = watchManager.getWatchCount(pageUser, WatchManager.NORMAL_WATCH); } boolean errors = false; String errorMessage = ""; if (add) { ForumThread thread = forum.getThread(threadID); watchManager.createWatch(pageUser, thread, type); if (type == WatchManager.NORMAL_WATCH) { if (alwaysEmailNotify && emailWatchesEnabled) { watchManager.createWatch(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH); } } if (redirect != null) { response.sendRedirect(redirect); } else { response.sendRedirect("thread.jsp?forum="+forumID+"&thread="+thread.getID()); } return; } else if (doExpire) { ForumThread thread = forum.getThread(threadID); watchManager.setWatchExpirable(pageUser, thread, type, expire); if (watchManager.isWatchedThread(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH)) { watchManager.setWatchExpirable(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH, expire); } if (redirect != null) { response.sendRedirect(redirect); } else { response.sendRedirect("thread.jsp?forum="+forumID+"&thread="+thread.getID()); } return; } else if (remove) { ForumThread thread = forum.getThread(threadID); watchManager.deleteWatch(pageUser, thread, type); if (type == WatchManager.NORMAL_WATCH) { if (watchManager.isWatchedThread(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH)) { watchManager.deleteWatch(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH); } } if (redirect != null) { response.sendRedirect(redirect); } else { response.sendRedirect("thread.jsp?forum="+forumID+"&thread="+thread.getID()); } return; } else if (deleteWatch) { for (int i=0; i<deleteWatchThreadIDs.length; i++) { forumID = ParamUtils.getLongParameter(request, "thread"+deleteWatchThreadIDs[i]+"forumID", -1L); forum = forumFactory.getForum(forumID); ForumThread thread = forum.getThread(Long.parseLong(deleteWatchThreadIDs[i])); watchManager.deleteWatch(pageUser, thread, WatchManager.NORMAL_WATCH); if (watchManager.isWatchedThread(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH)) { watchManager.deleteWatch(pageUser, thread, WatchManager.EMAIL_NOTIFY_WATCH); } } if (deleteWatchThreadIDs.length > 0) { // Get a watch manager watchManager = forumFactory.getWatchManager(); // Get an iterator of watched threads for this user watchedThreads = watchManager.getWatchedForumThreads(pageUser, WatchManager.NORMAL_WATCH); // total number of watches watchCount = watchManager.getWatchCount(pageUser, WatchManager.NORMAL_WATCH); } }%><% String title = SkinUtils.getLocalizedString("skin.default.watches.title",locale); %><%@ include file="header.jsp" %><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr> <td width="99%" valign="top"> <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>"> <b><%= SkinUtils.getLocalizedString("skin.default.global.your_watches",locale) %></b> </font> <br> <%-- Breadcrumbs --%> <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" 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> » <a href="index.jsp" title="<%= SkinUtils.getLocalizedString("skin.default.global.go_back_to_forum_list",locale) %>" ><%= SkinUtils.getLocalizedString("skin.default.global.forums",locale) %></a> » <a href="watches.jsp"><%= SkinUtils.getLocalizedString("skin.default.global.your_watches",locale) %></a> <% if (forumID != -1) { %> » <a href="forum.jsp?forum=<%= forumID %>"><%= forum.getName() %></a> <% } %> </b> </font> <p> <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>"> <%= SkinUtils.getLocalizedString("skin.default.watches.description",locale) %> </font> </td> <td valign="top" width="1%" align="center"> <%@ include file="loginbox.jsp" %> </td></tr></table><p><form action="watches.jsp">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -