%@ page import="java.net.*, java.text.*, java.io.*, java.util.*, com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.util.*, com.artima.website.*" errorPage="../error.jsp" %> <%@ include file="../global.jincl" %> <% // Get parameters long forumID = forumFactory.getForum(ArtimaConstants.PAVILION_ANNOUNCEMENTS_FORUM).getID(); String weblogsForumID = Long.toString(forumID); long threadID = ParamUtils.getLongParameter(request,"thread",-1L); String subject = ParamUtils.getParameter(request,"subject"); String body = ParamUtils.getParameter(request,"body"); String summary = ParamUtils.getParameter(request,"summary"); boolean fromLogin = ParamUtils.getBooleanParameter(request, "fromLogin", false); boolean isNewPost = (threadID == -1L); if (fromLogin) { if (subject == null) { subject = (String) session.getAttribute("jive.post.subject." + forumID + "." + threadID); } if (summary == null) { summary = (String) session.getAttribute("jive.post.summary." + forumID + "." + threadID); } if (body == null) { body = (String) session.getAttribute("jive.post.body." + forumID + "." + threadID); } // TODO: Dang, got to deal with the topics here... } List topics = Topic.getTopicsForForum(forumID); // The topic checkboxes boolean[] topicChecked = new boolean[topics.size()]; int i = 0; for (Iterator it = topics.iterator(); it.hasNext();) { Topic topic = (Topic) it.next(); String topicHandle = topic.getHandle(); topicChecked[i] = ParamUtils.getBooleanParameter(request, topicHandle, false); ++i; } // Trim subject and body to catch ones that consist of only spaces. subject = StringCleaner.trimAndMakeNullIfEmpty(subject); summary = StringCleaner.trimAndMakeNullIfEmpty(summary); body = StringCleaner.trimAndMakeNullIfEmpty(body); String formButton = ParamUtils.getParameter(request,"formButton"); if (pageUser == null) { // Redirect to ../login.jsp. If the subject, summary, & body are not null, post those // in the session. if (subject != null) { session.setAttribute("jive.post.subject."+forumID+"."+threadID, subject); } if (summary != null) { session.setAttribute("jive.post.summary."+forumID+"."+threadID, summary); } if (body != null) { session.setAttribute("jive.post.body."+forumID+"."+threadID, body); } // Next construct the ../login.jsp referrer (the link it will redirect to) StringBuffer url = new StringBuffer("announce/editpost.jsp"); // Set to fromPreview to true because fromPreview is used to decide whether or not to // grab subject and body from session state when coming back to post.jsp // after loggin in. url.append("?fromLogin=").append(true); if (threadID != -1) { url.append("?thread=").append(threadID); } if (formButton != null) { url.append("?formButton=").append(formButton); } // Do the redirect String redirect = "../login.jsp?novelist=true&referrer=" + URLEncoder.encode(url.toString()); response.sendRedirect(redirect); return; } Group vendorGroup = Vendor.getVendorForUser(pageUser); if (vendorGroup == null) { %>
Sorry, you can't post an announcement unless your user account is approved by a vendor. <% return; } // Get Iterators of messages for each moderation type. Start with a result // filter to grab only pending threads/messages Forum forum = forumFactory.getForum(ArtimaConstants.PAVILION_ANNOUNCEMENTS_FORUM); ForumThread threadToEdit = null; User author = null; ForumMessage newMessage = null; ColorStyle colorStyle = ColorStyle.GRAY; String theTitle = "Edit an Announcement for " + vendorGroup.getDescription(); String theButton = "Post Changes"; if (isNewPost) { newMessage = forumFactory.createMessage(pageUser); colorStyle = ColorStyle.YELLOW; theTitle = "Add a New Announcement for " + vendorGroup.getDescription(); theButton = "Post as Draft"; } else { threadToEdit = forum.getThread(threadID); author = threadToEdit.getRootMessage().getUser(); newMessage = threadToEdit.getRootMessage(); if (threadToEdit.getModerationValue() == 0) { colorStyle = ColorStyle.YELLOW; theTitle = "Edit a Draft Announcement for " + vendorGroup.getDescription(); theButton = "Post Changes as Draft"; } } String bloggerNickname = pageUser.getUsername(); // Although this page has a cancel button, it doesn't // use the FromPage session variable. So leave FromPage as is, // so if they logout form here, they'll redirect back to wherever // they came from to get here. %>
Please take our Snappy Survey.
|
Artima Pavilion Announcements
<%= theTitle %> |
<%@ include file="../loginbox.jincl" %> |
Look's like your session expired. You'll have to log back in and try again, after which you will be redirected back here.
<% return; } else if (!isNewPost && (pageUser.getID() != author.getID()) && !pageUser.getUsername().equals("admin")) { %>Sorry, you can only edit your own announcements, not someone else's.
<% return; } boolean errors = false; String errorMessage = ""; if (subject == null) { errors = true; errorMessage = "Sorry, you can't post a blank subject. Type a subject and try again."; } else if (summary == null) { errors = true; errorMessage = "Sorry, you can't post a blank summary. Type a summary and try again."; } else if (summary != null && (summary.length() > ArtimaConstants.MAX_SUMMARY_LENGTH)) { errors = true; errorMessage = "Sorry, your summary is too long. Please shorten the summary and try again."; } else if (body == null) { errors = true; errorMessage = "Sorry, you can't post a blank message. Type a message and try again."; } if (errors) { %><%=errorMessage%> <% } else { newMessage.setSubject(subject); newMessage.setBody(body); String processedSummary = StringUtils.escapeHTMLTags(summary); newMessage.setProperty(ArtimaConstants.SUMMARY_PROPERTY, processedSummary); if (isNewPost) { newMessage.setProperty(ArtimaConstants.FIRST_DRAFT_PROPERTY, "true"); forum.addThread(forumFactory.createThread(newMessage)); } ForumThread thread = newMessage.getForumThread(); thread.setProperty(ArtimaConstants.VENDOR_PROPERTY, vendorGroup.getName()); // topic properties must be thread, not message, properties, so they // can be used in the thread results filter in index.jsp. i = 0; for (Iterator it = topics.iterator(); it.hasNext();) { Topic topic = (Topic) it.next(); String topicHandle = topic.getHandle(); if (topicChecked[i]) { thread.setProperty(ArtimaConstants.TOPIC_PROPERTY_PREFIX + topicHandle, "true"); } else { thread.deleteProperty(ArtimaConstants.TOPIC_PROPERTY_PREFIX + topicHandle); } ++i; } response.sendRedirect("ment.jsp?thread=" + thread.getID()); } } // Only let people edit their own posts if (pageUser == null) { %>
Look's like your session expired. You'll have to log back in and try again, after which you will be redirected back here.
<% return; } else if (!isNewPost && (pageUser.getID() != author.getID()) && !pageUser.getUsername().equals("admin")) { %>Sorry, you can only edit your own announcements, not someone else's.
<% return; } if (!isNewPost) { if (summary == null) { summary = newMessage.getProperty(ArtimaConstants.SUMMARY_PROPERTY); } if (subject == null) { subject = newMessage.getSubject(); } if (body == null) { body = newMessage.getUnfilteredBody(); } i = 0; for (Iterator it = topics.iterator(); it.hasNext();) { Topic topic = (Topic) it.next(); String topicHandle = topic.getHandle(); String prop = threadToEdit.getProperty(ArtimaConstants.TOPIC_PROPERTY_PREFIX + topicHandle); if (prop != null) { topicChecked[i] = true; } else { topicChecked[i] = false; } ++i; } } %>
|
|
|
|
Copyright © 1996-2003 Artima Software, Inc. All Rights Reserved.
|
Artima.com is created by Bill Venners
|