[jboss-svn-commits] JBL Code SVN: r9564 - in labs/jbossforums/branches/forums22/forums/src: main/org/jboss/portlet/forums/helper and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Feb 16 18:24:01 EST 2007
Author: unibrew
Date: 2007-02-16 18:24:01 -0500 (Fri, 16 Feb 2007)
New Revision: 9564
Removed:
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/Context.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/action/
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/commands/
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentToken.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/ForumsTools.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Goto.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/GotoWithOffset.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/IndexIterator.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Range.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Time.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/interceptors/
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/servlet/
Modified:
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
labs/jbossforums/branches/forums22/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml
Log:
[JBFORUMS-161] I deleted all unused anymore classes where many of them are GPL. I also had to do small modifications in the rest of code.
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/Context.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/Context.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/Context.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,906 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portlet.forums.action.*;
-import org.jboss.portlet.forums.commands.post.*;
-import org.jboss.portlet.forums.impl.*;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.UploadedFile;
-import org.jboss.portlet.forums.helper.TempFileBinding;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.portlet.PortletFileUpload;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-
-import javax.portlet.PortletPreferences;
-import javax.servlet.http.HttpSessionBindingListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1415 $
- */
-public class Context
-{
- // Request parameters
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_submit;
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_confirm;
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_preview;
-
- /**
- * Scope : NewTopic/EditPost/Reply
- * When it's true that means the button add attachment is pressed.
- */
- public boolean p_attach;
-
- /**
- * Scope : NewTopic/EditPost/Reply
- * When it's true the user choosed to see the add attachment panel.
- */
- public boolean p_attach_box;
-
- /**
- * Scope : editing a post.
- * When it's true the user choosed to see the posted attachment.
- */
- public boolean p_posted_attach;
-
- /**
- * DOCUMENT_ME
- */
- public int p_mode;
-
- /**
- * DOCUMENT_ME
- */
- public int p_forum_id;
-
- /**
- * DOCUMENT_ME
- */
- public int p_topic_id;
-
- /**
- * DOCUMENT_ME
- */
- public int p_post_id;
-
- /**
- * DOCUMENT_ME
- */
- public int p_post_parent_topic_id;
-
- /**
- * DOCUMENT_ME
- */
- public int p_topic_type;
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_cancel;
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_notify;
-
- /**
- * DOCUMENT_ME
- */
- public int p_vote_option_id;
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_poll_delete;
-
- /**
- * DOCUMENT_ME
- */
- public boolean p_topic_first_post = false;
-
- /**
- * DOCUMENT_ME
- */
- public Poll p_poll;
-
- /**
- * DOCUMENT_ME
- */
- public Message p_message;
-
- /**
- * DOCUMENT_ME
- */
- public Poster p_poster;
-
- /**
- * DOCUMENT_ME
- */
- public List p_deleted_attachments = new ArrayList();
-
- /**
- * DOCUMENT_ME
- */
- public List p_session_attachments = new ArrayList();
-
- public Map p_updated_attachments = new HashMap();
-
- /**
- * DOCUMENT_ME
- */
- boolean c_refresh;
-
- /**
- * DOCUMENT_ME
- */
- private ForumsModule forumsModule;
-
- private Map files = new HashMap();
-
- /**
- * Creates a new {@link Context} object.
- */
- public Context()
- {
- //forumsModule = new ForumsModuleImpl();
-
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param req DOCUMENT_ME
- * @param resp DOCUMENT_ME
- */
- public void update(JBossActionRequest req,
- JBossActionResponse resp)
- {
-
-
- //So because posting form is probably multipart at the beggining we must parse form fields
- try
- {
- files = new HashMap();
- DiskFileItemFactory factory = new DiskFileItemFactory();
- PortletFileUpload upload = new PortletFileUpload(factory);
- upload.setHeaderEncoding("UTF-8");
-
- //if posting() was called with action link it won't be multipart
- if ((req.getContentType() != null) && req.getContentType().startsWith("multipart/form-data"))
- {
-
- // Merge with upload fields
- for (Iterator i = upload.parseRequest(req).iterator(); i.hasNext();)
- {
- FileItem item = (FileItem)i.next();
- if (item.isFormField())
- {
- //if it's form field just add it to request params map
- //TODO:Be aware that this adds single value as we won't have multiply values in new topic form for now...
- try
- {
- req.getParameterMap().put(item.getFieldName(), new String[]{item.getString("UTF-8")});
- }
- catch (Exception e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- else
- {
- if (item.getSize() != 0)
- {
- files.put(item.getName(), new UploadedFileImpl(item.getContentType(), item.get(), item.getName(), item.getSize()));
-
- }
- }
- }
- }
- }
- catch (FileUploadException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- //TODO:Some nice error message
- }
- //if we started editing post, already stored attachs in sessions should be cleaned.
- if (req.getParameters().get("editPostInit", "none").equals("true"))
- {
- //clear stored files from session
- req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, null);
- }
- //Uncoment for debug purposes:
- /*System.out.println("@@@@@@@@@@@@@@@@@@@@@@");
- System.out.println("in Context.update(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
- for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- System.out.println("param key: " + key + " ||param val[1/" + req.getParameterValues(key).length + "]: " + req.getParameter(key));
- }
- System.out.println("Parsed file names in request:");
- for (Iterator i = files.keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- System.out.println(" -- filename: " + key);
- }*/
- //DEBUG code
- /*AttachmentsManager tflf = (AttachmentsManager)req.getPortletSession().getAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS);
- if (!(tflf == null))
- {
- System.out.println("Already stored files");
- for (Iterator i = tflf.getFiles().iterator(); i.hasNext();)
- {
- TempFileBinding tfb = (TempFileBinding)i.next();
- System.out.println("+++" + tfb.getFileName() + "<==>" + tfb.getFilePath());
- }
- }*/
-
- //System.out.println("Doing Context.update()");
- PortletPreferences pp = req.getPreferences();
- p_mode = ForumsConstants.ModeDecoder.decodePosting(req.getParameter("mode"));
- //System.out.println("Decoded mode: "+ req.getParameter("mode"));
- p_forum_id = req.getParameters().getInt(ForumsConstants.POST_FORUM_URL, -1);
- //System.out.println("Decoded forum id: "+ p_forum_id);
- p_topic_id = req.getParameters().getInt(ForumsConstants.POST_TOPIC_URL, -1);
- //System.out.println("Decoded topic id: " +p_topic_id);
- p_post_id = req.getParameters().getInt(ForumsConstants.POST_POST_URL, -1);
- //System.out.println("Decoded post id: " +p_post_id);
- p_topic_type = req.getParameters().getInt("topictype", ForumsConstants.POST_NORMAL);
- /*p_notify = req.getParameters().getParameterExists("notify");*/
- p_notify = pp.getValue("notifyreply", "1").equals("1");
- p_vote_option_id = req.getParameters().getInt("vote_id", -1);
-
- p_message = new MessageImpl();
- p_message.setSubject(req.getParameters().get("subject", ""));
- p_message.setText(req.getParameters().get("message", ""));
-
- /*if (pp.getValue("attachsig","0").equals("1")){
- p_message.setText(req.getParameters().get("message", "")+ '\n' + pp.getValue("signature",""));
- } else {
- p_message.setText(req.getParameters().get("message", ""));
- }*/
- //p_message.setHTMLEnabled(!req.getParameters().getParameterExists("disable_html"));
- //p_message.setHTMLEnabled(pp.getValue("allowhtml","1").equals("1"));
- p_message.setBBCodeEnabled(!req.getParameters().getParameterExists("disable_bbcode"));
- /*p_message.setBBCodeEnabled(pp.getValue("allowbbcode","1").equals("1"));*/
- p_message.setSmiliesEnabled(!req.getParameters().getParameterExists("disable_smilies"));
- /*p_message.setSignatureEnabled(req.getParameters().getParameterExists("attach_sig"));*/
- p_message.setSignatureEnabled(pp.getValue("attachsig", "1").equals("1"));
-
- String sessionId = req.getPortletSession().getId();
-
- /**
- * So... attachments are stored in AttachmentsManager as String path to disk temp file. Manager
- * is stored in session so when session is broken it will remove files from disk.
- * When NewTopic view is created for the first time AttachmentManager is removed from session
- * to deal with clean attachments state. When EditPost link is clicked removal of Manager from session
- * is done some lines above
- */
-
- //persisting attachments to disk
- int filescount = 0;
- AttachmentsManager attachmentsManager = (AttachmentsManager)req.getPortletSession().getAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS);
- //if there is no Manager object in session create one
- if (attachmentsManager == null)
- {
- attachmentsManager = new AttachmentsManager();
- req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, attachmentsManager);
- }
- //add newly uploaded files to Manager
- for (Iterator i = files.keySet().iterator(); i.hasNext(); filescount++)
- {
- String fileName = (String)i.next();
- UploadedFile uf = (UploadedFile)files.get(fileName);
- try
- {
- TempFileBinding tfb = new TempFileBinding(uf.getContentType(),
- uf.getByteContent(),
- uf.getName(),
- sessionId.toString() + "_" + getNextFileIndex(req));
- tfb.setComment(req.getParameters().get("filecomment", ""));
- attachmentsManager.addBinding(tfb);
- }
- catch (Exception e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- //TODO:Some nice error message
- }
- }
- //p_session_attachments = attachmentsManager.getFiles();
-
- //
- String userId = req.getUser().getId().toString();
- try
- {
- p_poster = getForumsModule().findPosterByUserId(userId);
- }
- catch (ModuleException e)
- {
- //TODO:Some nice error message
- e.printStackTrace();
- }
-
- if (p_post_id != -1)
- {
- try
- {
- Integer tid = getForumsModule().findPostById(new Integer(p_post_id)).getTopic().getId();
- p_post_parent_topic_id = tid.intValue();
- Integer fpid = getForumsModule().findTopicById(tid).getFirstPost().getId();
- p_topic_first_post = p_post_id == fpid.intValue();
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
-
- if (p_poster == null)
- {
- p_poster = new PosterImpl(userId);
- }
-
- //
- p_poll = new PollImpl();
- p_poll.setTitle(req.getParameters().get("poll_title", ""));
- p_poll.setLength(Math.max(req.getParameters().getInt("poll_length", 0),
- 0));
- p_poll.setOptions(new LinkedList());
-
- String p_add_poll_option_text = req.getParameter("add_poll_option_text");
- boolean p_poll_add = req.getParameters().getParameterExists("add_poll_option");
- boolean p_poll_edit = req.getParameters().getParameterExists("edit_poll_option");
-
- boolean option_deleted = false;
- for (int index = 0; true; index++)
- {
- String param = "poll_option_text[" + index + "]";
- String value = req.getParameter(param);
- boolean deleted = req.getParameter("del_poll_option[" + index + "]") != null;
- option_deleted |= deleted;
- if ((value != null))
- {
- if (!deleted)
- {
- /*p_poll.getOptions().add(deleted ? null : value);*/
- //p_poll.getOptions().add(value);
-
- p_poll.getOptions().add(new PollOptionImpl(value));
- }
- }
- else
- {
- break;
- }
- }
-
- if (p_poll_add)
- {
- //p_poll.getOptions().add(p_add_poll_option_text);
- p_poll.getOptions().add(new PollOptionImpl(p_add_poll_option_text));
- }
-
- // if (p_poll_add && p_add_poll_option_text != null)
- // {
- // // htmlspecialchars(trim(stripslashes(
- // p_poll_option_text.add(p_add_poll_option_text);
- // }
- boolean toggle_attach_box = req.getParameters().getParameterExists("add_attachment_box");
- boolean toggle_posted_attachments = req.getParameters().getParameterExists("posted_attachments");
-
- p_poll_delete = req.getParameters().getParameterExists("poll_delete");
- p_cancel = req.getParameters().getParameterExists("cancel");
- p_submit = req.getParameters().getParameterExists("post");
- p_confirm = req.getParameters().getParameterExists("confirm");
- p_preview = req.getParameters().getParameterExists("preview");
- p_attach_box = toggle_attach_box | req.getParameters().getParameterExists("add_attachment_box_flag");
- p_posted_attach = toggle_posted_attachments ^ req.getParameters().getParameterExists("posted_attachments_flag");
- p_attach = req.getParameters().getParameterExists("add_attachment");
-
- // Handle Delete/update attachments buttons
- boolean session_attachment_deleted = false;
- //search thru params for update/delete command
- for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
- {
- String parameter = (String)i.next();
- if (parameter.startsWith("del_attachment["))
- {
- //attach id can be for attachment in DB or file in AttachmentsManager
- boolean isStored = parameter.startsWith("del_attachment[stored_attach_");
- int from = (isStored ? "del_attachment[stored_attach_" : "del_attachment[").length();
-
- int to = parameter.length() - 1;
- String s = parameter.substring(from, to);
- //int index = Integer.parseInt(s);
- //if it's for attachment in DB just remember it's ID to remove it during executin proper command
- if (isStored)
- {
- int index = Integer.parseInt(s);
- attachmentsManager.getDeletedAttachments().add(new Integer(index));
- }
- //if it's previosly uploaded file just remove binding from Manager
- else
- {
- attachmentsManager.removeBinding(s);
- }
- session_attachment_deleted = true;
- break;
- }
- //check if this is update button
- if (parameter.startsWith("update_attachment["))
- {
- boolean isStored = parameter.startsWith("update_attachment[stored_attach_");
- int from = (isStored ? "update_attachment[stored_attach_" : "update_attachment[").length();
- int to = parameter.length() - 1;
- String s = parameter.substring(from, to);
- //int index = Integer.parseInt(s);
- //if this is attachment in DB remember it's index and new comment
- if (isStored)
- {
- int index = Integer.parseInt(s);
- String newComment = req.getParameters().get("attach_comment[stored_attach_" + s + "]", "");
- attachmentsManager.getUpdatedAttachments().put(new Integer(index), newComment);
- }
- //if this is previously uploaded file update comment in binding in Manager
- else
- {
- attachmentsManager.updateBindingComment(s, req.getParameters().get("attach_comment[" + s + "]", ""));
- }
- session_attachment_deleted = true;
- break;
- }
- }
- //[List]newly uploaded files
- p_session_attachments = attachmentsManager.getFiles();
- //[List]indexes of attachments that should be removed from DB
- p_deleted_attachments = attachmentsManager.getDeletedAttachments();
- //[Map]indexes of attachments and new comments that should be updated in DB
- p_updated_attachments = attachmentsManager.getUpdatedAttachments();
-
- // Are we refreshing the page ?
- boolean c_refresh = p_preview;
- c_refresh |= p_poll_delete;
- c_refresh |= p_poll_add;
- c_refresh |= p_poll_edit;
- c_refresh |= p_attach;
- c_refresh |= option_deleted;
-
- // c_refresh |= session_attachment_deleted;
- c_refresh |= toggle_attach_box;
- c_refresh |= toggle_posted_attachments;
-
- this.c_refresh = c_refresh;
-
- // Clean up the attachments if necessary
- /*if (((p_mode == ForumsConstants.PMODE_EDIT_POST) || (p_mode == ForumsConstants.PMODE_NEW_TOPIC)
- || (p_mode == ForumsConstants.PMODE_REPLY))
- && (c_refresh || p_submit))
- {
- //
- }
- else
- {
- //p_deleted_attachments.clear();
- //p_session_attachments.clear();
-
- }*/
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param req DOCUMENT_ME
- * @param resp DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public Action action(JBossActionRequest req,
- JBossActionResponse resp)
- {
- //System.out.println("Doing Context.action()");
- Action action = null;
- switch (p_mode)
- {
-
- case ForumsConstants.PMODE_VOTE:
- {
- VoteTopicCommand vtc = new VoteTopicCommand(req, resp);
- vtc.setPoster(p_poster);
- vtc.topicId = p_topic_id;
- vtc.forumId = p_forum_id;
- vtc.voteOptionId = p_vote_option_id;
- action = new ProcessCommandAction(vtc);
- break;
- }
- case ForumsConstants.PMODE_REPLY:
- {
- if (c_refresh)
- {
- ReplyAction rra = new ReplyAction(p_post_id, p_message, p_poster, p_session_attachments);
- rra.setModule(getForumsModule());
- action = rra;
- }
- else if (p_submit)
- {
- ReplyCommand rc = new ReplyCommand(req, resp);
- rc.setPoster(p_poster);
- rc.postId = p_post_id;
- PortletPreferences pp = req.getPreferences();
- /*if (pp.getValue("attachsig","0").equals("1")){
- String tmp = p_message.getText();
- p_message.setText(tmp + "\n\n" + pp.getValue("signature",""));
- }*/
- List attachments = new LinkedList();
- for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
- {
- attachments.add(((TempFileBinding)i.next()).produceAttachment());
- }
- rc.attachments = attachments;
- rc.message = p_message;
- rc.current_time = new Date();
- rc.setModule(getForumsModule());
- // rc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
- action = new ProcessCommandAction(rc);
- }
- else
- {
- ReplyAction rra = new ReplyAction(false, p_post_id, p_message, p_poster);
- rra.setModule(getForumsModule());
- action = rra;
- }
-
- break;
- }
-
- case ForumsConstants.PMODE_QUOTE:
- {
- ReplyAction rra = new ReplyAction(true, p_post_id, p_message, p_poster);
- rra.setModule(getForumsModule());
- action = rra;
- break;
- }
-
- case ForumsConstants.PMODE_EDIT_POST:
- {
- if (c_refresh)
- {
- EditPostAction epa =
- new EditPostAction(p_message, p_poster, p_post_id, p_session_attachments, p_poll);
- epa.setModule(getForumsModule());
- action = epa;
- }
- else if (p_submit)
- {
- EditPostCommand epc = new EditPostCommand(req, resp);
- epc.setPoster(p_poster);
- epc.postId = p_post_id;
- PortletPreferences pp = req.getPreferences();
- /*if (pp.getValue("attachsig","0").equals("1")){
- String tmp = p_message.getText();
- p_message.setText(tmp + "\n\n");
- }*/
- epc.message = p_message;
- p_poll.setCreationDate(new Date());
- if (req.hasPermission("EditPollInPost"))
- {
- epc.poll = p_poll;
- }
-
- // epc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
-
-
- List attachments = new LinkedList();
- for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
- {
- attachments.add(((TempFileBinding)i.next()).produceAttachment());
- }
- epc.attachments = attachments;
-
- epc.topic_type = p_topic_type;
- epc.current_time = new Date();
- epc.poll_delete = p_poll_delete;
- epc.notify = p_notify;
- /*epc.deletedAttachments =
- (Integer[])p_deleted_attachments.toArray(new Integer[p_deleted_attachments.size()]);*/
- epc.deletedAttachments = p_deleted_attachments;
-
- epc.updatedAttachments = p_updated_attachments;
- action = new ProcessCommandAction(epc);
- }
- else
- {
- EditPostAction epa =
- new EditPostAction(p_message, p_poster, p_post_id, p_session_attachments, p_poll);
- epa.setModule(getForumsModule());
- action = epa;
- }
-
- break;
- }
-
- case ForumsConstants.PMODE_DELETE:
- {
- DeletePostCommand dpc = new DeletePostCommand(req, resp);
- dpc.setPoster(p_poster);
- dpc.postId = p_post_id;
- dpc.setModule(getForumsModule());
- action = new ProcessCommandAction(dpc);
- break;
- }
-
- case ForumsConstants.PMODE_POLL_DELETE:
- {
- DeletePollCommand dpc = new DeletePollCommand(req, resp);
- dpc.setPoster(p_poster);
- dpc.postId = p_post_id;
- action = new ProcessCommandAction(dpc);
- break;
- }
-
- case ForumsConstants.PMODE_NEW_TOPIC:
- {
- if (c_refresh)
- {
-
- NewTopicAction nta =
- new NewTopicAction(p_poster, p_message, p_forum_id, p_session_attachments, p_poll);
- nta.setModule(getForumsModule());
- action = nta;
- }
- else if (p_submit)
- {
- NewTopicCommand ntc = new NewTopicCommand(req, resp);
- ntc.setPoster(p_poster);
- ntc.forumId = p_forum_id;
-
- /*ntc.message = p_message;*/
-
- PortletPreferences pp = req.getPreferences();
- /*if (pp.getValue("attachsig","0").equals("1")){
- String tmp = p_message.getText();
- p_message.setText(tmp + "\n\n" + pp.getValue("signature",""));
- }*/
- List attachments = new LinkedList();
- for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
- {
- attachments.add(((TempFileBinding)i.next()).produceAttachment());
- }
- ntc.attachments = attachments;
-
- ntc.message = p_message;
- p_poll.setCreationDate(new Date());
- ntc.poll = p_poll;
- // ntc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
- ntc.topic_type = p_topic_type;
- ntc.current_time = new Date();
- ntc.notify = p_notify;
- ntc.setModule(getForumsModule());
- action = new ProcessCommandAction(ntc);
- }
- else
- {
- NewTopicAction nta = new NewTopicAction(p_forum_id);
- nta.setModule(getForumsModule());
- action = nta;
- }
-
- break;
- }
-
-
- case ForumsConstants.PMODE_REPOST:
- {
- RepostCommand rc = new RepostCommand(req, resp);
- rc.setPoster(p_poster);
- rc.postId = p_post_id;
- action = new ProcessCommandAction(rc);
- break;
- }
- }
-
- return action;
- }
-
- public ForumsModule getForumsModule()
- {
- return forumsModule;
- }
-
- public void setForumsModule(ForumsModule forumsModule)
- {
- this.forumsModule = forumsModule;
- }
-
-
- /**
- * Object that stores binding to uploaded and stored as Temp Files attachments. Object is stored in
- * session and implements HttpSessionBindingListener so when session is invalidated it removes stored
- * files from disk
- */
- private class AttachmentsManager implements HttpSessionBindingListener
- {
- //uploaded and stored to disk attachments bindings.
- private List files;
- //indexes of attachments that should be deleted from DB
- private List deletedAttachments;
- //indexes of attachments in DB that should have updated comment + new comment value
- private Map updatedAttachments;
-
- AttachmentsManager()
- {
- files = new LinkedList();
- setDeletedAttachments(new LinkedList());
- setUpdatedAttachments(new HashMap());
-
-
- }
-
- /**
- * Simply adds new TempFileBinding
- *
- * @param tmp
- */
- public void addBinding(TempFileBinding tmp)
- {
- files.add(tmp);
- }
-
- /**
- * Removes Binding of id such as in argument
- *
- * @param id
- */
- public void removeBinding(String id)
- {
- for (Iterator i = files.iterator(); i.hasNext();)
- {
- TempFileBinding tfb = (TempFileBinding)i.next();
- if (tfb.getFileId().equals(id))
- {
- tfb.delete();
- files.remove(tfb);
- break;
- }
- }
- }
-
- /**
- * Updates comment for attachment
- *
- * @param id
- * @param comment
- */
- public void updateBindingComment(String id, String comment)
- {
- for (Iterator i = files.iterator(); i.hasNext();)
- {
- TempFileBinding tfb = (TempFileBinding)i.next();
- if (tfb.getFileId().equals(id))
- {
- tfb.setComment(comment);
- break;
- }
- }
- }
-
- public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent)
- {
- }
-
- /**
- * If object removed from session we do clean up and removes every file stored to disk
- *
- * @param httpSessionBindingEvent
- */
- public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent)
- {
- for (Iterator i = files.iterator(); i.hasNext();)
- {
- TempFileBinding tmpb = (TempFileBinding)i.next();
- tmpb.delete();
- }
- }
-
- public List getFiles()
- {
- return files;
- }
-
- public void setFiles(List files)
- {
- this.files = files;
- }
-
- /**
- * Stores indexes of persisted attachments which should be deleted
- *
- * @return
- */
- public List getDeletedAttachments()
- {
- return deletedAttachments;
- }
-
- public void setDeletedAttachments(List deletedAttachments)
- {
- this.deletedAttachments = deletedAttachments;
- }
-
- /**
- * Stores indexes of persisted attachments and their new comments.
- *
- * @return
- */
- public Map getUpdatedAttachments()
- {
- return updatedAttachments;
- }
-
- public void setUpdatedAttachments(Map updatedAttachments)
- {
- this.updatedAttachments = updatedAttachments;
- }
- }
-
- /**
- * provides session unique integer value
- *
- * @param req
- * @return
- */
- int getNextFileIndex(JBossActionRequest req)
- {
- Integer index = (Integer)req.getPortletSession().getAttribute(ForumsConstants.FILE_SESSION_INDEX);
- if (index == null)
- {
- index = new Integer(0);
- req.getPortletSession().setAttribute(ForumsConstants.FILE_SESSION_INDEX, index);
- }
- else
- {
- int i = index.intValue();
- index = new Integer(i + 1);
- req.getPortletSession().setAttribute(ForumsConstants.FILE_SESSION_INDEX, index);
-
- }
- return index.intValue();
- }
-}
-
-
Modified: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -15,8 +15,6 @@
import org.jboss.portal.core.model.User;
import org.jboss.portal.core.modules.ModuleException;
import org.jboss.portal.core.hibernate.HibernateProvider;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
import org.jboss.portlet.forums.model.*;
import org.jboss.portlet.command.ActionCommand;
@@ -589,14 +587,6 @@
* @param watch
*/
void removeWatch(Watch watch) throws ModuleException;
-
- /**
- *
- * @param cmd
- * @return
- * @throws CommandException
- */
- Result invoke(ActionCommand cmd) throws CommandException;
/**
*
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,6817 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums;
-
-
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.result.ResultType;
-import org.jboss.portal.common.context.DelegateContext;
-import org.jboss.portal.common.util.ProxyInfo;
-import org.jboss.portal.core.CoreConstants;
-import org.jboss.portal.core.aspects.server.UserInterceptor;
-import org.jboss.portal.core.model.PropertyMap;
-import org.jboss.portal.core.model.User;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.core.servlet.jsp.PortalJsp;
-import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig;
-import org.jboss.portal.format.render.bbcodehtml.ToHTMLRenderer;
-import org.jboss.portal.format.util.CLLoader;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portlet.JBossPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-import org.jboss.portlet.forums.action.Action;
-import org.jboss.portlet.forums.action.EditPostAction;
-import org.jboss.portlet.forums.action.ForumAction;
-import org.jboss.portlet.forums.action.NewTopicAction;
-import org.jboss.portlet.forums.action.PostAction;
-import org.jboss.portlet.forums.action.ProcessCommandAction;
-import org.jboss.portlet.forums.action.ReplyAction;
-import org.jboss.portlet.forums.action.TopicAction;
-import org.jboss.portlet.forums.commands.CommandConstants;
-import org.jboss.portlet.forums.commands.admin.CreateCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.CreateForumCommand;
-import org.jboss.portlet.forums.commands.admin.DeleteForumCommand;
-import org.jboss.portlet.forums.commands.admin.DeleteMoveCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.DeleteMoveForumCommand;
-import org.jboss.portlet.forums.commands.admin.OrderCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.OrderForumCommand;
-import org.jboss.portlet.forums.commands.admin.UpdateCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.UpdateForumCommand;
-import org.jboss.portlet.forums.commands.moderation.DeleteTopicCommand;
-import org.jboss.portlet.forums.commands.moderation.LockTopicCommand;
-import org.jboss.portlet.forums.commands.moderation.MoveTopicCommand;
-import org.jboss.portlet.forums.commands.moderation.SplitTopicCommand;
-import org.jboss.portlet.forums.commands.post.DeletePostCommand;
-import org.jboss.portlet.forums.commands.post.EditPostCommand;
-import org.jboss.portlet.forums.commands.post.ForumCommand;
-import org.jboss.portlet.forums.commands.post.NewTopicCommand;
-import org.jboss.portlet.forums.commands.post.ReplyCommand;
-import org.jboss.portlet.forums.helper.ForumsTools;
-import org.jboss.portlet.forums.helper.Goto;
-import org.jboss.portlet.forums.helper.GotoWithOffset;
-import org.jboss.portlet.forums.helper.IndexIterator;
-import org.jboss.portlet.forums.helper.FileBinding;
-import org.jboss.portlet.forums.helper.AttachmentTokenManager;
-import org.jboss.portlet.forums.helper.AttachmentToken;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.ForumWatch;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.PollOption;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.TopicWatch;
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portlet.forums.properties.TCCLXProperties;
-import org.jboss.portlet.forums.theme.FolderType;
-import org.jboss.portlet.forums.theme.ForumsTheme;
-import org.jboss.util.collection.CompoundIterator;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.PortletURL;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-import javax.portlet.PortletSession;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.Enumeration;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 2171 $
- */
-public class ForumsPortlet
- extends JBossPortlet
- implements ForumsConstants
-{
- // private ForumsModule forumsModule;
-
- private final String OP_MAIN = "main";
-
- public static final String OP_SHOWFORUM = "showForum";
-
- private final String OP_POSTING = "showPosting";
-
- public final static String OP_SHOWTOPIC = "showTopic";
-
- public static final String OP_SHOWADMINFORUMS = "showAdminForums";
-
- public static final String OP_SHOWMODERATEFORUM = "showModerateForum";
-
- public static final String OP_SHOWMOVETOPIC = "showMoveTopic";
-
- public static final String OP_SHOWODELETETOPIC = "showDeleteTopic";
-
- public static final String OP_SHOWSPLITTOPIC = "showSplitTopic";
-
- public static final String OP_SHOWUSERPROFILE = "showUserProfile";
-
- private final String OP_SHOWADDEDITFORUM = "showAddEditForum";
-
- private final String OP_SHOWEDITCATEGORY = "showEditCategory";
-
- private final String OP_SHOWDELETEFORUM = "showDeleteForum";
-
- private final String OP_CONFIRM = "showConfirm";
-
- private final String OP_SHOWWATCHEDTOPICS = "showWatchedTopics";
-
- private final String OP_SHOWWATCHEDFORUMS = "showWatchedForums";
-
- private ForumsTheme theme;
-
- private ProxyInfo proxyInfo;
-
- private CLLoader loader;
-
- private ForumsModule forumsModule;
-
- /**
- * Initialization method of the portlet
- *
- * @throws PortletException DOCUMENT_ME
- */
- public void init() throws PortletException
- {
- super.init();
-
- try
- {
- forumsModule = (ForumsModule)new InitialContext().lookup("java:portal/ForumsModule");
- getPortletContext().setAttribute("forumsModule", forumsModule);
- }
- catch (NamingException e)
- {
- throw new PortletException(e);
- }
-
- /*
- try
- {
- userModule = (UserModule) new InitialContext()
- .lookup(ModuleConstants.USERMODULE_JNDINAME);
- roleModule = (RoleModule) new InitialContext()
- .lookup(ModuleConstants.ROLEMODULE_JNDINAME);
- }
- catch (NamingException e)
- {
- throw new PortletException(e);
- }
- */
- // Start the theme
- theme = new ForumsTheme();
- try
- {
- // start theme
- theme.setExtendedProperties(new TCCLXProperties(ForumsConstants.THEMENAME, "theme.properties"));
- theme.start();
- }
- catch (IOException e)
- {
- throw new PortletException("Cannot start the forums theme, can't read template files", e);
- }
- catch (Exception e)
- {
- throw new PortletException("Cannot start the forums theme", e);
- }
-
- // Preferences proxy
- /*
- Class proxyClass = Proxy.getProxyClass(Thread.currentThread().getContextClassLoader(), new Class[]{PreferencesProxy.class});
- try
- {
- proxyInfo = new ProxyInfo(proxyClass);
- }
- catch (Exception e1)
- {
- throw new PortletException();
- }
- */
-
- // Loader that will load the resource from the war file
- loader = new CLLoader("template");
- }
-
- public String getDefaultOperation()
- {
- return OP_MAIN;
- }
-
- /**
- * doEdit Portlet method
- *
- * @param req Portlet render request
- * @param resp Portlet response request
- * @throws PortletException For any unexpected exception
- * @throws IOException If cannot write HTML chunk
- */
- protected void doEdit(JBossRenderRequest req, JBossRenderResponse resp)
- throws PortletException, IOException
- {
-
- ResourceBundle bundle = getResourceBundle(req.getLocale());
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.write("<div class=\"bb\">");
- if (req.getWindowState() != WindowState.MAXIMIZED)
- {
- writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
- writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
- PortletURL showProfileURL = resp.createRenderURL();
- showProfileURL.setWindowState(WindowState.MAXIMIZED);
- showProfileURL.setPortletMode(PortletMode.EDIT);
- writer.write("<a href=\"" + showProfileURL.toString() + "\">"
- + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums.gif" + "\"><br>"
- + bundle.getString("Preferences_edit") + "</a>");
- writer.write("</td></tr></table>");
- }
- else
- {
- DelegateContext root = new DelegateContext();
- if (!(req.getRemoteUser() != null))
- {
- writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
- writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
- writer.write("Sorry but you must login to change preferences");
- writer.write("</td></tr></table>");
- writer.write("</div>");
- writer.close();
- return;
- }
- else
- {
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowPreferencesContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/preferences_body.jsp");
- rd.include(req, resp);
- }
- }
- writer.write("</div>");
- writer.close();
- }
-
- /**
- * doView Portlet method
- *
- * @param req Portlet render request
- * @param resp Portlet response request
- * @throws PortletException For any unexpected exception
- * @throws IOException If cannot write HTML chunk
- */
- protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
- throws PortletException, IOException
- {
- //Use this to do debug
- /*System.out.println("#####################");
- System.out.println("in doView(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
- for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- System.out.println("param key: " + key + " ||param val: " + req.getParameter(key));
- }*/
-
-
-
-
-
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.write("<div class=\"bb\">");
- String op = req.getParameters().get(getOperationName(),
- getDefaultOperation());
- if (req.getWindowState() != WindowState.MAXIMIZED)
- {
- DelegateContext root = new DelegateContext();
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowBlockTopicsContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/block/topics.jsp");
- rd.include(req, resp);
-
- /*writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
-
- // Window is is normal mode
- // Check if the user is an administrator
- boolean isAdmin = hasPermission(req,"Admin");
- if (isAdmin)
- {
- writer.write("<td width=\"50%\" align=\"center\" class=\"portlet-menu-item\">");
-
- // Create a link to the administration interface
- PortletURL adminURL = resp.createRenderURL();
- adminURL.setParameter("op", "" + OP_SHOWADMINFORUMS);
- adminURL.setWindowState(WindowState.MAXIMIZED);
- writer.write("<a href=\"" + adminURL.toString() + "\">"
- + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums_admin.gif\"><br>"
- + bundle.getString("Admin_panel") + "</a>");
- writer.write("</td>");
- writer.write("<td width=\"50%\" align=\"center\" class=\"portlet-menu-item\">");
- }
- else
- {
- writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
- }
-
- //Create a link to the forum index
- PortletURL showForumsURL = resp.createRenderURL();
- showForumsURL.setWindowState(WindowState.MAXIMIZED);
- showForumsURL.setParameter("op", "" + OP_MAIN);
- writer.write("<a href=\"" + showForumsURL.toString() + "\">"
- + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums.gif" + "\"><br>"
- + bundle.getString("Main_index") + "</a>");
- writer.write("</td></tr></table>");*/
-
-
- }
- else
- {
- DelegateContext logged_in = null;
- DelegateContext root = new DelegateContext();
- if ((req.getRemoteUser() != null))
- {
- logged_in = root.next("switch_user_logged_in");
- }
- boolean isAdmin = ForumsTools.hasPermission(req, "Admin");
- if (isAdmin && (req.getRemoteUser() != null))
- {
- // Create a link to the administration interface
- PortletURL adminURL = resp.createRenderURL();
- adminURL.setParameter("op", "" + OP_SHOWADMINFORUMS);
- String adminLink = new String("<a id=\"adminPanel\" class=\"mainmenu\" href=\"" + adminURL.toString() + "\">"
- + "<img src=\"" + req.getContextPath() + "/subSilver/images/icon_mini_admin.gif\"\n" +
- " width=\"12\" height=\"13\" border=\"0\"\n" +
- " hspace=\"3\"/>"
- + bundle.getString("Admin_panel") + "</a><br/>");
- logged_in.put("ADMIN_PANEL_LINK", adminLink);
- }
-
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- PortletRequestDispatcher rdisp = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/small_header.jsp");
- rdisp.include(req, resp);
-
- if (OP_MAIN.equals(op))
- {
- // Forum index
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowIndexContext(req,
- resp, root));
-
-
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/index_body.jsp");
- rd.include(req, resp);
- }
- else if (OP_SHOWFORUM.equals(op))
- {
- // Display topics of a forums
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowForumContext(req,
- resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/viewforum_body.jsp");
- rd.include(req, resp);
- }
- else if (OP_POSTING.equals(op))
- {
- // Display new post form
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowNewTopicContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/posting_body.jsp");
- rd.include(req, resp);
- }
- else if (OP_SHOWTOPIC.equals(op))
- {
- // Display a topic
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowTopicContext(req,
- resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/viewtopic_body.jsp");
- rd.include(req, resp);
- }
- else if (OP_SHOWADMINFORUMS.equals(op))
- {
- // Display administration interface
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "Admin");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST,
- fillShowAdminForumsContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_admin_body.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_SHOWMODERATEFORUM.equals(op))
- {
- // Display administration interface
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST,
- fillShowModerateForumContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_body.jsp");
- rd.include(req, resp);
- }
- }
-
- else if (OP_SHOWUSERPROFILE.equals(op))
- {
- // Display administration interface
- resp.setTitle("Forums");
- if ((req.getRemoteUser() != null))
- {
- req.setAttribute(PortalJsp.CTX_REQUEST,
- fillShowUserProfileContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/profile_view_body.jsp");
- rd.include(req, resp);
- }
- }
-
- else if (OP_SHOWMOVETOPIC.equals(op))
- {
- // Display administration interface
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
- if (auth)
- {
- /*req.setAttribute(PortalJsp.CTX_REQUEST,
- fillShowModerateForumContext(req, resp, root));*/
- PortletURL forumGotoURL = resp.createActionURL();
- forumGotoURL.setParameter(getOperationName(), OP_SHOWFORUM);
- forumGotoURL.setParameter("f", "" + req.getParameters().get("U_INDEX_f", "-1"));
- root.put("U_INDEX", forumGotoURL.toString());
- root.put("L_INDEX", req.getParameters().get("L_INDEX", ""));
- root.put("S_HIDDEN_FIELDS", req.getParameters().get("S_HIDDEN_FIELDS", ""));
- root.put("S_FORUM_SELECT", req.getParameters().get("S_FORUM_SELECT", ""));
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_move.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_SHOWSPLITTOPIC.equals(op))
- {
- // Display administration interface
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST,
- fillShowSplitTopicContext(req, resp, root));
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_split.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_SHOWADDEDITFORUM.equals(op))
- {
- // Display new or edit a forum form
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "Admin");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST,
- fillShowAddEditForumContext(req, resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_edit_body.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_SHOWDELETEFORUM.equals(op))
- {
- // Show form to delete an exisiting forum
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "Admin");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- root.put("NAME", req.getParameter("NAME"));
- root.put("S_SELECT_TO", req.getParameter("S_SELECT_TO"));
- root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
- PortletURL postURL = resp.createActionURL();
- root.put("POST_URL", postURL.toString());
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_delete_body.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_SHOWEDITCATEGORY.equals(op))
- {
- // Show form to edit or create a category
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "Admin");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- root.put("CAT_TITLE", req.getParameter("CAT_TITLE"));
- root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
- PortletURL postURL = resp.createActionURL();
- root.put("POST_URL", postURL.toString());
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/category_edit_body.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_CONFIRM.equals(op))
- {
- // Show form to edit or create a category
- resp.setTitle("Forums");
- boolean auth = ForumsTools.hasPermission(req, "Delete");
- if (auth)
- {
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- root.put("MESSAGE_TITLE", req.getParameter("MESSAGE_TITLE"));
- root.put("MESSAGE_TEXT", req.getParameter("MESSAGE_TEXT"));
- root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
- PortletURL postURL = resp.createActionURL();
- root.put("POST_URL", postURL.toString());
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/confirm_body.jsp");
- rd.include(req, resp);
- }
- }
- else if (OP_SHOWWATCHEDFORUMS.equals(op))
- {
- resp.setTitle("Forums");
- req.setAttribute(PortalJsp.CTX_REQUEST, fillShowWatchedForums(req,
- resp, root));
- PortletRequestDispatcher rd = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/watched_forums_body.jsp");
- rd.include(req, resp);
- }
-
- /*NAVIGATION JUMP BOX*/
- String selectTo = "";
- selectTo = "<select name=\"nav_id\">"
- + "<option value=\"main\">" + "All categories view" + "</option>\n";
- selectTo += ForumsTools.listForumsCategories(forumsModule);
- selectTo += "</select>";
-
- PortletURL navigationActionURL = resp.createActionURL();
- navigationActionURL.setParameter("op", "navigation");
- root.put("S_JUMPBOX_ACTION", navigationActionURL.toString());
- root.put("S_JUMPBOX_SELECT", selectTo);
- req.setAttribute(PortalJsp.CTX_REQUEST, root);
- PortletRequestDispatcher rdispend = getPortletContext()
- .getRequestDispatcher("/WEB-INF/subSilver/jsp/jumpbox.jsp");
- rdispend.include(req, resp);
- }
-
-
- writer.write("</div>");
- writer.close();
- }
-
- public void navigation(JBossActionRequest request, JBossActionResponse response)
- throws CommandException
- {
- //Use this to do debug
- /*System.out.println("!@!@!@!@!@!@!@!@!@!@!@!@");
- System.out.println("in navigation(); op: " + request.getParameter("op") + " and mode: " + request.getParameter("mode"));
- for (Iterator i=request.getParameterMap().keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- System.out.println("param key: " + key + " ||param val: " + request.getParameter(key));
- }*/
- String nav = "main";
- nav = request.getParameter("nav_id");
- response.setRenderParameter(getOperationName(), OP_MAIN);
- if (nav.equals("main"))
- {
- return;
- }
- else
- {
- String toGo[] = nav.split("x");
- if (toGo.length == 2)
- {
- response.setRenderParameter(toGo[0], toGo[1]);
- if (toGo[0].equals("f"))
- {
- response.setRenderParameter(getOperationName(), OP_SHOWFORUM);
- }
- }
-
- }
-
-
- }
-
- /**
- * Method do action processing for Moderator functions from moderator panel
- * in forum view and moderator bar in topic view.
- * <p/>
- * This method <b>MUST</b> get both proper "f" (forum id) and "t" (topic id) params.
- *
- * @param request
- * @param response
- * @throws CommandException
- */
- public void moderate_forum(JBossActionRequest request, JBossActionResponse response)
- throws CommandException
- {
- //Use this to do debug
- /*System.out.println("!@!@!@!@!@!@!@!@!@!@!@!@");
- System.out.println("in moderate_forum(); op: " + request.getParameter("op") + " and mode: " + request.getParameter("mode"));
- for (Iterator i=request.getParameterMap().keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- System.out.println("param key: " + key + " ||param val: " + request.getParameter(key));
- }*/
-
- ResourceBundle bundle = getResourceBundle(request.getLocale());
-
- //get all parameters passed
- Map paramMap = request.getParameterMap();
-
- //is this return from confirmation page?
- boolean confirmed = paramMap.containsKey("comfirmPage");
-
- //if no button was pressed let's jump to main view
- if (paramMap.containsKey("cancel"))
- {
- response.setRenderParameter(getOperationName(), getDefaultOperation());
- return;
- }
- //if its confirmed and it's not cancel button then it should be yes button
-
- //type of action
- String mode = request.getParameters().get("mode", "");
-
- //forum id:
- int fid = Integer.parseInt(request.getParameters().get("f", "-1"));
- int tid = Integer.parseInt(request.getParameters().get("t", "-1"));
-
- //get forum from fid
- Forum forum = null;
- try
- {
- //if (fid != -1)
- //{
- forum = forumsModule.findForumById(new Integer(fid));
- //}
- }
- catch (ModuleException e)
- {
-
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- //if no forum then goto main
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
-
- //Initial perrmisions check
- String[] testArray = new String[]{forum.getCategory().getTitle(), forum.getName()};
- boolean authMod = ForumsTools.hasPermission(request, testArray, "ModerateForum");
- if (!authMod)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_PERMISSION_VIOLATION");
- return;
- }
-
- //if not specified jump to OP_MAIN at end
- response.setRenderParameter(getOperationName(), OP_MAIN);
-
- //let decode which button was pressed in moderator panel
- //or what command is confirmed
- if (paramMap.containsKey("delete"))
- {
-
- mode = "delete";
- }
- else if (paramMap.containsKey("move"))
- {
-
- mode = "move";
- }
- else if (paramMap.containsKey("lock"))
- {
-
- mode = "lock";
- }
- else if (paramMap.containsKey("unlock"))
- {
-
- mode = "unlock";
- }
- else if (paramMap.containsKey("split"))
- {
-
- mode = "split";
- }
-
- //list of passed topic number
- List topicsPassedList = new LinkedList();
-
- //we need to know how many topics could be passed in topic_id_list[N]= pattern
- int topicsPerPage = Integer.parseInt(request.getPreferences().getValue("topicsperforum", "10"));
-
- //let's get all passed topics
- for (int i = 0; i <= topicsPerPage; i++)
- {
- String pattern = "topic_id_list[" + i + "]";
- String topicNum = request.getParameters().get(pattern, "none");
-
- if (!topicNum.equals("none"))
- {
-
- topicsPassedList.add(new Integer(topicNum));
- }
- }
- //plus the one from "t" param
- if (tid != -1)
- {
- topicsPassedList.add(new Integer(tid));
- }
-
- //process delete button
- if (mode.equals("delete"))
- {
-
- //show confirmation page in doView()
- response.setRenderParameter(getOperationName(), OP_CONFIRM);
- //action url for the confirmation form
-
- StringBuffer hiddenFields = new StringBuffer();
- hiddenFields.append("<input type=\"hidden\" name=\"deleteConfirm\" value=\"yes\"/>").
- append("<input type=\"hidden\" name=\"op\" value=\"moderate_forum\"/>").
- append("<input type=\"hidden\" name=\"f\" value=\"" + fid + "\"/>");
- int i = 0;
- //we must passed all topics number in response
- for (Iterator itp = topicsPassedList.iterator(); itp.hasNext(); i++)
- {
- hiddenFields.append("<input type=\"hidden\" name=\"topic_id_list[" + i + "]" + "\" value=\"" + ((Integer)itp.next()).toString() + "\"/>");
- }
- response.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields.toString());
- response.setRenderParameter("MESSAGE_TITLE", bundle.getString("Topic_delete_confirm"));
- response.setRenderParameter("MESSAGE_TEXT", bundle.getString("Topic_delete_message"));
- return;
- }
- // proces deletion confirmation
- else if (paramMap.containsKey("deleteConfirm"))
- {
-
-
- DeleteTopicCommand cmd = new DeleteTopicCommand(request, response);
- cmd.topicIds = topicsPassedList;
- cmd.module = forumsModule;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_CANNOT_REMOVE_TOPICS)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_CANNOT_REMOVE_TOPIC");
- return;
- }
- else if (type == CommandConstants.TYPE_TOPICS_REMOVED)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- response.setRenderParameter("f", "" + fid);
- addSuccessMessage(response, "moderate", "SUCC_TOPIC_REMOVED");
- return;
- }
- return;
- }
- // process move button
- else if (mode.equals("move"))
- {
-
- /*response.setRenderParameter(getOperationName(), OP_SHOWMOVETOPIC);
- //url for navigation link - show our forum
- PortletURL forumGotoURL = response.createActionURL();
- forumGotoURL.setParameter(getOperationName(), OP_SHOWFORUM);
- forumGotoURL.setParameter("f", "" + fid);
- //<a href=...
- response
- response.setRenderParameter("U_INDEX", forumGotoURL.toString());*/
- //>forum name</a>
- //ass render urls should be created from RenderResponse we pass it to doView
- response.setRenderParameter("U_INDEX_f", "" + fid);
- response.setRenderParameter("L_INDEX", forum.getName());
-
- //hidden fields
- StringBuffer hiddenFields = new StringBuffer();
- hiddenFields.append("<input type=\"hidden\" name=\"moveConfirm\" value=\"yes\"/>").
- append("<input type=\"hidden\" name=\"op\" value=\"moderate_forum\"/>").
- append("<input type=\"hidden\" name=\"f\" value=\"" + fid + "\" />");
- int i = 0;
- //we must passed all topics number in response
- for (Iterator itp = topicsPassedList.iterator(); itp.hasNext(); i++)
- {
- hiddenFields.append("<input type=\"hidden\" name=\"topic_id_list[" + i + "]" + "\" value=\"" + ((Integer)itp.next()).toString() + "\"/>");
- }
- response.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields.toString());
-
-
- try
- {
- String selectTo = new StringBuffer().
- append("<select name=\"forum_to_id\">").
- append("<option value=\"-1\"").
- append(" selected=\"selected\">").
- append("Select destination forum").append("</option>\n").
- append(ForumsTools.listForums(forumsModule.findForums(), -1)).
- append("</select>").toString();
- response.setRenderParameter("S_FORUM_SELECT", selectTo);
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
- return;
-
- }
-
- //process move confirmation
- else if (paramMap.containsKey("moveConfirm"))
- {
-
- int toForumId = request.getParameters().getInt("forum_to_id", -1);
- if (toForumId == -1)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_NO_DEST_FORUM");
- return;
- }
-
- MoveTopicCommand cmd = new MoveTopicCommand(request, response);
- cmd.topicIds = topicsPassedList;
- cmd.module = forumsModule;
- cmd.destinationForumId = new Integer(toForumId);
-
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
- else if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
- else if (type == CommandConstants.TYPE_TOPIC_MOVED)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- response.setRenderParameter("f", "" + fid);
- addSuccessMessage(response, "moderate", "SUCC_TOPIC_MOVED");
- return;
- }
- return;
- }
-
- //process lock button
- else if (mode.equals("lock"))
- {
-
- LockTopicCommand cmd = new LockTopicCommand(request, response);
- cmd.topicIds = topicsPassedList;
- cmd.module = forumsModule;
-
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
- else if (type == CommandConstants.TYPE_TOPIC_LOCKED)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- response.setRenderParameter("f", "" + fid);
- addSuccessMessage(response, "moderate", "SUCC_TOPIC_LOCKED");
- return;
- }
- return;
-
-
- }
- //process unlock button
- else if (mode.equals("unlock"))
- {
-
- LockTopicCommand cmd = new LockTopicCommand(request, response);
- cmd.topicIds = topicsPassedList;
- cmd.module = forumsModule;
- cmd.unlockAction = true;
-
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
- else if (type == CommandConstants.TYPE_TOPIC_UNLOCKED)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- response.setRenderParameter("f", "" + fid);
- addSuccessMessage(response, "moderate", "SUCC_TOPIC_UNLOCKED");
-
- return;
- }
- return;
- }
- //process split button
- else if (mode.equals("split"))
- {
-
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- return;
- }
- //process split all button
- else if (paramMap.containsKey("split_type_all"))
- {
-
-
- Topic topic = null;
- try
- {
- topic = forumsModule.findTopicById(new Integer(tid));
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
- return;
- }
- if (topic.getPosts().size() == 1)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- //response.setRenderParameter("t","" + tid);
- addErrorMessage(response, "moderate", "ERR_SPLIT_ONE_POST_TOPIC");
- return;
- }
-
- //first get all post numbers passed in request
- List postsPassedList = new LinkedList();
- for (int i = 0; i < topic.getPosts().size(); i++)
- {
- String pattern = "post_id_list[" + i + "]";
- String postNum = request.getParameters().get(pattern, "none");
-
- if (!postNum.equals("none"))
- {
-
- postsPassedList.add(new Integer(postNum));
- }
- else
- {
- //break;
- }
- }
- //check if we don't want to move all posts from source topic
- if (postsPassedList.size() == 0)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_NO_POST_SELECTED");
- return;
- }
- else if ((topic.getPosts().size() - postsPassedList.size()) == 0)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_SPLIT_ALL");
- return;
- }
-
- int toForumId = request.getParameters().getInt("forum_to_id", -1);
- if (toForumId == -1)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_DEST_FORUM");
- return;
- }
- SplitTopicCommand cmd = new SplitTopicCommand(request, response);
- cmd.postIds = postsPassedList;
- cmd.module = forumsModule;
- cmd.destinationForumId = new Integer(toForumId);
- cmd.newSubject = request.getParameters().get("subject", "default");
- cmd.topicId = new Integer(tid);
- cmd.userId = request.getUser().getId().toString();
-
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
- return;
- }
- else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
- return;
- }
- else if (type == CommandConstants.TYPE_TOPIC_SPLITED)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addSuccessMessage(response, "moderate", "SUCC_TOPIC_SPLITTED");
- ;
- return;
- }
- return;
- }
- //process split after button
- else if (paramMap.containsKey("split_type_beyond"))
- {
-
- if (topicsPassedList.size() > 1)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "Too_many_error");
- return;
- }
-
- Topic topic = null;
- try
- {
- topic = forumsModule.findTopicById(new Integer(tid));
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
- return;
- }
- if (topic.getPosts().size() == 1)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- //response.setRenderParameter("t","" + tid);
- addErrorMessage(response, "moderate", "ERR_SPLIT_ONE_POST_TOPIC");
- return;
- }
-
- //first get all post numbers passed in request
- List postsPassedList = new LinkedList();
- for (int i = 0; i < topic.getPosts().size(); i++)
- {
- String pattern = "post_id_list[" + i + "]";
- String postNum = request.getParameters().get(pattern, "none");
-
- if (!postNum.equals("none"))
- {
-
- postsPassedList.add(new Integer(postNum));
- }
- else
- {
- //break;
- }
- }
- if (postsPassedList.size() == 0)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_NO_POST_SELECTED");
- return;
- }
- else if (postsPassedList.size() != 1)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "Too_many_error");
- return;
- }
- //check if user selected first post
- else if (topic.getFirstPost().getId().equals((Integer)(postsPassedList.iterator()).next()))
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_SPLIT_ALL");
- return;
- }
-
- int toForumId = request.getParameters().getInt("forum_to_id", -1);
- if (toForumId == -1)
- {
- response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
- response.setRenderParameter("t", "" + tid);
- response.setRenderParameter("f", "" + fid);
- addErrorMessage(response, "moderate", "ERR_DEST_FORUM");
- return;
- }
- SplitTopicCommand cmd = new SplitTopicCommand(request, response);
- cmd.postIds = postsPassedList;
- cmd.module = forumsModule;
- cmd.destinationForumId = new Integer(toForumId);
- cmd.newSubject = request.getParameters().get("subject", "default");
- cmd.topicId = new Integer(tid);
- cmd.userId = request.getUser().getId().toString();
- cmd.splitAfter = true;
-
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
- return;
- }
- else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
- return;
- }
- else if (type == CommandConstants.TYPE_TOPIC_SPLITED)
- {
- response.setRenderParameter(getOperationName(), OP_MAIN);
- addSuccessMessage(response, "moderate", "SUCC_TOPIC_SPLITTED");
-
- return;
- }
-
-
- return;
- }
-
-
- }
-
- public void preferences(JBossActionRequest request, JBossActionResponse response)
- throws CommandException
- {
-
- try
- {
- PortletPreferences pp = request.getPreferences();
- PropertyMap upm = request.getUser().getProperties();
- if (!pp.isReadOnly("notifyreply"))
- {
- pp.setValue("notifyreply", request.getParameter("notifyreply"));
- }
- /*if (!pp.isReadOnly("attachsig"))
- pp.setValue("attachsig", request.getParameter("attachsig"));*/
- if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
- {
- upm.put(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY, request.getParameter("attachsig"));
- }
- //TODO: BBCode disable should be implemented
- /*if (!pp.isReadOnly("allowbbcode"))
- pp.setValue("allowbbcode", request.getParameter("allowbbcode"));*/
- if (!pp.isReadOnly("allowhtml"))
- {
- pp.setValue("allowhtml", request.getParameter("allowhtml"));
- }
- if (!pp.isReadOnly("postorder"))
- {
- pp.setValue("postorder", request.getParameter("postorder"));
- }
- if (!pp.isReadOnly("topicsperforum"))
- {
- pp.setValue("topicsperforum", request.getParameter("topicsperforum"));
- }
- if (!pp.isReadOnly("postspertopic"))
- {
- pp.setValue("postspertopic", request.getParameter("postspertopic"));
- }
- if (!pp.isReadOnly("dateformat"))
- {
- if (request.getParameter("dateformat") != null)
- {
- try
- {
- new SimpleDateFormat(request.getParameter("dateformat"));
- pp.setValue("dateformat", request.getParameter("dateformat"));
- }
- catch (IllegalArgumentException e)
- {
- System.out.println("Illegal date format");
- pp.setValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
- }
- }
- else
- {
- pp.setValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
- }
-
- }
- /*if (!pp.isReadOnly("signature"))
- {
- pp.setValue("signature", request.getParameter("signature"));
- }*/
- if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
- {
- upm.put(ForumsConstants.USER_SIGNATURE_PROPERTY, request.getParameter("signature"));
- }
-
- String summarymode = request.getParameter("summarymode");
- String limit = request.getParameter("summarytopiclimit");
- String days = request.getParameter("summarytopicdays");
- String replies = request.getParameter("summarytopicreplies");
- // we do simple validation of integers in fields
-
- if (!pp.isReadOnly("summarymode"))
- {
- new Integer(summarymode);
- pp.setValue("summarymode", request.getParameter("summarymode"));
- }
-
- try
- {
- if (!pp.isReadOnly("summarytopiclimit"))
- {
- Integer.parseInt(limit);
- pp.setValue("summarytopiclimit", request.getParameter("summarytopiclimit"));
- }
- }
- catch (IllegalArgumentException e)
- {
- //e.printStackTrace();
- if (!pp.isReadOnly("summarytopiclimit"))
- {
- pp.setValue("summarytopiclimit", "6");
- }
- addErrorMessage(response, "posting", "Illegal format in: Topic Summary Limit");
- }
-
- try
- {
- if (!pp.isReadOnly("summarytopicdays"))
- {
- new Integer(days);
- pp.setValue("summarytopicdays", request.getParameter("summarytopicdays"));
- }
- }
- catch (IllegalArgumentException e)
- {
- //e.printStackTrace();
- if (!pp.isReadOnly("summarytopicdays"))
- {
- pp.setValue("summarytopicdays", "20");
- }
- addErrorMessage(response, "posting", "Illegal format in: Topic Summary Days");
- }
-
- try
- {
- if (!pp.isReadOnly("summarytopicreplies"))
- {
- new Integer(replies);
- pp.setValue("summarytopicreplies", request.getParameter("summarytopicreplies"));
- }
- }
- catch (IllegalArgumentException e)
- {
- //e.printStackTrace();
- if (!pp.isReadOnly("summarytopicreplies"))
- {
- pp.setValue("summarytopicreplies", "15");
- }
- addErrorMessage(response, "posting", "Illegal format in: Topic Summary Replies");
- }
- pp.store();
- }
- catch (Exception e)
- {
- System.out.println("Some Exception while storing portlet prefs....");
- addErrorMessage(response, "posting", "Some Exception while storing portlet prefs....");
- e.printStackTrace();
- }
- }
-
-
- /**
- * posting operation
- *
- * @param request JBoss action request
- * @param response JBoss action response
- * @throws CommandException
- * @throws CommandException DOCUMENT_ME
- */
- public void posting(JBossActionRequest request, JBossActionResponse response)
- throws CommandException
- {
-
-
- //for debug
- /*System.out.println("@@@@@@@@@@@@@@@@@@@@@@");
- System.out.println("in posting();");
- *///For more debug puproses uncomment lines in Contex.update()
-
- ResourceBundle bundle = getResourceBundle(request.getLocale());
-
- Context ctx = new Context();
- ctx.setForumsModule(forumsModule);
- ctx.update(request, response);
-
- //Cancel button
- String cancelVal = request.getParameters().get("cancel_posting", "none");
- boolean cancelbtn = !cancelVal.equals("none");
- if (cancelbtn)
- {
- switch (ctx.p_mode)
- {
- case ForumsConstants.PMODE_NEW_TOPIC:
- {
- response.setRenderParameter("op", OP_SHOWFORUM);
- response.setRenderParameter("f", "" + ctx.p_forum_id);
- return;
- }
- case ForumsConstants.PMODE_REPLY:
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("t", "" + ctx.p_post_parent_topic_id);
- return;
- }
- case ForumsConstants.PMODE_EDIT_POST:
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("p", "" + ctx.p_post_id);
- return;
- }
- }
-
- }
-
- //Set info that posting was processed so if new topic page will be displayed it will be postback
- response.setRenderParameter(ForumsConstants.POSTING_POSTBACK_FLAG, "true");
-
- /*
- // Was cancel pressed? If so then redirect to the appropriate page
- if (ctx.p_cancel)
- {
- if (ctx.p_post_id != -1)
- {
- response.sendRedirect("index.html?module=bb&op=viewtopic&p="
- + ctx.p_post_id + "#" + ctx.p_post_id);
- }
- else if (ctx.p_topic_id != -1)
- {
- response.sendRedirect("index.html?module=bb&op=viewtopic&t="
- + ctx.p_topic_id);
- }
- else if (ctx.p_forum_id != -1)
- {
- response.sendRedirect("index.html?module=bb&op=viewforum&f="
- + ctx.p_forum_id);
- }
- else
- {
- response.sendRedirect("index.html?module=bb");
- }
- return;
- }
- */
-
- // If the variable mode is empty we don't go farther in the process
- if (ctx.p_mode == PMODE_NO_MODE)
- {
- addErrorMessage(response, "posting",
- "Unexpected error: No mode defined");
- return;
- }
-
- //If there were poll delete confirmation "No" button pressed
- if ((ctx.p_mode == ForumsConstants.PMODE_POLL_DELETE) &&
- (request.getParameter("cancel") != null) &&
- (request.getParameter("cancel").equals("No")))
- {
- if (ctx.p_post_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("p", "" + ctx.p_post_id);
- }
- else if (ctx.p_topic_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("t", "" + ctx.p_topic_id);
- }
- else if (ctx.p_forum_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWFORUM);
- response.setRenderParameter("f", "" + ctx.p_forum_id);
- }
- return;
-
- }
-
- if (ctx.c_refresh)
- {
- response.setRenderParameter("mode", request.getParameter("mode"));
-
- }
-
- if (ctx.p_mode == PMODE_EDIT_POST)
- {
- if (ctx.p_topic_first_post)
- {
- response.setRenderParameter("firstTopicPost", "" + ctx.p_topic_first_post);
- }
- response.setRenderParameter("topictype", "" + ctx.p_topic_type);
- //return;
- }
- /*
- // If the mode is set to topic review then output that review
- switch (ctx.p_mode)
- {
- case PMODE_TOPIC_REVIEW:
- // display(theme.TPL_THEME_POSTING_TOPIC_REVIEW, topicReview(ctx.p_topic_id), page);
- return;
- case PMODE_SMILIES:
- // generate_smilies('window', PAGE_POSTING);
- // exit;
- return;
- }
- */
-
- // Output the confirm message in no confirm variable is found when we delete something
- if ((((ctx.p_mode == PMODE_EDIT_POST) && ctx.p_poll_delete) || (ctx.p_mode == PMODE_DELETE))
- && !ctx.p_confirm)
- {
- response.setRenderParameter("MESSAGE_TITLE", bundle
- .getString("Information"));
- response.setRenderParameter("MESSAGE_TEXT",
- (ctx.p_mode == PMODE_DELETE) ? bundle
- .getString("Confirm_delete") : bundle
- .getString("Confirm_delete_poll"));
- response
- .setRenderParameter("S_HIDDEN_FIELDS",
- "<input type=\"hidden\" name=\"p\" value=\""
- + ctx.p_post_id
- + "\"/>"
- + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
- + "<input type=\"hidden\" name=\"op\" value=\"posting\"/>"
- + ((ctx.p_mode == PMODE_DELETE) ? "<input type=\"hidden\" name=\"mode\" value=\"delete\"/>"
- : "<input type=\"hidden\" name=\"mode\" value=\"poll_delete\"/>"));
-
- // display(theme.TPL_THEME_CONFIRM_BODY, temp, page);
- response.setRenderParameter("op", OP_CONFIRM);
- return;
- }
-
- // Get user informations
- User currentUser = request.getUser();
-
- //
- Action action = ctx.action(request, response);
-
- if (action instanceof ProcessCommandAction)
- {
- // Get the encapsulated command
- ForumCommand cmd = ((ProcessCommandAction)action).getCommand();
-
- // Set the current user on it
- cmd.setCurrentUser(currentUser);
-
- // Execute it
- // Finish the command configuration
- cmd.setModule(forumsModule);
-
- // Execute the command
- Result result = forumsModule.invoke(cmd);
-
- // Switch on the result
- ResultType type = result.getType();
-
- /*
- if (type == CommandConstants.TYPE_ALREADY_VOTED)
- {
- // Die.exit(GENERAL_MESSAGE,
- // "${bb.Already_voted}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
- // ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
- }
- else if (type == CommandConstants.TYPE_CANNOT_INSERT_VOTE)
- {
- // Die.rollback(GENERAL_ERROR, "Could not insert user_id for poll");
- }
- else if (type == CommandConstants.TYPE_CANNOT_OBTAIN_USER_DATA)
- {
- // Die.exit(GENERAL_ERROR, "Could not obtain user vote data for this topic");
- }
- else if (type == CommandConstants.TYPE_VOTE_CAST)
- {
- // Die.exit(GENERAL_MESSAGE,
- // "${bb.Vote_cast}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
- // ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
- }
- else if (type == CommandConstants.TYPE_NO_VOTE_OPTION)
- {
- // Die.exit(GENERAL_MESSAGE,
- // "${bb.No_vote_option}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
- // ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
- }
- else if (type == CommandConstants.TYPE_COULD_NOT_OBTAIN_VOTE_DATA)
- {
- // Die.exit(GENERAL_ERROR, "Could not obtain vote data for this topic");
- }
- else if (type == CommandConstants.TYPE_REDIRECT)
- {
- response.sendRedirect("index.html?module=bb&op=viewtopic&t=" + ((VoteTopicCommand) cmd).topic.getId());
- }
- else
- */
- if (type == CommandConstants.TYPE_ERROR_IN_POSTING)
- {
- addErrorMessage(response, "postingfailed", "Error in posting");
- return;
- }
- else if ((type == CommandConstants.TYPE_NEW_TOPIC_POSTED)
- || (type == CommandConstants.TYPE_EDIT_POST_POSTED)
- || (type == CommandConstants.TYPE_REPLY_POSTED)
- )
- {
- Post post = null;
- if (cmd instanceof NewTopicCommand)
- {
- post = ((NewTopicCommand)cmd).post;
- }
- else if (cmd instanceof EditPostCommand)
- {
- post = ((EditPostCommand)cmd).post;
- }
- else
- {
- post = ((ReplyCommand)cmd).newPost;
- }
-
- //removed according JBPORTAL-403
- //addSuccessMessage(response, "posting", "Stored");
- if (ctx.p_post_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("p", "" + ctx.p_post_id);
- }
- else if (ctx.p_topic_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("t", "" + ctx.p_topic_id);
- }
- else if (ctx.p_forum_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWFORUM);
- response.setRenderParameter("f", "" + ctx.p_forum_id);
- }
-
-
- return;
- }
- else if (type == CommandConstants.TYPE_VOTE_POSTED)
- {
- addSuccessMessage(response, "posting", "Voted Successfully");
- if (ctx.p_post_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("p", "" + ctx.p_post_id);
- }
- else if (ctx.p_topic_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("t", "" + ctx.p_topic_id);
- }
- else if (ctx.p_forum_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWFORUM);
- response.setRenderParameter("f", "" + ctx.p_forum_id);
- }
-
- return;
- }
- else if (type == CommandConstants.TYPE_NOT_SELECTED_VOTE)
- {
- addErrorMessage(response, "posting", "Cannot vote because no option selected");
- return;
- }
- else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_POST)
- {
- addErrorMessage(response, "posting", "Error in deleting post");
- return;
- }
- else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_POLL)
- {
- addErrorMessage(response, "posting", "Error in deleting poll");
- return;
- }
- else if ((type == CommandConstants.TYPE_POLL_DELETED)
- || (type == CommandConstants.TYPE_POST_DELETED))
- {
- // Die.exit(GENERAL_MESSAGE,
- // "<br/><br/>${bb.Click_return_forum_0}<a href=\"index.html?module=bb&op=viewforum&f=" +
- // cmd.forum.getId() + "\">${bb.Click_return_forum_1}</a>" +
- // "${bb.Click_return_forum_2}");
- if (ctx.p_post_id != -1 && (type != CommandConstants.TYPE_POST_DELETED))
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("p", "" + ctx.p_post_id);
- }
- else if (ctx.p_topic_id != -1 &&
- (cmd instanceof DeletePostCommand) &&
- !(((DeletePostCommand)cmd).pd_first_post && ((DeletePostCommand)cmd).pd_last_post))
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("t", "" + ctx.p_topic_id);
-
- }
- else if (ctx.p_forum_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWFORUM);
- response.setRenderParameter("f", "" + ctx.p_forum_id);
- }
- else
- {
- response.setRenderParameter("op", OP_MAIN);
- }
-
- return;
- }
- else if (type == CommandConstants.TYPE_FORUM_LOCKED)
- {
- addErrorMessage(response, "postingfailed", "Forum_locked");
- return;
- }
- else if (type == CommandConstants.TYPE_TOPIC_IS_LOCKED)
- {
- addErrorMessage(response, "postingfailed", "Topic_locked");
- return;
- }
- else if (type == CommandConstants.TYPE_NOT_AUTHORIZED)
- {
- //if (isUserLoggedIn(currentUser))
- if (request.getRemoteUser() != null)
- {
- // Die.exit(GENERAL_MESSAGE, "${bb." + AUTH_TYPE_TO_MESSAGE[cmd.authType()] + "0}" +
- // "todo" + // $is_auth[$is_auth_type . "_type"]
- // "${bb." + AUTH_TYPE_TO_MESSAGE[cmd.authType()] + "1}");
- return;
- }
- else
- {
- if (cmd instanceof EditPostCommand)
- {
- // redirect after = index.html?module=bb&op=posting&mode=quote& + POST_POST_URL + = post_id
- }
- else if (cmd instanceof NewTopicCommand)
- {
- // redirect after = index.html?module=bb&op=posting&mode=newtopic& + POST_FORUM_URL + = forum_id
- }
- else if (cmd instanceof ReplyCommand)
- {
- // if (((ReplyCommand)cmd).quote)
- // {
- // // redirect after = index.html?module=bb&op=posting&mode=quote& + POST_POST_URL + = post_id
- // }
- // else
- // {
- // // beware mode=reply switched from topic to topic.lastPost
- // // redirect after = index.html?module=bb&op=posting&mode=reply& + POST_TOPIC_URL + = topic_id
- // }
- }
- else
- {
- if (ctx.p_post_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("p", "" + ctx.p_post_id);
- }
- else if (ctx.p_topic_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWTOPIC);
- response.setRenderParameter("t", "" + ctx.p_topic_id);
- }
- else if (ctx.p_forum_id != -1)
- {
- response.setRenderParameter("op", OP_SHOWFORUM);
- response.setRenderParameter("f", "" + ctx.p_forum_id);
- }
- }
-
- // response.sendRedirect("index.html?module=user&op=getlogin");
- }
- }
- else if (type == CommandConstants.TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR)
- {
- // Die.exit(GENERAL_MESSAGE, (cmd instanceof DeletePollCommand || cmd instanceof DeletePostCommand) ?
- // "${bb.Delete_own_posts}" : "${bb.Edit_own_posts}" +
- // "<br/><br/>${bb.Click_return_topic_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
- // ((TopicCommand)cmd).topic.getId() +
- // "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}");
- }
- else if (type == CommandConstants.TYPE_CANNOT_DELETE_REPLIED)
- {
- addErrorMessage(response, "postingfailed", "Cannot_delete_replied");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_DELETE_POLL)
- {
- addErrorMessage(response, "postingfailed", "Cannot_delete_poll");
- return;
- }
- else if (type == CommandConstants.TYPE_NO_SUCH_POST)
- {
- addErrorMessage(response, "postingfailed", "No_such_Post");
- return;
- }
- else if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
- {
- addErrorMessage(response, "postingfailed", "No_topic_id");
- return;
- }
- else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
- {
- addErrorMessage(response, "postingfailed", "Forum_not_exist");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_QUERY)
- {
- addErrorMessage(response, "postingfailed",
- "Could not query forum/topic/post information");
- return;
- }
- else if (type == CommandConstants.TYPE_INVALID_POST_SUBJECT)
- {
- addErrorMessage(response, "postingfailed", "Empty_subject");
- return;
- }
- else if (type == CommandConstants.TYPE_INVALID_POST_MESSAGE)
- {
- addErrorMessage(response, "postingfailed", "Empty_message");
- return;
- }
- else if (type == CommandConstants.TYPE_TOO_MANY_POLL_OPTION)
- {
- addErrorMessage(response, "postingfailed", "To_many_poll_options");
- return;
- }
- else if (type == CommandConstants.TYPE_INVALID_POLL_OPTION)
- {
- addErrorMessage(response, "postingfailed", "Empty_poll_option");
- return;
- }
- else if (type == CommandConstants.TYPE_INVALID_POLL_TITLE)
- {
- addErrorMessage(response, "postingfailed", "Empty_poll_title");
- return;
- }
- else if (type == CommandConstants.TYPE_TOO_FEW_POLL_OPTION)
- {
- addErrorMessage(response, "postingfailed", "To_few_poll_options");
- return;
- }
- else if (type == CommandConstants.TYPE_REPOSTED)
- {
- addErrorMessage(response, "postingfailed", "Reposted");
- return;
-
- // Die.exit(GENERAL_MESSAGE,
- // "${bb.Reposted}<br/><br/>" +
- // "${bb.Click_view_message_0}" +
- // "<a href=\"index.html?module=bb&op=viewtopic&t=" +
- // ((RepostCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
- }
- else if (type == CommandConstants.TYPE_FLOODING_CANNOT_CREATE)
- {
- addErrorMessage(response, "postingfailed", "Flood_Error");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_ADD_ATTACHMENT)
- {
- addErrorMessage(response, "postingfailed",
- "You are not authorized to add an attachment");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_DELETE_ATTACHMENT)
- {
- addErrorMessage(response, "postingfailed",
- "You are not authorized to delete an attachment");
- return;
- }
- else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_ATTACHMENT)
- {
- addErrorMessage(response, "postingfailed",
- "Problem when deleting an attachment");
- return;
- }
- else
- {
- throw new RuntimeException("This statement should not be reached");
- }
- }
- else
- {
- ForumAction faction = (ForumAction)action;
-
- faction.init();
-
- Forum forum = faction.getForum();
- Category category = forum.getCategory();
- Message msg = faction.getMessage();
- Poster poster = faction.getPoster();
-
- // Level level = secGetLevel(category.getTitle() + ":" + forum.getName() + ":", currentUser);
- //boolean loggedIn = isUserLoggedIn(currentUser);
- boolean loggedIn = request.getRemoteUser() != null;
- /*int[] types = new int[]{AuthType.READ, AuthType.DELETE,
- AuthType.STICKY, AuthType.ANNOUNCE, AuthType.POLL,
- AuthType.ATTACH};*/
-
- // boolean[] auths = forum.getAuth().can(types, loggedIn, level);
- // boolean isAuthRead = auths[0];
- // boolean isAuthDelete = auths[1];
- // boolean isAuthSticky = auths[2];
- // boolean isAuthAnnounce = auths[3];
- // boolean isAuthPollCreate = auths[4];
- // boolean isAuthAttachments = auths[5];
- // boolean isAuthMod = Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
- // We are sure to have forumEJB not null and we always target a forum
- int forum_id = forum.getId().intValue();
- String forum_name = forum.getName();
- Integer topic_id = (faction instanceof TopicAction) ? ((TopicAction)faction)
- .getTopic().getId()
- : new Integer(-1);
-
- // julien : is it utile ?
- // if (topic_id.intValue() > -1 && (cmd instanceof NewTopicCommand || cmd instanceof ReplyCommand))
- // {
- // Map trackingTopics = getTrackingTopics(page);
- // trackingTopics.put(topic_id, new Date());
- // }
- // if (!"".equals(error_msg))
- // {
- // DelegateContext temp = provider.instantiate(TPL_THEME_ERROR_BODY);
- // temp.put("ERROR_MESSAGE", error_msg);
- // errorBox = temp.render();
- // }
- String previewBox = "";
- String errorBox = "";
-
- if (ctx.p_preview)
- {
- PropertyMap upm = request.getUser().getProperties();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
- String preview_message = "";
- if ((addsign != null) && (sign != null) && addsign.equals("1"))
- {
- //preview_message = formatMessage(request, msg.getText() + "\n\n" + sign, msg.getBBCodeEnabled(), msg.getHTMLEnabled());
- preview_message = formatMessage(request, msg.getText() + "\n\n" + sign, msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
- }
- else
- {
- //preview_message = formatMessage(request, msg.getText(), msg.getBBCodeEnabled(), msg.getHTMLEnabled());
- preview_message = formatMessage(request, msg.getText(), msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
- }
- /*String preview_message = formatMessage(msg.getText(), msg
- .getBBCodeEnabled(), msg.getHTMLEnabled());*/
- //if ((currentUser != null) && msg.getSignatureEnabled())
- //{
- //String signature = currentUser.getSignature();
- String signature = request.getPreferences().getValue("signature", "");
- if (!ForumsTools.isNullOrBlank(signature))
- {
- //preview_message += formatSignature(request, signature, msg.getBBCodeEnabled(), msg.getHTMLEnabled());
- preview_message += formatSignature(request, signature, msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
- }
- //}
-
- String preview_subject = formatTitle(request, msg.getSubject());
- String preview_username = formatUserName(poster.getUser());
-
- //
- // Date formater
- //
- SimpleDateFormat sdf = getSDF(request);
-
- // PortletURL postingURL = response.createRenderURL();
- // postingURL.setParameter("op", OP_POSTING);
- response.setRenderParameter("op", OP_POSTING);
- response.setRenderParameter("preview", "true");
- if (request.getParameters().getParameterExists("f"))
- {
- response.setRenderParameter("f", request.getParameter("f"));
- }
-
- if (request.getParameters().getParameterExists("p"))
- {
- response.setRenderParameter("p", request.getParameter("p"));
- }
-
- response.setRenderParameter("mode", request.getParameter("mode"));
- response.setRenderParameter("TOPIC_TITLE", preview_subject);
- response.setRenderParameter("POST_SUBJECT", msg.getSubject());
- response.setRenderParameter("PREVIEW_SUBJECT", preview_subject);
- response.setRenderParameter("POSTER_NAME", preview_username);
- response.setRenderParameter("POST_DATE", sdf.format(new Date()));
- response.setRenderParameter("MESSAGE", msg.getText());
- response.setRenderParameter("PREVIEW_MESSAGE", preview_message);
-
- // response.sendRedirect(postingURL.toString());
-
- }
-
- if ((ctx.p_mode == ForumsConstants.PMODE_EDIT_POST) &&
- (ctx.p_topic_first_post == true))
- {
- response.setRenderParameter("editPoll", "true");
- Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
- if (request.getParameter("editPostInit") != null && (ctx.p_post_id != -1))
- {
- try
- {
- Post p = forumsModule.findPostById(new Integer(ctx.p_post_id));
- Topic t = forumsModule.findTopicById(p.getTopic().getId());
- if (t.getPoll() != null)
- {
- poll = t.getPoll();
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- DelegateContext temp = new DelegateContext();
- response.setRenderParameter("POLL_TITLE", poll.getTitle());
- response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));
- if (action instanceof EditPostAction)
- {
- response.setRenderParameter("switch_poll_delete_toggle", "true");
- //root.next("switch_poll_delete_toggle");
- }
- int index = 0;
- for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
- {
- String text = ((PollOption)iterator.next()).getQuestion();
- //String text = (String)iterator.next();
- String param = "poll_option_text[" + index + "]";
- response.setRenderParameter(param, text);
- index++;
- }
- }
-
- //DelegateContext root = new DelegateContext();
-
- /*
- if (htmlEnabled)
- {
- root.next("switch_html_checkbox");
- root.put("HTML_STATUS", "${bb.HTML_is_ON}");
- }
- else
- {
- root.put("HTML_STATUS", "${bb.HTML_is_OFF}");
- }
- if (codeEnabled)
- {
- root.next("switch_bbcode_checkbox");
- root.put("BBCODE_STATUS", "${bb.BBCode_is_ON_0}<a href=\"index.html?module=bb&op=faq\" " +
- "target=\"_phpbbcode\">" +
- "${bb.BBCode_is_ON_1}</a>${bb.BBCode_is_ON_2}");
- }
- else
- {
- root.put("BBCODE_STATUS", "${bb.BBCode_is_OFF_0}<a href=\"index.html?module=bb&op=faq\"" +
- "target=\"_phpbbcode\">" +
- "${bb.BBCode_is_OFF_1}</a>${bb.BBCode_is_OFF_2}");
- }
- if (smiliesEnabled)
- {
- root.next("switch_smilies_checkbox");
- root.put("SMILIES_STATUS", "${bb.Smilies_are_ON}");
- }
- else
- {
- root.put("SMILIES_STATUS", "${bb.Smilies_are_OFF}");
- }
- */
- /*if ((currentUser == null)
- || (faction instanceof EditPostAction && (((EditPostAction)faction)
- .getPost().getPoster().getUser() == null)))
- {
- root.next("switch_username_select");
- }*/
-
- // Set the notify toggle on the template
- /* if (currentUser != null)
- {
- root.next("switch_notify_checkbox");
- boolean notify = ctx.p_notify;
- if ((faction instanceof EditPostAction && (faction.getMode() == ForumAction.INIT))
- || (faction instanceof ReplyAction && (faction.getMode() == ForumAction.INIT)))
- {
- */ /*
- try
- {
- homesRW.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(currentUser.getId(), ((TopicAction)faction).getTopic().getId()));
- notify = true;
- }
- catch (ObjectNotFoundException e)
- {
- // no watch
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain watch information", e);
- }
- */
- /* }
-
- root.put("S_NOTIFY_CHECKED", notify ? "checked=\"checked\"" : "");
- }*/
-
- // Set the signature toggle on the template
- /*if (currentUser != null)
- {
- root.next("switch_signature_checkbox");
- }*/
-
- // BLAH todo
- // Set set delete toggle on the template
- // if (action instanceof EditPostAction && (isAuthMod || isAuthDelete))
- // {
- // EditPostAction epa = (EditPostAction)action;
- // if (epc.pd_last_post && (!epc.topic.getVote() || epc.pd_edit_poll))
- // {
- // root.next("switch_delete_checkbox");
- // }
- // }
- // Topic type selection
- if (faction instanceof NewTopicAction
- || (faction instanceof EditPostAction && ((EditPostAction)faction)
- .isFirstPost()))
- {
- int topic_type = ctx.p_topic_type;
-
- // If we edit the post we override the topic type with the one loaded from the DB
- if (faction instanceof EditPostAction
- && (faction.getMode() == EditPostAction.INIT))
- {
- topic_type = ((EditPostAction)faction).getTopic().getType();
- }
-
- switch (topic_type)
- {
- case 1:
- {
- response.setRenderParameter("topictype",Integer.toString(1));
- }
- break;
-
- case 2:
- {
- response.setRenderParameter("topictype",Integer.toString(2));
- }
- break;
-
-
- default:
- {
- response.setRenderParameter("topictype",Integer.toString(0));
- }
- break;
- }
-
-
- /*
- // Create the topic type selected
- if (isAuthSticky || isAuthAnnounce)
- {
- StringBuffer selector = new StringBuffer("${bb.Post_topic_as}:");
- BBTools.radioButton(selector, "topictype", "" + POST_NORMAL, topic_type == POST_NORMAL);
- selector.append("${bb.Post_Normal} ");
- if (isAuthSticky)
- {
- BBTools.radioButton(selector, "topictype", "" + POST_STICKY, topic_type == POST_STICKY);
- selector.append("${bb.Post_Sticky} ");
- }
- if (isAuthAnnounce)
- {
- BBTools.radioButton(selector, "topictype", "" + POST_ANNOUNCE, topic_type == POST_ANNOUNCE);
- selector.append("${bb.Post_Announcement} ");
- }
- root.next("switch_type_toggle");
- root.put("S_TYPE_TOGGLE", selector.toString());
- }
- */
- }
-
- // Hidden form fields
- StringBuffer hidden_form_fields = new StringBuffer();
- hidden_form_fields.append("<input type=\"hidden\" name=\"mode\" value=\"").append(ModeDecoder.encodePosting(ctx.p_mode)).append("\"/>").append("<input type=\"hidden\" name=\"op\" value=\"posting\"/>");
- if (faction instanceof NewTopicAction)
- {
- hidden_form_fields.append("<input type=\"hidden\" name=\"f\" value=\"")
- .append(forum_id).append("\"/>");
- }
- else if (faction instanceof ReplyAction
- || faction instanceof EditPostAction)
- {
- hidden_form_fields.append("<input type=\"hidden\" name=\"p\" value=\"").append(((PostAction)faction).getPost().getId()).append("\"/>");
- }
-
- //System.out.println("I'm here :) - so refreshing page or doing sth else");
- //System.out.println("Number of polls opts: " + ctx.p_poll.getOptions().size() + " plus poll lenght: " + ctx.p_poll.getLength());
-
- String pollBox = "";
- boolean canCreatePoll = false;
- /*if (action instanceof EditPostAction)
- {
-
- switch (((EditPostAction)faction).getTopic().getPollLevel())
- {
- case TopicEJB.POLL_LEVEL_EMPTY:
- canCreatePoll = isAuthPollCreate || isAuthMod;
- break;
- case TopicEJB.POLL_LEVEL_NO_POLL:
- canCreatePoll = isAuthPollCreate || isAuthMod;
- break;
- case TopicEJB.POLL_LEVEL_NON_EMPTY:
- canCreatePoll = isAuthMod;
- break;
- default:
- throw new RuntimeException();
- }
-
- }
- else*/
- //{
- canCreatePoll = (action instanceof NewTopicAction);
-
- canCreatePoll &= ForumsTools.hasPermission(request, "AddPollInPost");
- //}
- if (canCreatePoll)
- {
- Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
- DelegateContext temp = new DelegateContext();
- response.setRenderParameter("POLL_TITLE", poll.getTitle());
- response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));
- if (action instanceof EditPostAction)
- {
- response.setRenderParameter("switch_poll_delete_toggle", "true");
- //root.next("switch_poll_delete_toggle");
- }
- int index = 0;
- for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
- {
- String text = ((PollOption)iterator.next()).getQuestion();
- //String text = (String)iterator.next();
- String param = "poll_option_text[" + index + "]";
- response.setRenderParameter(param, text);
- index++;
- }
- }
-
- boolean canAttach = false;
- if ((action instanceof NewTopicAction) ||
- (action instanceof EditPostAction) ||
- (action instanceof ReplyAction))
- {
- String[] testArray = new String[]{category.getTitle(), forum.getName()};
- canAttach = ForumsTools.hasPermission(request, testArray, "AddAttachmentInPost");
- }
-
- //We must pass attachments data through response to creation of NewTopic view
- if (canAttach)
- {
- List uploadedAttachments = ctx.p_session_attachments;
- //index to count id of all attachments passd to view. needed to generate proper render params
- int index = 0;
- //if its edit we must pass already stored attachments minus those deleted by user
- if (ctx.p_mode == ForumsConstants.PMODE_EDIT_POST)
- {
- Post p = null;
- try
- {
- p = forumsModule.findPostById(new Integer(ctx.p_post_id));
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- //TODO:Some nice error message...
- }
- List storedAttachments = null;
- if (p != null && (storedAttachments = p.getAttachments()) != null)
- {
- storedAttachments:
- for (Iterator i = storedAttachments.iterator(); i.hasNext();)
- {
- Attachment attachment = (Attachment)i.next();
- String updatedComment = null;
- //check if attachment id is on deleted list;
- for (Iterator j = ctx.p_deleted_attachments.iterator(); j.hasNext();)
- {
- Integer deletedIndex = (Integer)j.next();
- if (deletedIndex.intValue() == attachment.getId().intValue())
- {
- //Attachment id on deleted list so continueing without displaying it
- continue storedAttachments;
- }
- }
- for (Iterator j = ctx.p_updated_attachments.keySet().iterator(); j.hasNext();)
- {
- Integer updatedIndex = (Integer)j.next();
- if (updatedIndex.intValue() == attachment.getId().intValue())
- {
- //Attachment id on updated list so we retrieve updated comment
- updatedComment = (String)ctx.p_updated_attachments.get(updatedIndex);
- break;
- }
- }
- response.setRenderParameter("ATTACHMENT[" + index + "]_NAME", attachment.getFile().getName());
- response.setRenderParameter("ATTACHMENT[" + index + "]_ID", "stored_attach_" + attachment.getId());
- response.setRenderParameter("ATTACHMENT[" + index + "]_COMMENT", (updatedComment != null) ? updatedComment : attachment.getComment());
- index++;
- }
- }
- }
- //and now pass newly uploaded ones
- for (Iterator i = uploadedAttachments.iterator(); i.hasNext(); index++)
- {
- FileBinding fb = (FileBinding)i.next();
- response.setRenderParameter("ATTACHMENT[" + index + "]_NAME", fb.getFileName());
- response.setRenderParameter("ATTACHMENT[" + index + "]_ID", fb.getFileId());
- response.setRenderParameter("ATTACHMENT[" + index + "]_COMMENT", fb.getComment());
- }
- }
-
- // generate smilies listing for page output
- // generate_smilies('inline', PAGE_POSTING);
- /*
- String pollBox = "";
- boolean canCreatePoll = false;
- if (action instanceof EditPostAction)
- {
-
- switch (((EditPostAction)faction).getTopic().getPollLevel())
- {
- case TopicEJB.POLL_LEVEL_EMPTY:
- canCreatePoll = isAuthPollCreate || isAuthMod;
- break;
- case TopicEJB.POLL_LEVEL_NO_POLL:
- canCreatePoll = isAuthPollCreate || isAuthMod;
- break;
- case TopicEJB.POLL_LEVEL_NON_EMPTY:
- canCreatePoll = isAuthMod;
- break;
- default:
- throw new RuntimeException();
- }
-
- }
- else
- {
- canCreatePoll = action instanceof NewTopicAction;
- }
- if (canCreatePoll)
- {
- Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
- DelegateContext temp = new DelegateContext();
- temp.put("POLL_TITLE", poll.getTitle());
- temp.put("POLL_LENGTH", Integer.toString(poll.getLength()));
- if (action instanceof EditPostAction)
- {
- temp.next("switch_poll_delete_toggle");
- }
- int index = 0;
- for (Iterator iterator = poll.getOptions().iterator();iterator.hasNext();)
- {
- String text = (String)iterator.next();
- if (text != null)
- {
- DelegateContext poll_option_rows = temp.next("poll_option_rows");
- poll_option_rows.put("POLL_OPTION", text);
- poll_option_rows.put("S_POLL_OPTION_NUM", "" + index++);
- }
- }
- pollBox = theme.TPL_THEME_POSTING_POLL_BODY.render(temp);
- }
- */
- // attachBox
- // get HTMLCode for attachment form
- // TODO: Check the if condition for attachBox
- // String attachBox = "";
- // if (/*(action instanceof NewTopicAction || action instanceof EditPostAction) && */isAuthAttachments)
- /* {
- DelegateContext temp = new DelegateContext();
- if (showApcp)
- {
- temp.next("show_apcp");
- temp.next("switch_posted_attachments");
- }
- String addAttachmentBox = "";
- if (ctx.p_attach_box || !showApcp)
- {
- root.put("S_FORM_ENCTYPE", " enctype=\"multipart/form-data\"");
- DelegateContext addAttachmentCtx = new DelegateContext();
- addAttachmentBox = theme.TPL_THEME_ADD_ATTACHMENT_BODY.render(addAttachmentCtx);
- DelegateContext hidden_row = temp.next("hidden_row");
- hidden_row.put("S_HIDDEN", "<input type=\"hidden\" name=\"add_attachment_box_flag\" value=\"1\"/>\n");
- temp.put("ADD_ATTACHMENT_BODY", addAttachmentBox);
- }
- String postedAttachmentsBox = "";
- if ((ctx.p_posted_attach) || (!showApcp))
- {
- DelegateContext postedAttachmentsCtx = new DelegateContext();
- if (faction instanceof EditPostAction)
- {
- EditPostAction epa = (EditPostAction)faction;
- PostEJBLocal post = epa.getPost();
- for (Iterator i = post.getAttachments().iterator();i.hasNext();)
- {
- AttachmentEJBLocal attachmentEJB = (AttachmentEJBLocal)i.next();
- if (!ctx.p_deleted_attachments.contains(attachmentEJB.getId()))
- {
- DelegateContext attachRowContext = postedAttachmentsCtx.next("attach_row");
- attachRowContext.put("FILE_NAME", attachmentEJB.getRealFilename());
- attachRowContext.put("FILE_COMMENT", attachmentEJB.getComment());
- attachRowContext.put("ATTACH_FILENAME", "" + attachmentEJB.getId());
- attachRowContext.put("ATTACH_ID", "" + attachmentEJB.getId());
- }
- //attachRowContext.next("switch_update_attachment");
- }
- }
- for (IndexIterator i = IndexIterator.wrap(faction.getAttachments().iterator(), -1);i.hasNext();)
- {
- UploadedFile attachment = (UploadedFile)i.next();
- DelegateContext attachRowContext = postedAttachmentsCtx.next("attach_row");
- attachRowContext.put("FILE_NAME", attachment.getFile().getName());
- attachRowContext.put("FILE_COMMENT", attachment.getComment());
- attachRowContext.put("ATTACH_FILENAME", "session_" + i.getIndex());
- attachRowContext.put("ATTACH_ID", "session_" + i);
- //attachRowContext.next("switch_update_attachment");
- //attachRowContext.next("switch_thumbnail");
- }
- DelegateContext hidden_row = temp.next("hidden_row");
- hidden_row.put("S_HIDDEN", "<input type=\"hidden\" name=\"posted_attachments_flag\" value=\"1\"/>\n");
- postedAttachmentsBox = theme.TPL_THEME_POSTED_ATTACHMENTS_BODY.render(postedAttachmentsCtx);
- temp.put("POSTED_ATTACHMENTS_BODY", postedAttachmentsBox);
- }
-
- // if (ctx.p_attach)
- // {
- // UploadedFileImpl webFile = page.getParameterAsFile("fileupload");
- // if (webFile != null)
- // {
- // // Create the command
- // return new StoreAttachmentCommand(
- // context.getFileHome(),
- // id,
- // fileId,
- // webFile.getContentType(),
- // webFile.getContent(),
- // user,
- // makeProd);
- //Die.exit(GENERAL_ERROR, webFile.getContentType());
- }
- }
- attachBox = theme.TPL_THEME_POSTING_ATTACH_BODY.render(temp);
- }
- // end attachBox
- */
- //String topicReviewBox = "";
- /*
- if (isAuthRead && faction instanceof ReplyAction)
- {
- DelegateContext sub = topicReview(((ReplyAction)faction).getTopic());
- // sub.next("switch_inline_mode");
- // topicReviewBox = theme.TPL_THEME_POSTING_TOPIC_REVIEW.render(sub);
- }
- */
- // We don't handle PM for now
- /*
- root.next("switch_not_privmsg");
- // Output the data to the template
- root.put("FORUM_NAME", forum_name);
- root.put("CATEGORY_NAME",
- category.getTitle());
- root.put("L_POST_A", ""); // not used, this is for the page title
- root.put("U_VIEW_CATEGORY", "index.html?module=bb&op=main&c=" + category.getId().toString());
- root.put("U_VIEW_FORUM", "index.html?module=bb&op=viewforum&f=" + forum_id);
- root.put("USERNAME",
- poster.getUserName());
- root.put("L_EMOTICONS", ""); // todo
- root.put("U_VIEWTOPIC",
- (ctx.p_mode == PMODE_REPLY)
- ? ("index.html?module=bb&op=viewtopic&t=" + topic_id + "&postorder=desc") : "");
- root.put("U_REVIEW_TOPIC",
- (ctx.p_mode == PMODE_REPLY) ? ("index.html?module=bb&op=posting&mode=topicreview&t=" + topic_id)
- : "");
- root.put("S_HTML_CHECKED", msg.getHTMLEnabled() ? "" : "checked=\"checked\"");
- root.put("S_BBCODE_CHECKED", msg.getBBCodeEnabled() ? "" : "checked=\"checked\"");
- root.put("S_SMILIES_CHECKED", msg.getSmiliesEnabled() ? "" : "checked=\"checked\"");
- root.put("S_SIGNATURE_CHECKED", msg.getSignatureEnabled() ? "checked=\"checked\"" : "");
- root.put("S_TOPIC_ID",
- topic_id.toString());
- // root.put("JUMPBOX", makeJumpBox("viewforum", currentUser != null));
- root.put("ERROR_BOX", errorBox);
- root.put("POST_PREVIEW_BOX", previewBox);
- // root.put("POLLBOX", pollBox);
- // root.put("ATTACHBOX", attachBox);
- root.put("TOPIC_REVIEW_BOX", topicReviewBox);
- */
- response.setRenderParameter("S_HIDDEN_FORM_FIELDS", hidden_form_fields
- .toString());
- response.setRenderParameter("op", OP_POSTING);
- if (request.getParameters().getParameterExists("f"))
- {
- response.setRenderParameter("f", request.getParameter("f"));
- }
-
- if (request.getParameters().getParameterExists("p"))
- {
- response.setRenderParameter("p", request.getParameter("p"));
- }
- response.setRenderParameter("SUBJECT", msg.getSubject());
-
- if (ctx.p_mode == PMODE_QUOTE)
- {
- Post post;
- try
- {
- post = forumsModule.findPostById(new Integer(ctx.p_post_id));
- msg.setText("[quote=" + post.getPoster().getUser().getUserName() + "]" + post.getMessage().getText() + "[/quote]");
- }
- catch (ModuleException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- else if (ctx.p_mode == PMODE_EDIT_POST)
- {
- Post post;
- try
- {
- post = forumsModule.findPostById(new Integer(ctx.p_post_id));
- msg.setText(post.getMessage().getText());
- }
- catch (ModuleException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- response.setRenderParameter("MESSAGE", msg.getText());
- }
- }
-
- /**
- * admin_forums operation
- *
- * @param req JBoss Action Request
- * @param resp JBoss Action Response
- */
- public void admin_forums(JBossActionRequest req, JBossActionResponse resp)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
- //Use this to do debug
- /*System.out.println("in admin_forums(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
- for (Iterator i=req.getParameterMap().keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- System.out.println("param key: " + key + " param val: " + req.getParameter(key));
- }*/
- String mode = req.getParameters().get("mode", "");
- boolean addCategory = req.getParameter("addcategory") != null;
- Category addforum = null;
-
-
- try
- {
- for (Iterator i = forumsModule.findCategories().iterator(); i
- .hasNext();)
- {
- Category category = (Category)i.next();
- if (req.getParameter("addforum_" + category.getId()) != null)
- {
- addforum = category;
- break;
- }
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
- addErrorMessage(resp, "admin", "Cannot process command");
- return;
- }
-
- if ((addforum != null) || addCategory)
- {
- if (addforum != null)
- {
- mode = "addforum";
- }
- else
- {
- mode = "addcat";
- }
- }
-
- if ("addforum".equals(mode) || "editforum".equals(mode))
- {
-
- /*PortletURL addOrEditForumURL = resp.createRenderURL();
- addOrEditForumURL.setParameters(req.getParameterMap());
- addOrEditForumURL.setParameter("mode", mode);
- addOrEditForumURL.setParameter("op", OP_SHOWADDEDITFORUM);*/
- resp.setRenderParameters(req.getParameterMap());
- resp.setRenderParameter("mode", mode);
- resp.setRenderParameter("op", OP_SHOWADDEDITFORUM);
-
- if ("addforum".equals(mode))
- {
- //addOrEditForumURL.setParameter("c", "" + addforum.getID());
- resp.setRenderParameter("c", "" + addforum.getId());
- }
-
- /*try
- {
- resp.sendRedirect(addOrEditForumURL.toString());
- }
- catch (IOException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }*/
- }
- else if ("cat_order".equals(mode))
- {
- try
- {
- Category category = forumsModule.findCategoryById(req
- .getParameters().getIntObject(POST_CAT_URL));
- String[] test = new String[]{category.getTitle()};
- if (ForumsTools.hasPermission(req, test, "AdminCategory"))
- {
- OrderCategoryCommand cmd = new OrderCategoryCommand(req, resp);
- cmd.move = req.getParameters().getInt("move", 0);
- cmd.category = category;
- cmd.module = forumsModule;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_CATEGORIES_ORDERED)
- {
- addSuccessMessage(resp, "catorder", "Forums_updated");
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_ORDER_CATEGORIES)
- {
- addErrorMessage(resp, "catorder",
- "Can't change category order");
- return;
- }
- }
- else
- {
- addErrorMessage(resp, "catorder",
- "Not authorized to change the category order");
- return;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- addErrorMessage(resp, "catorder", "Couldn't order categories");
- return;
- }
- }
- else if ("addcat".equals(mode))
- {
- if (ForumsTools.hasPermission(req, "Admin"))
- {
- CreateCategoryCommand cmd = new CreateCategoryCommand(req, resp);
- cmd.name = req.getParameters().get("categoryname", "").trim();
- cmd.module = forumsModule;
- Result result;
- try
- {
- result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME)
- {
- addErrorMessage(resp, "addcat",
- "Can't create a category without a name");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED)
- {
- addErrorMessage(resp, "addcat",
- "Couldn't insert row in categories table");
- return;
- }
- else if (type == CommandConstants.TYPE_CATEGORY_CREATED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "addcat", "Forums_updated");
- }
- }
- catch (CommandException e1)
- {
- e1.printStackTrace();
- }
- }
- else
- {
- addErrorMessage(resp, "addcat", "Not authorized to add a category");
- return;
- }
- }
- else if ("createforum".equals(mode))
- {
- try
- {
- Category category = forumsModule.findCategoryById(req
- .getParameters().getIntObject(POST_CAT_URL));
- String[] test = new String[]{category.getTitle()};
- if (ForumsTools.hasPermission(req, test, "AdminCategory"))
- {
- CreateForumCommand cmd = new CreateForumCommand(req, resp);
- cmd.name = req.getParameters().get("forumname", "");
- cmd.description = req.getParameters().get("forumdesc", "")
- .trim();
- cmd.category = category;
- cmd.module = forumsModule;
-
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
-
- if (type == CommandConstants.TYPE_FORUM_CREATED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "addforum", "Forums_updated");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INVALID_NAME)
- {
- addErrorMessage(resp, "addforum", "Forum_missing_name");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY)
- {
- addErrorMessage(resp, "addforum", "Forum_missing_category");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED)
- {
- addErrorMessage(resp, "addforum", "Forum_failed");
- return;
- }
- }
- else
- {
- addErrorMessage(resp, "addforum", "Forum_not_authorized");
- return;
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
-
- // Die.exit(GENERAL_ERROR, "Couldn't get order number from forums table", e);
- }
-
- // if( $HTTP_POST_VARS['prune_enable'] )
- // {
- // if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "")
- // {
- // message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
- // }
- // $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
- // VALUES('" . $next_id . "', " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
- // if( !$result = $db->sql_query($sql) )
- // {
- // message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql);
- // }
- // }
- catch (CommandException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- else if ("forum_order".equals(mode))
- {
- try
- {
- Forum forum = forumsModule.findForumById(req.getParameters()
- .getIntObject("f"));
- String[] test = new String[]{forum.getCategory().getTitle()};
- if (ForumsTools.hasPermission(req, test, "AdminCategory"))
- {
- OrderForumCommand cmd = new OrderForumCommand(req, resp);
- cmd.module = forumsModule;
- cmd.forum = forum;
- cmd.move = req.getParameters().getIntObject("move", 0)
- .intValue();
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_FORUMS_ORDERED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "ordersuccess", "Forums_updated");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_ORDER_FORUMS)
- {
- addErrorMessage(resp, "orderfailed",
- "Couldn't change category order");
- return;
- }
- }
- else
- {
- addErrorMessage(resp, "forum",
- "Not authorized to change order in this category");
- return;
- }
- }
- catch (Exception e)
- {
- addErrorMessage(resp, "orderfailed",
- "Couldn't change category order");
- return;
- }
- }
- else if ("forum_sync".equals(mode))
- {
- // sync('forum', intval($HTTP_GET_VARS[POST_FORUM_URL]));
- // $show_index = TRUE;
- }
- else if ("deletecat".equals(mode))
- {
- try
- {
- Integer catId = req.getParameters().getIntObject(POST_CAT_URL);
- Category category = forumsModule.findCategoryById(catId);
- String selectTo = "";
- if (forumsModule.findCategories().size() == 1)
- {
- if (forumsModule.findForumsByCategoryId(catId).size() > 0)
- {
- addErrorMessage(resp, "deletecat", "Must_delete_forums");
- return;
- }
- else
- {
- selectTo = bundle.getString("Nowhere_to_move");
- }
- }
- else
- {
- selectTo = "<select name=\"to_id\">"
- + ForumsTools.listCategories(forumsModule.findCategories(), catId.intValue())
- + "</select>";
- }
-
- resp.setRenderParameter("op", OP_SHOWDELETEFORUM);
- resp.setRenderParameter("NAME", category.getTitle());
- resp.setRenderParameter("S_SELECT_TO", selectTo);
- resp
- .setRenderParameter("S_HIDDEN_FIELDS",
- "<input type=\"hidden\" name=\"mode\" value=\"movedelcat\"/>"
- + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
- + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>"
- + "<input type=\"hidden\" name=\"from_id\" value=\""
- + catId + "\"/>");
-
- /*
- DelegateContext root = new DelegateContext();
- root.put("NAME", category.getTitle());
- root.put("S_SELECT_TO", selectTo);
- root.put("S_HIDDEN_FIELDS", "<input type=\"hidden\" name=\"mode\" value=\"movedelcat\"/>" +
- "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
- "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>" +
- "<input type=\"hidden\" name=\"from_id\" value=\"" + catId + "\"/>");
- display(theme.TPL_THEME_ADMIN_FORUM_DELETE_BODY, root, page);
- */
- }
- catch (ModuleException e)
- {
- addErrorMessage(resp, "deletefailed", "Couldn't get Forum info");
- return;
- }
- }
- else if ("movedelcat".equals(mode))
- {
- try
- {
- Category fromCategory = forumsModule.findCategoryById(req
- .getParameters().getIntObject("from_id"));
- Category toCategory = forumsModule.findCategoryById(req
- .getParameters().getIntObject("to_id"));
- if (req.getParameters().getIntObject("from_id").equals(req.getParameters().getIntObject("to_id")))
- {
- addErrorMessage(resp, "deletecat", "cant_move_to_same_category");
- return;
- }
- String[] test1 = new String[]{fromCategory.getTitle()};
- String[] test2 = new String[]{toCategory.getTitle()};
- if ((ForumsTools.hasPermission(req, test1, "DeleteForumInCategory"))
- && (ForumsTools.hasPermission(req, test2, "AddForumInCategory")))
- {
- DeleteMoveCategoryCommand cmd = new DeleteMoveCategoryCommand(req, resp);
- cmd.source = fromCategory;
- cmd.target = toCategory; //null
- cmd.module = forumsModule;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_CANNOT_REMOVE_CATEGORY)
- {
- addErrorMessage(resp, "deletecategory",
- "Couldn't delete category");
- return;
- }
- else if (type == CommandConstants.TYPE_CATEGORY_REMOVED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "deletecategory", "Forums_updated");
- return;
- }
- }
- else
- {
- addErrorMessage(resp, "deletecategory",
- "You can't delete and move this category");
- return;
- }
- }
- catch (Exception e)
- {
- addErrorMessage(resp, "deletefailed", "Couldn't delete category");
- e.printStackTrace();
- return;
- }
- }
- else if ("deleteforum".equals(mode))
- {
- try
- {
- Integer forumId = req.getParameters().getIntObject("f");
- Forum forum = forumsModule.findForumById(forumId);
- resp.setRenderParameter("op", OP_SHOWDELETEFORUM);
- resp.setRenderParameter("NAME", forum.getName());
- resp
- .setRenderParameter("S_HIDDEN_FIELDS",
- "<input type=\"hidden\" name=\"mode\" value=\"movedelforum\"/>"
- + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
- + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>"
- + "<input type=\"hidden\" name=\"from_id\" value=\""
- + forum.getId() + "\"/>");
- resp.setRenderParameter("S_SELECT_TO",
- "<select name=\"to_id\"><option value=\"-1\">"
- + bundle.getString("Delete_all_posts")
- + "</option>\n" // $s
- + ForumsTools.listForums(forumsModule.findForums(),
- forumId.intValue()) + "</select>");
-
- // display(theme.TPL_THEME_ADMIN_FORUM_DELETE_BODY, root, page);
- }
- catch (ModuleException e)
- {
- addErrorMessage(resp, "deletefailed",
- "Could not obtain forum information");
- e.printStackTrace();
- return;
- }
- }
- else if ("movedelforum".equals(mode))
- {
- // int deleteOld = page.getParameterAsInt("delete_old", -1);
- try
- {
- Integer fromId = req.getParameters().getIntObject("from_id", -1);
- Forum fromForum = forumsModule.findForumById(fromId);
- Integer toId = req.getParameters().getIntObject("to_id", -1);
- if ((toId.intValue() < 0) && (fromId.intValue() >= 0))
- {
- String[] test = new String[]{
- fromForum.getCategory().getTitle(), fromForum.getName()};
- if (ForumsTools.hasPermission(req, test, "DeletePostInForum"))
- {
- //resp.setRenderParameter("op","" + OP_SHOWFORUM);
- DeleteForumCommand cmd = new DeleteForumCommand(req, resp);
- cmd.forum = fromForum;
- cmd.module = forumsModule;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_FORUM_REMOVED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "delete", "Forums_updated");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED)
- {
- addErrorMessage(resp, "delete", "Could not delete forum");
- }
- }
- }
- else if (!fromId.equals(toId) && (fromId.intValue() >= 0)
- && (toId.intValue() >= 0))
- {
- Forum toForum = forumsModule.findForumById(toId);
- String[] test1 = new String[]{
- fromForum.getCategory().getTitle(), fromForum.getName()};
- String[] test2 = new String[]{
- toForum.getCategory().getTitle(), toForum.getName()};
- if ((ForumsTools.hasPermission(req, test1, "DeletePostInForum"))
- && (ForumsTools.hasPermission(req, test2, "AddPostInForum")))
- {
- DeleteMoveForumCommand cmd = new DeleteMoveForumCommand(req, resp);
- cmd.source = fromForum;
- cmd.target = toForum;
- cmd.module = forumsModule;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_FORUM_MOVED_AND_REMOVED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "delete", "Forums_updated");
- return;
- }
- else if (type == CommandConstants.TYPE_CANNOT_MOVE_AND_REMOVE_FORUM)
- {
- addErrorMessage(resp, "delete", "Could not delete forum");
- return;
- }
-
- /*
- cmd.sourceId = fromId;
- cmd.targetId = toId;
- cmd.topicDataSource = topicDataSource;
- cmd.topicTableName = topicTableName;
- cmd.topicForumFKColumnName = topicForumRelationColumnName;
- cmd.postDataSource = postDataSource;
- cmd.postTableName = postTableName;
- cmd.postForumFKColumnName = postForumRelationColumnName;
- cmd.forumHome = homesRW.forum;
- cmd.postHome = homesRW.post;
- cmd.topicHome = homesRW.topic;
- Result result = forumsModule.invoke(req, resp, cmd);
- */
- }
- }
- else
- {
- addErrorMessage(resp, "delete", "Sorry but forums weren't updated... Check options you choose and try again");
- }
- }
- catch (Exception e)
- {
- addErrorMessage(resp, "delete", "Could not delete forum");
- e.printStackTrace();
- return;
- }
- }
- else if ("editcat".equals(mode))
- {
- try
- {
- Integer catId = req.getParameters().getIntObject(POST_CAT_URL);
- Category category = forumsModule.findCategoryById(catId);
- String hiddenFields = "<input type=\"hidden\" name=\"mode\" value=\"modcat\"/>"
- + "<input type=\"hidden\" name=\""
- + POST_CAT_URL
- + "\" value=\""
- + category.getId()
- + "\"/>"
- + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
- + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>";
- resp.setRenderParameter("op", OP_SHOWEDITCATEGORY);
- resp.setRenderParameter("c", "" + category.getId());
- resp.setRenderParameter("CAT_TITLE", category.getTitle());
- resp.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields);
-
- // display(theme.TPL_THEME_ADMIN_CATEGORY_EDIT_BODY, root, page);
- }
- catch (ModuleException e)
- {
- addErrorMessage(resp, "deletefailed", "Cannot edit category");
- e.printStackTrace();
- return;
- }
- }
- else if ("modcat".equals(mode))
- {
- try
- {
- Category category = forumsModule.findCategoryById(req
- .getParameters().getIntObject(POST_CAT_URL));
- String[] test = new String[]{category.getTitle()};
- if (ForumsTools.hasPermission(req, test, "EditCategory"))
- {
- UpdateCategoryCommand cmd = new UpdateCategoryCommand(req, resp);
- cmd.title = req.getParameters().get("cat_title", "").trim();
- cmd.category = category;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_CATEGORY_UPDATED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "update", "Forums_updated");
- return;
- }
- }
- }
- catch (Exception e)
- {
- addErrorMessage(resp, "update", "Cannot update category");
- e.printStackTrace();
- return;
- }
- }
- else if ("modforum".equals(mode))
- {
- // if( isset($HTTP_POST_VARS['prune_enable']))
- // {
- // if( $HTTP_POST_VARS['prune_enable'] != 1 )
- // {
- // $HTTP_POST_VARS['prune_enable'] = 0;
- // }
- // }
- try
- {
- Category category = forumsModule.findCategoryById(req
- .getParameters().getIntObject(POST_CAT_URL));
- Forum forum = forumsModule.findForumById(req.getParameters()
- .getIntObject("f"));
- String[] test1 = new String[]{category.getTitle(),};
- String[] test2 = new String[]{forum.getCategory().getTitle(),};
- if ((ForumsTools.hasPermission(req, test1, "AddForumInCategory"))
- && (ForumsTools.hasPermission(req, test2, "EditForumInCategory")))
- {
- UpdateForumCommand cmd = new UpdateForumCommand(req, resp);
- cmd.name = req.getParameters().get("forumname", "");
- cmd.description = req.getParameters().get("forumdesc", "");
- cmd.category = category;
- cmd.forum = forum;
- Result result = forumsModule.invoke(cmd);
- ResultType type = result.getType();
- if (type == CommandConstants.TYPE_FORUM_UPDATED)
- {
- resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
- addSuccessMessage(resp, "edit", "Forums_updated");
- return;
- }
- }
- addErrorMessage(resp, "edit", "Cannot update forums");
-
- // forum_status = intval($HTTP_POST_VARS['forumstatus'])
- // prune_enable = intval($HTTP_POST_VARS['prune_enable']
- }
- catch (Exception e)
- {
- addErrorMessage(resp, "edit", "Couldn't update forum information");
- e.printStackTrace();
- return;
- }
-
- // if( $HTTP_POST_VARS['prune_enable'] == 1 )
- // {
- // if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "" )
- // {
- // message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
- // }
- // $sql = "SELECT *
- // FROM " . PRUNE_TABLE . "
- // WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
- // if( !$result = $db->sql_query($sql) )
- // {
- // message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql);
- // }
- // if( $db->sql_numrows($result) > 0 )
- // {
- // $sql = "UPDATE " . PRUNE_TABLE . "
- // SET prune_days = " . intval($HTTP_POST_VARS['prune_days']) . ", prune_freq = " . intval($HTTP_POST_VARS['prune_freq']) . "
- // WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
- // }
- // else
- // {
- // $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
- // VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
- // }
- // if( !$result = $db->sql_query($sql) )
- // {
- // message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql);
- // }
- // }
- // Die.exit(GENERAL_MESSAGE, "${bb.Forums_updated}<br/><br/>${bb.Click_return_forumadmin_0}<a href=\"" +
- // "index.html?module=bb&op=admin_forums\">${bb.Click_return_forumadmin_1}</a>" +
- // "${bb.Click_return_forumadmin_2}<br/><br/>${bb.Click_return_admin_index_0}" +
- // "<a href=\"index.html?module=bb&pane=right\">${bb.Click_return_admin_index_1}</a>" +
- // "${bb.Click_return_admin_index_2}");
- }
- }
-
- private DelegateContext fillShowIndexContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- Integer c = req.getParameters().getIntObject("c", -1);
- try
- {
- if (c.intValue() != -1)
- {
- Category category = forumsModule.findCategoryById(c);
- fillShowCategoryContext(req, resp, root, category);
- }
- else
- {
- // Fill context with categories
- Iterator iterator = forumsModule.findCategories().iterator();
- while (iterator.hasNext())
- {
- Category currentCategory = (Category)iterator.next();
-
- fillShowCategoryContext(req, resp, root, currentCategory);
- }
- }
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return root;
- }
-
- private DelegateContext fillShowCategoryContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root, Category category)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
- try
- {
- String[] testArray = new String[]{category.getTitle()};
-
- boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadCategory");
-
- if (authRead)
- {
- DelegateContext catrow = root.next("catrow");
- catrow.put("CAT_DESC", category.getTitle());
- PortletURL viewCatURL = resp.createRenderURL();
- viewCatURL.setParameter("op", OP_MAIN);
- viewCatURL.setParameter("c", "" + category.getId());
- catrow.put("U_VIEWCAT", viewCatURL.toString());
-
- // Fill context with forums
- Iterator forumsIterator = forumsModule.findForumsByCategoryId(category.getId()).iterator();
- while (forumsIterator.hasNext())
- {
- Forum currentForum = (Forum)forumsIterator.next();
- Integer currentCategoryId = category.getId();
- String currentCategoryTitle = category.getTitle();
- String currentForumName = currentForum.getName();
- testArray = new String[]{currentCategoryTitle,
- currentForumName};
-
- authRead = ForumsTools.hasPermission(req, testArray, "ReadForum");
- boolean authView = authRead;
-
- // We display the forum only if needed
- if (authView)
- {
- // Get forum data
- int currentForumStatus = currentForum.getStatus();
- Integer currentForumId = currentForum.getId();
- Post lastPost = forumsModule.findLastPost(currentForum);
- String currentForumDescription = currentForum
- .getDescription();
- int currentForumPostSize = currentForum.getPostCount();
- int currentForumTopicSize = currentForum.getTopicCount();
- String folderImage = theme.resourceForumURL;
- String folderAlt = bundle.getString("No_new_posts");
- if (currentForumStatus == FORUM_LOCKED)
- {
- folderImage = theme.resourceForumLockedURL;
- folderAlt = bundle.getString("Forum_locked");
- }
-
- /*
- else
- {
- Date when1 = (Date)dates.get(currentForumId);
- Date when2 = (Date)trackingForums.get(currentForumId);
- if ((Time.compare(when1, when2) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0)
- {
- folderImage = theme.resourceForumNewBigURL;
- folderAlt = "${bb.New_posts}";
- }
- }
- */
-
- // Get the last post text
- String lastPostText = bundle.getString("No_Posts");
- if (lastPost != null)
- {
- Integer lastPostId = lastPost.getId();
- StringBuffer temp = new StringBuffer();
- Date lastPostDate = lastPost.getCreateDate();
-
- // temp.append(dateFormatPool.formatDate(lastPostDate)).append("<br/>");
- // temp.append(lastPost.getPoster().getAuthor(true));
- SimpleDateFormat sdf = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
- //temp.append(lastPostDate).append("<br/>");
- temp.append(sdf.format(lastPostDate)).append("<br/>");
- if ((req.getRemoteUser() != null))
- {
- PortletURL userProfileURL = resp.createRenderURL();
- userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
- userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
- temp.append("<a href=\"" + userProfileURL.toString() + "\">" + lastPost.getPoster().getUser().getUserName() + "</a>");
- }
- else
- {
- temp.append(lastPost.getPoster().getUser().getUserName());
- }
- PortletURL postURL = resp.createRenderURL();
- postURL.setParameter("op", OP_SHOWTOPIC);
- postURL.setParameter("p", "" + lastPostId);
- temp.append("<a href=\"").append(postURL.toString())
- .append("\"><img src=\"").append(theme.resourceIconLatestReplyURL).append("\" border=\"0\" alt=\""
- + bundle.getString("View_latest_post")
- + "\" title=\""
- + bundle.getString("View_latest_post")
- + "\"/></a>");
- lastPostText = temp.toString();
- }
-
- // Fetch the moderator list
- String moderatorList = " ";
- String moderatorsMessage = " ";
-
- /*
- Set moderators = moderators(currentCategoryTitle, currentForumName);
- if (moderators.size() > 0)
- {
- StringBuffer temp = new StringBuffer();
- for (Iterator j = moderators.iterator();j.hasNext();temp.append(j.hasNext() ? "," : ""))
- {
- temp.append(j.next());
- }
- moderatorList = temp.toString();
- moderatorsMessage = moderators.size() == 1 ? "${bb.Moderator}" : "${bb.Moderators}";
- }
- */
-
- // Build the template
- DelegateContext forumrow = catrow.next("forumrow");
-
- /* forumrow.put("ROW_COLOR", theme.getProperty(i.getIndex() % 2 == 0 ? "td_color1" : "td_color2"));
- forumrow.put("ROW_CLASS", theme.getProperty(i.getIndex() % 2 == 0 ? "td_class1" : "td_class2"));
- */
- forumrow.put("FORUM_FOLDER_IMG", folderImage);
- forumrow.put("FORUM_NAME", currentForumName);
- forumrow.put("FORUM_DESC", currentForumDescription);
- forumrow.put("POSTS", "" + currentForumPostSize);
- forumrow.put("TOPICS", "" + currentForumTopicSize);
- forumrow.put("LAST_POST", lastPostText);
- forumrow.put("MODERATORS", moderatorList);
- forumrow.put("L_MODERATOR", moderatorsMessage);
- forumrow.put("L_FORUM_FOLDER_ALT", folderAlt);
- PortletURL viewForumURL = resp.createRenderURL();
- viewForumURL.setParameter("op", OP_SHOWFORUM);
- viewForumURL.setParameter("f", currentForumId.toString());
- forumrow.put("U_VIEWFORUM", viewForumURL.toString());
- }
- }
- }
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return root;
- }
-
- private DelegateContext fillShowForumContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- // JBossPortletPreferences prefs =
- // new JBossPortletPreferences(null,
- // req.getUser().getPreferenceStore().get(new FQN("org.jboss.portlet.forums")),
- // null, PortletPreferencesImpl.RENDER, proxyInfo);
- // PreferencesProxy proxy = (PreferencesProxy) prefs.getProxy();
-
- /*int topicsPerPage = 10;*/
- int topicsPerPage = Integer.parseInt(req.getPreferences().getValue("topicsperforum", "10"));
- int hotThreshold = 10;
- /*int postsPerPage = 10;*/
- int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
-
-
- Integer forumId = req.getParameters().getIntObject("f", -1);
- int start = req.getParameters().getInt("start", 0);
-
- // String markRead = page.getParameter("mark", "");
- int topicDays = req.getParameters().getInt("topicdays", 0);
-
- Forum forum = null;
- try
- {
- forum = forumsModule.findForumById(forumId);
- }
- catch (ModuleException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- Category category = forum.getCategory();
- User user = req.getUser();
- //boolean loggedIn = isUserLoggedIn(user);
- boolean loggedIn = req.getRemoteUser() != null;
- Date lastVisit = loggedIn ? user.getLastVisitDate() : null;
- String categoryTitle = category.getTitle();
- String forumName = forum.getName();
-
- // Level level = secGetLevel(categoryTitle + ":" + forumName + ":");
- // Auth auth = forum.getAuth();
- //TODO: add security here
- String[] testArray = new String[]{categoryTitle, forumName};
- boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadForum"); //auth.can(Auth.TYPE_READ, loggedIn, level);
- boolean authView = ForumsTools.hasPermission(req, testArray, "ReadForum"); //auth.can(Auth.TYPE_VIEW, loggedIn, level);
- boolean authPost = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
- boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum"); //Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
-
- if (authPost)
- {
- root.next("AUTH_POST");
- }
-
- if (!authRead || !authView)
- {
- System.out.println("You are not authorized to see this forum");
- return root;
-
- /*
- if (!loggedIn)
- {
- // $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
- // redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
- // page.sendRedirect("index.html?module=user&op=getlogin");
- // return root;
- }
- Die.exit(GENERAL_MESSAGE, !authView ? "${bb.Forum_not_exist}" : "sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type'])");
- */
- }
-
- /*
- if ("topics".equals(markRead) && loggedIn)
- {
- PostEJBLocal lastPost = forum.getLastPost();
- if (lastPost != null)
- {
- if (lastPost.getPostDate().after(lastVisit))
- {
- getTrackingForums(page).put(forumId, new Date());
- }
- }
- Die.exit(GENERAL_MESSAGE, "${bb.Topics_marked_read}<br/><br/>" +
- "${bb.Click_return_forum_0}<a href=\"index.html?module=bb&op=viewforum&f=" +
- forumId + "\">${bb.Click_return_forum_1}</a>" +
- "${bb.Click_return_forum_2}");
- }
- if (authMod && pruneEnable)
- {
- // if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
- // {
- // include($phpbb_root_path . 'includes/prune.'.$phpEx);
- // require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
- // auto_prune($forum_id);
- // }
- }
- // todo put that in statistics
- Set moderators = moderators(categoryTitle, forumName);
- String moderatorMessage = "${bb.Moderators}";
- String moderatorList = "${bb.None}";
- if (moderators.size() > 0)
- {
- StringBuffer temp = new StringBuffer();
- if (moderators.size() == 1)
- {
- moderatorMessage = "${bb.Moderator}";
- }
- for (Iterator iterator = moderators.iterator();iterator.hasNext();)
- {
- temp.append((String)iterator.next());
- if (iterator.hasNext())
- {
- temp.append(", ");
- }
- }
- moderatorList = temp.toString();
- }
- // int topicCount = 0;
- */
- Date minTopicTime = null;
- if (topicDays > 0)
- {
- Calendar c = Calendar.getInstance();
- c.add(Calendar.DATE, -topicDays);
- minTopicTime = c.getTime();
-
- // Collection temp = null;
- // try
- // {
- // temp = homes.topic.selectGeneric("SELECT t.id FROM topic AS t WHERE t.forum=?1 AND t.lastPost.postDate>=?2",
- // new Object[]{forum, minTopicTime});
- // }
- // catch(FinderException e)
- // {
- // Die.exit(GENERAL_ERROR, "Could not obtain limited topics count information");
- // }
- // topicCount = temp.size();
- }
- else
- {
- // topicCount = forum.getTopicSize();
- topicDays = 0;
- }
-
- List announcements = null;
- List topics = null;
-
- try
- {
- announcements = forumsModule.findAnnouncements(forum);
- topics = (minTopicTime == null) ? forumsModule.findTopicsDesc(forum,
- POST_ANNOUNCE, start, topicsPerPage) : forumsModule
- .findTopicsBefore(forum, POST_ANNOUNCE, start, topicsPerPage,
- minTopicTime);
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- int totalAnnoucements = announcements.size();
- int totalTopicsAndStickies = forum.getTopicCount();
- int totalTopics = totalTopicsAndStickies; // + totalAnnoucements;
-
- StringBuffer authCan = new StringBuffer();
- //Prapare permission info
- //authCan.append(authMod ? bundle.getString("Rules_moderate_0") : bundle.getString("Rules_moderate_0"));
-
- //authCan = new StringBuffer();
-
- //generate "You can..." forum permissions description
- ForumsTools.authCan(authCan, req, testArray, bundle);
- //Moderator permission is described separately
- PortletURL moderateURL = resp.createRenderURL();
- moderateURL.setParameter(getOperationName(), OP_SHOWMODERATEFORUM);
- moderateURL.setParameter("f", "" + forumId);
- if (authMod)
- {
- authCan.append(bundle.getString("Rules_moderate_0")).
- append("<a href=\"" + moderateURL.toString() + "\">").
- append(bundle.getString("Rules_moderate_2")).
- append("</a><br/>");
- }
- else
- {
- authCan.append(bundle.getString("Rules_moderate_1")).
- append(bundle.getString("Rules_moderate_2")).
- append("<b/>");
- }
-
- Iterator ci = new CompoundIterator(new Iterator[]{
- announcements.iterator(), topics.iterator()});
-
- /*
- if (!ci.hasNext())
- {
- }
- */
-
- // if
- // No topics
- // $no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
- // $template->assign_vars(array(
- // 'L_NO_TOPICS' => $no_topics_msg)
- /*
- Map trackingForums = getTrackingForums(page);
- Map trackingTopics = getTrackingTopics(page);
- Date trackingAllForums = (Date)page.getSession().getAttribute(cookieName + "_f_all");
- */
- PortletURL gotoURL = resp.createRenderURL();
- gotoURL.setParameter("op", OP_SHOWTOPIC);
- Goto toPost = new Goto(postsPerPage, bundle.getString("Goto_page"), gotoURL.toString());
- toPost.setImgUrl(theme.resourceIconGotopostURL);
-
- for (IndexIterator iterator = IndexIterator.wrap(ci, -1); iterator
- .hasNext();)
- {
- Topic topic = (Topic)iterator.next();
-
- int replies = topic.getReplies();
- int status = topic.getStatus();
- /*Integer topicId = (status == TOPIC_MOVED) ? topic.getTarget().getID()
- : topic.getID();*/
- Integer topicId = topic.getId();
- String type = bundle.getString("Topic_Moved");
- String folderImage = theme.resourceFolderURL;
- String folderAlt = bundle.getString("Topic_Moved");
- String newestPostImg = "";
- Date topicLastPostDate = (topic.getLastPost() != null) ? topic.getLastPost().getCreateDate() : null;
- Post firstPost = topic.getFirstPost();
- Post lastPost = topic.getLastPost();
- Poster lastPostUser = lastPost.getPoster();
- Poster poster = topic.getPoster();
-
- if (status != TOPIC_MOVED)
- {
- FolderType folderType = theme.getFolderType(topic.getType(),
- status, replies >= hotThreshold);
- boolean newest = loggedIn; /* &&
- ((Time.compare(topicLastPostDate, lastVisit) & Time.LEFT_AFTER) != 0) &&
- ((Time.compare(topicLastPostDate, trackingAllForums) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0) &&
- ((Time.compare(topicLastPostDate, (Date)trackingTopics.get(topicId)) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0) &&
- ((Time.compare(topicLastPostDate, (Date)trackingForums.get(forumId)) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0);
- */
-
- if (newest)
- {
- folderImage = folderType.folderNew;
- folderAlt = (status == TOPIC_LOCKED) ? bundle
- .getString("Topic_locked") : bundle.getString("New_posts");
- newestPostImg = "<a href=\"index.html?module=bb&op=viewtopic&t="
- + topicId + "&view=newest\"><img src=\""
- + theme.resourceIconNewestReplyURL + "\" alt=\""
- + bundle.getString("View_newest_post") + "\" title=\""
- + bundle.getString("View_newest_post")
- + "\" border=\"0\"/></a>";
- }
- else
- {
- folderImage = folderType.folder;
- folderAlt = (status == TOPIC_LOCKED) ? bundle
- .getString("Topic_locked") : bundle
- .getString("No_new_posts");
- newestPostImg = "";
- }
-
- try
- {
- type = bundle.getString(folderType.type);
- }
- catch (java.util.MissingResourceException e)
- {
- type = "";
- }
-
- /*
- if (topic.getVote())
- {
- type += "${bb.Topic_Poll} ";
- }
- */
- }
-
- toPost.setPostSize(replies);
- toPost.setTopicId(topicId.intValue());
- String gotoPage = toPost.generate();
- String rowColor = theme
- .getProperty(((iterator.getIndex() % 2) == 0) ? "td_color1"
- : "td_color2");
- String rowClass = theme
- .getProperty(((iterator.getIndex() % 2) == 0) ? "td_class1"
- : "td_class2");
- String topicAuthor = firstPost.getPoster().getUser().getUserName();
- String lastPostAuthor = lastPost.getPoster().getUser().getUserName();
-
- PortletURL lastPostURL = resp.createRenderURL();
- lastPostURL.setParameter("op", OP_SHOWTOPIC);
- lastPostURL.setParameter("p", "" + lastPost.getId());
-
- String lastPostUrl = "<a href=\"" + lastPostURL.toString() + "\">"
- + "<img src=\"" + theme.resourceIconLatestReplyURL + "\" alt=\""
- + bundle.getString("View_latest_post") + "\" title=\""
- + bundle.getString("View_latest_post") + "\" border=\"0\"/></a>";
-
- DelegateContext topicrow = root.next("topicrow");
- topicrow.put("ROW_COLOR", rowColor);
- topicrow.put("ROW_CLASS", rowClass);
- topicrow.put("FORUM_ID", forumId.toString());
- topicrow.put("TOPIC_ID", topicId.toString());
- topicrow.put("TOPIC_FOLDER_IMG", folderImage);
- topicrow.put("TOPIC_AUTHOR", topicAuthor);
- topicrow.put("GOTO_PAGE", gotoPage);
- topicrow.put("REPLIES", "" + replies);
- //topicrow.put("NEWEST_POST_IMG", newestPostImg);
- topicrow.put("NEWEST_POST_IMG", lastPostUrl);
- topicrow.put("TOPIC_TITLE", formatTitle(req, topic.getSubject()));
- topicrow.put("TOPIC_TYPE", type);
- topicrow.put("VIEWS", "" + topic.getViewCount());
-
- // topicrow.put("FIRST_POST_TIME", dateFormatPool.formatDate(topic.getCreationDate()));
- /*topicrow.put("LAST_POST_TIME", topic.getLastPostDate().toString());*/
- SimpleDateFormat sdfp = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
- topicrow.put("LAST_POST_TIME", sdfp.format(topic.getLastPostDate()));
- if ((req.getRemoteUser() != null))
- {
- PortletURL userProfileURL = resp.createRenderURL();
- userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
- userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
- topicrow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
- }
- topicrow.put("LAST_POST_AUTHOR", lastPostAuthor);
- topicrow.put("LAST_POST_IMG", lastPostUrl);
- topicrow.put("L_TOPIC_FOLDER_ALT", folderAlt);
- PortletURL viewTopicURL = resp.createRenderURL();
- viewTopicURL.setParameter("op", OP_SHOWTOPIC);
- viewTopicURL.setParameter("t", "" + topicId);
- topicrow.put("U_VIEW_TOPIC", viewTopicURL.toString());
- }
-
- PortletURL pageNavigationURL = resp.createRenderURL();
- pageNavigationURL.setParameter("op", OP_SHOWFORUM);
- pageNavigationURL.setParameter("f", "" + forumId);
- pageNavigationURL.setParameter("topicDays", "" + topicDays);
-
- GotoWithOffset toTopic = new GotoWithOffset(totalTopicsAndStickies,
- start, topicsPerPage, pageNavigationURL + "&start=", bundle
- .getString("Goto_page"), bundle.getString("Previous"), bundle
- .getString("Next"));
-
- String pageNumber = bundle.getString("Page_of_0")
- + ((int)Math.floor((double)start / topicsPerPage) + 1)
- + bundle.getString("Page_of_1")
- + ((int)Math.ceil((double)totalTopicsAndStickies / topicsPerPage));
-
- PortletURL postNewURL = resp.createRenderURL();
- postNewURL.setParameter("op", OP_POSTING);
- postNewURL.setParameter("f", "" + forumId);
- postNewURL.setParameter("mode", "newtopic");
- root.put("U_POST_NEW_TOPIC", postNewURL.toString());
-
- // root.put("S_SELECT_TOPIC_DAYS", BBTools.selectDays("topicdays", topicDays));
- root.put("S_POST_DAYS_ACTION", "index.html?module=bb&op=viewforum&f="
- + forumId + "&start=" + start);
- root.put("FORUM_ID", forum.getId().toString());
- root.put("FORUM_NAME", forum.getName());
- root.put("CATEGORY_NAME", categoryTitle);
-
- // root.put("MODERATORS", moderatorList);
- root.put("POST_IMG",
- (forum.getStatus() == FORUM_LOCKED) ? theme.resourcePostLockedURL
- : theme.resourcePostNewURL);
- root.put("FOLDER_IMG", theme.resourceFolderURL);
- root.put("FOLDER_NEW_IMG", theme.resourceFolderNewURL);
- root.put("FOLDER_HOT_IMG", theme.resourceFolderHotURL);
- root.put("FOLDER_HOT_NEW_IMG", theme.resourceFolderHotNewURL);
- root.put("FOLDER_LOCKED_IMG", theme.resourceFolderLockedURL);
- root.put("FOLDER_LOCKED_NEW_IMG", theme.resourceFolderLockedNewURL);
- root.put("FOLDER_STICKY_IMG", theme.resourceFolderStickyURL);
- root.put("FOLDER_STICKY_NEW_IMG", theme.resourceFolderStickyNewURL);
- root.put("FOLDER_ANNOUNCE_IMG", theme.resourceFolderAnnounceURL);
- root.put("FOLDER_ANNOUNCE_NEW_IMG", theme.resourceFolderAnnounceNewURL);
-
- // root.put("L_MODERATOR", moderatorMessage);
- root.put("L_POST_NEW_TOPIC", (forum.getStatus() == FORUM_LOCKED) ? bundle
- .getString("Forum_locked") : bundle.getString("Post_new_topic"));
-
- root.put("S_AUTH_LIST", authCan.toString());
- PortletURL viewMainPageURL = resp.createRenderURL();
- viewMainPageURL.setParameter("op", OP_MAIN);
- root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
- root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
- PortletURL viewCategoryURL = resp.createRenderURL();
- viewCategoryURL.setParameter("op", OP_MAIN);
- viewCategoryURL.setParameter("c", "" + category.getId());
- root.put("U_VIEW_CATEGORY", viewCategoryURL.toString());
- PortletURL viewForumURL = resp.createRenderURL();
- viewForumURL.setParameter("op", OP_SHOWFORUM);
- viewForumURL.setParameter("f", "" + forumId);
- root.put("U_VIEW_FORUM", viewForumURL.toString());
- root.put("U_MARK_READ", "index.html?module=bb&op=viewforum&f=" + forumId
- + "&mark=topics");
- root.put("PAGE_NUMBER", pageNumber.toString());
- root.put("PAGINATION", toTopic.generate());
-
- // root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
- return root;
- }
-
- private DelegateContext fillShowPreferencesContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- try
- {
- PortletURL preferencesSubmitURL = resp.createActionURL();
- preferencesSubmitURL.setParameter("op", "preferences");
- //Go into view mode after submit
- preferencesSubmitURL.setPortletMode(PortletMode.VIEW);
- //process portlet.preferences() method on Submit
- root.put("S_PROFILE_ACTION", preferencesSubmitURL.toString());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- PortletPreferences pp = req.getPreferences();
- PropertyMap upm = req.getUser().getProperties();
- if (pp.getValue("notifyreply", "0").equals("1"))
- {
- root.put("NOTIFY_REPLY_YES", "CHECKED");
- }
- else
- {
- root.put("NOTIFY_REPLY_NO", "CHECKED");
- }
- /*if (pp.getValue("attachsig", "0").equals("1"))
- {
- root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
- }
- else
- {
- root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
- }*/
- String attachsig = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
- if ((attachsig != null) && attachsig.equals("1"))
- {
- root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
- }
- else if ((attachsig != null))
- {
- root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
- }
- else if ((attachsig == null))
- {
- root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
- }
-
- //TODO:Disable BBCode need to be implemented in ToHTMLRenderer --> BBCodeParser
- /*if (pp.getValue("allowbbcode", "0").equals("1")) {
- root.put("ALWAYS_ALLOW_BBCODE_YES", "CHECKED");
- } else {
- root.put("ALWAYS_ALLOW_BBCODE_NO", "CHECKED");
- }*/
- if (pp.getValue("allowhtml", "0").equals("1"))
- {
- root.put("ALWAYS_ALLOW_HTML_YES", "CHECKED");
- }
- else
- {
- root.put("ALWAYS_ALLOW_HTML_NO", "CHECKED");
- }
- if (pp.getValue("postorder", "ascending").equals("ascending"))
- {
- root.put("POST_ORDER_ASCENDING", "CHECKED");
- }
- else
- {
- root.put("POST_ORDER_DESCENDING", "CHECKED");
- }
- /*root.put("TOPICS_PER_FORUM", pp.getValue("topicsperforum", "10"));*/
- int topics = Integer.parseInt(pp.getValue("topicsperforum", "10"));
- switch (topics)
- {
- case 5:
- root.put("TOPICS_PER_FORUM_N5", "CHECKED");
- break;
- case 10:
- root.put("TOPICS_PER_FORUM_N10", "CHECKED");
- break;
- case 15:
- root.put("TOPICS_PER_FORUM_N15", "CHECKED");
- break;
- case 20:
- root.put("TOPICS_PER_FORUM_N20", "CHECKED");
- break;
- case 25:
- root.put("TOPICS_PER_FORUM_N25", "CHECKED");
- break;
- case 30:
- root.put("TOPICS_PER_FORUM_N30", "CHECKED");
- break;
- }
-
- /*root.put("POSTS_PER_TOPIC", pp.getValue("postspertopic", "15"));*/
- int posts = Integer.parseInt(pp.getValue("postspertopic", "10"));
- switch (posts)
- {
- case 5:
- root.put("POSTS_PER_TOPIC_N5", "CHECKED");
- break;
- case 10:
- root.put("POSTS_PER_TOPIC_N10", "CHECKED");
- break;
- case 15:
- root.put("POSTS_PER_TOPIC_N15", "CHECKED");
- break;
- case 20:
- root.put("POSTS_PER_TOPIC_N20", "CHECKED");
- break;
- case 25:
- root.put("POSTS_PER_TOPIC_N25", "CHECKED");
- break;
- case 30:
- root.put("POSTS_PER_TOPIC_N30", "CHECKED");
- break;
- }
-
- root.put("DATE_FORMAT", pp.getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN));
- //root.put("SIGNATURE", pp.getValue("signature", ""));
- String sig = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- root.put("SIGNATURE", (sig != null) ? sig : "");
-
- if (pp.isReadOnly("notifyreply"))
- {
- root.put("NOTIFY_ON_REPLY_DISABLED", "DISABLED");
- }
- /*if (pp.isReadOnly("attachsig"))
- root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");*/
- if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
- {
- root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");
- }
- /*if (pp.isReadOnly("allowbbcode"))
- root.put("ALWAYS_ALLOW_BBCODE_DISABLED", "DISABLED");*/
- if (pp.isReadOnly("allowhtml"))
- {
- root.put("ALWAYS_ALLOW_HTML_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("postorder"))
- {
- root.put("POST_ORDER_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("topicsperforum"))
- {
- root.put("TOPICS_PER_FORUM_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("postspertopic"))
- {
- root.put("POSTS_PER_TOPIC_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("dateformat"))
- {
- root.put("DATE_FORMAT_DISABLED", "DISABLED");
- }
- /*if (pp.isReadOnly("signature"))
- root.put("SIGNATURE_DISABLED", "DISABLED");*/
- if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
- {
- root.put("SIGNATURE_DISABLED", "DISABLED");
- }
-
- int summarymode = Integer.parseInt(pp.getValue("summarymode", "0"));
- switch (summarymode)
- {
- case 0:
- root.put("TOPIC_SUMMARY_MODE_LATEST_POSTS", "SELECTED");
- break;
- case 1:
- root.put("TOPIC_SUMMARY_MODE_HOT", "SELECTED");
- break;
- case 2:
- root.put("TOPIC_SUMMARY_MODE_HOTTEST", "SELECTED");
- break;
- case 3:
- root.put("TOPIC_SUMMARY_MODE_MOST_VIEWED", "SELECTED");
- break;
- }
- if (pp.isReadOnly("summarymode"))
- {
- root.put("MODE_CHOOSE_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("summarytopiclimit"))
- {
- root.put("TOPIC_SUMMARY_LIMIT_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("summarytopicdays"))
- {
- root.put("TOPIC_SUMMARY_DAYS_DISABLED", "DISABLED");
- }
- if (pp.isReadOnly("summarytopicreplies"))
- {
- root.put("TOPIC_SUMMARY_REPLIES_DISABLED", "DISABLED");
- }
- root.put("TOPIC_SUMMARY_LIMIT", pp.getValue("summarytopiclimit", "6"));
- root.put("TOPIC_SUMMARY_DAYS", pp.getValue("summarytopicdays", "20"));
- root.put("TOPIC_SUMMARY_REPLIES", pp.getValue("summarytopicreplies", "5"));
- return root;
- }
-
-
- private DelegateContext fillShowUserProfileContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- User user = null;
- Poster poster = null;
- try
- {
- poster = forumsModule.findPosterByUserId(req.getParameters().get("uid", "-1"));
- user = poster.getUser();
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- return root;
- }
-
- PortletURL viewMainPageURL = resp.createRenderURL();
- viewMainPageURL.setParameter("op", OP_MAIN);
- root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
- root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
- root.put("USERNAME", user.getGivenName());
-
- //root.put("EMAIL_IMG", user.getFakeEmail());
- //String homepage = (String)(user.getProperties().get(CoreConstants.INFO_USER_HOMEPAGE));
- //root.put("WWW", "<a href=\"" + homepage + "\">"+ homepage + "</a>");
- root.put("LOCATION", (String)(user.getProperties().get(CoreConstants.INFO_USER_LOCATION)));
- root.put("OCCUPATION", (String)(user.getProperties().get(CoreConstants.INFO_USER_OCCUPATION)));
- root.put("INTERESTS", (String)(user.getProperties().get(CoreConstants.INFO_USER_INTERESTS)));
-
- //root.put("ICQ_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_ICQ)));
- //root.put("AIM_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_AIM)));
- //root.put("YIM_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_YIM)));
- root.put("MSN_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_MSNM)));
- root.put("SKYPE_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_SKYPE)));
-
- root.put("JOINED", "" + user.getRegistrationDate());
- root.put("POSTS", "" + poster.getPostCount());
-
-
- String fakeEmail = user.getFakeEmail();
- String homepage = (String)(user.getProperties().get(CoreConstants.INFO_USER_HOMEPAGE));
- String icqAddr = (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_ICQ));
- String aimAddr = (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_AIM));
- String yimAddr = (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_YIM));
-
-
- if (fakeEmail != null && fakeEmail.length() > 0)
- {
- String emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
- root.put("EMAIL_IMG", emailImgLnk);
- }
- if (homepage != null && homepage.length() > 0)
- {
- String wwwImgLnk = ForumsTools.createImageLink(homepage, theme.resourceIconWWWURL, "");
- root.put("WWW", wwwImgLnk);
- }
- String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + icqAddr;
- if (icqAddr != null && icqAddr.length() > 0)
- {
- String icqImgLnk = ForumsTools.createImageLink(icqUrl, theme.resourceIconICQURL, "");
- root.put("ICQ_IMG", icqImgLnk);
- }
- String aimUrl = "aim:goim?screenname=" + aimAddr + "&message=Hello+Are+you+there?";
- if (aimAddr != null && aimAddr.length() > 0)
- {
- String aimImgLnk = ForumsTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "");
- root.put("AIM_IMG", aimImgLnk);
- }
- String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + yimAddr + "&src=pg";
- if (yimAddr != null && yimAddr.length() > 0)
- {
- String yimImgLnk = ForumsTools.createImageLink(yimUrl.toString(), theme.resourceIconYIMURL, "");
- root.put("YIM_IMG", yimAddr);
- }
-
- return root;
- }
-
-
- private DelegateContext fillShowBlockTopicsContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- //System.out.println("in fillShowNewTopicContext(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
- ResourceBundle bundle = getResourceBundle(req.getLocale());
- PortletPreferences pp = req.getPreferences();
- //int mode = ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS;
- PortletURL viewMainPageURL = resp.createRenderURL();
- viewMainPageURL.setParameter("op", OP_MAIN);
- try
- {
- viewMainPageURL.setWindowState(WindowState.MAXIMIZED);
- }
- catch (WindowStateException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
- root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
- int mode = ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS;
- int limit = 6;
- int replies = 15;
- int days = 20;
- try
- {
- mode = new Integer(pp.getValue("summarymode", "0")).intValue();
- limit = new Integer(pp.getValue("summarytopiclimit", "6")).intValue();
- days = new Integer(pp.getValue("summarytopicdays", "20")).intValue();
- replies = new Integer(pp.getValue("summarytopicreplies", "5")).intValue();
- }
- catch (IllegalArgumentException e)
- {
- System.out.println("ERROR -- Illegal value of summary topic properties");
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- Calendar after = Calendar.getInstance();
- after.add(Calendar.DATE, - days);
- Collection topics = new LinkedList();
- Date time = after.getTime();
-
- try
- {
- switch (mode)
- {
- case ForumsConstants.BLOCK_TOPICS_MODE_HOT_TOPICS:
- root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_HOT_TOPICS"));
- topics = forumsModule.findTopicsHot(replies, limit);
- break;
- case ForumsConstants.BLOCK_TOPICS_MODE_HOTTEST_TOPICS:
- root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_HOTTEST_TOPICS"));
- topics = forumsModule.findTopicsHottest(time, limit);
- break;
- case ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS:
- root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_LATEST_POSTS"));
- topics = forumsModule.findTopicsByLatestPosts(limit);
- break;
- case ForumsConstants.BLOCK_TOPICS_MODE_MOST_VIEWED:
- root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_MOST_VIEWED"));
- topics = forumsModule.findTopicsMostViewed(time, limit);
- break;
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- //DelegateContext root = new DelegateContext();
- root.next("switch_no_topics").put("L_NO_TOPICS", topics.size() + " " + bundle.getString("L_TOPICS_FOUND"));
-
- if (topics.size() > 0)
- {
- for (Iterator i = topics.iterator(); i.hasNext();)
- {
- //TopicEJBLocal topic = (TopicEJBLocal)i.next();
- Topic topic = (Topic)i.next();
- DelegateContext topicrow = root.next("topicrow");
- topicrow.put("TOPIC_TITLE", topic.getSubject());
- PortletURL topicViewURL = resp.createRenderURL();
- try
- {
- topicViewURL.setWindowState(WindowState.MAXIMIZED);
- }
- catch (WindowStateException e)
- {
- e.printStackTrace();
- }
- topicViewURL.setParameter("op", "showTopic");
- topicViewURL.setParameter("t", "" + topic.getId());
- topicrow.put("U_VIEW_TOPIC", topicViewURL.toString());
- }
- }
- /*else
- {
- root.next("switch_no_topics");
- }*/
-
- /*root.put("BLOCK_TOPICS_TYPE","Newest topics");
- for (int i = 0; i<4; i++){
- DelegateContext topicrow = root.next("topicrow");
- topicrow.put("TOPIC_TITLE", "topic name " + i);
- }*/
-
-
-
-
- return root;
- }
-
-
- private DelegateContext fillShowNewTopicContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- //System.out.println("in fillShowNewTopicContext(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
- PortletURL topicSubmitURL = resp.createActionURL();
- topicSubmitURL.setParameter("op", "posting");
- String forumId = req.getParameter("f");
- if (forumId != null)
- {
- topicSubmitURL.setParameter("f", forumId);
- }
- String postId = req.getParameter("p");
- if (postId != null)
- {
- topicSubmitURL.setParameter("p", postId);
- }
-
- boolean isPostBack = false;
- //check if we display for the first time or if it's postback
- //postback flag is set in posting() method so we can deal with first display of this view.
- if (req.getParameter(ForumsConstants.POSTING_POSTBACK_FLAG) != null)
- {
- isPostBack = true;
- }
- else
- {
- //clear stored files from session
- req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, null);
- }
-
-
- if (req.getParameter("S_HIDDEN_FORM_FIELDS") != null)
- {
- root.put("S_HIDDEN_FORM_FIELDS", req
- .getParameter("S_HIDDEN_FORM_FIELDS"));
- }
- else
- {
- root.put("S_HIDDEN_FORM_FIELDS",
- "<input type=\"hidden\" name=\"mode\" value=\""
- + req.getParameter("mode") + "\" />"
- + "<input type=\"hidden\" name=\"iteratingtest\" value=\"val1\" /><input type=\"hidden\" name=\"iteratingtest\" value=\"val2\" /><input type=\"hidden\" name=\"iteratingtest\" value=\"val3\" />");
- }
-
-
- root.put("U_FORM_SUBMIT", topicSubmitURL.toString());
- root.put("S_FORM_ENCTYPE", "enctype=\"multipart/form-data\"");
-
- String instantReplyHiddenFormFields = "<input type=\"hidden\" name=\"attach_sig\" value=\"-1\"/>\n";
- root.put("S_INSTANT_REPLY_HIDDEN_FORM_FIELDS",
- instantReplyHiddenFormFields);
-
- if (req.getParameters().getParameterExists("preview"))
- {
- PropertyMap upm = req.getUser().getProperties();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-
- DelegateContext preview = root.next("preview");
- preview.put("PREVIEW_SUBJECT", req.getParameter("PREVIEW_SUBJECT"));
- preview.put("TOPIC_TITLE", req.getParameter("TOPIC_TITLE"));
- preview.put("POSTER_NAME", req.getParameter("POSTER_NAME"));
- preview.put("POST_DATE", req.getParameter("POST_DATE"));
- preview.put("PREVIEW_MESSAGE", req.getParameter("PREVIEW_MESSAGE"));
- }
-
- root.put("SUBJECT", req.getParameter("SUBJECT"));
- root.put("MESSAGE", req.getParameter("MESSAGE"));
- //root.next("switch_notify_checkbox");
- //root.put("S_NOTIFY_CHECKED", "checked");
-
- Forum forum = null;
- try
- {
- Integer tmp = req.getParameters().getIntObject("f");
- forum = forumsModule.findForumById(tmp);
- }
- catch (ModuleException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- Category category = forum.getCategory();
- String forumName = forum.getName();
- String[] testArray = new String[]{category.getTitle(), forum.getName()};
- boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum"); //Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
- boolean authAddAttach = ForumsTools.hasPermission(req, testArray, "AddAttachmentInPost");
- boolean authAddPoll = ForumsTools.hasPermission(req, testArray, "AddPollInPost");
- boolean authEditPoll = ForumsTools.hasPermission(req, testArray, "EditPollInPost");
-
- if (authMod)
- {
- root.next("auth_mod");
-
- }
-
- /*if (authAddAttach)
- {
- root.next("attachmentsEnabled");
- }*/
-
- //System.out.println("title from req: " + req.getParameter("POLL_TITLE"));
- /*if (ForumsTools.hasPermission(req,"AddPollInPost"))
- {
- System.out.println("Enabling poll body");
- DelegateContext poll = root.next("pollEnabled");
- poll.put("POLL_TITLE", req.getParameter("POLL_TITLE"));
-
- }
- */
- boolean newTopic = false;
- if ((req.getParameter("mode") != null) && req.getParameter("mode").equals("newtopic"))
- {
- newTopic = true;
- }
- boolean firstTopicPost = false;
- if ((req.getParameter("firstTopicPost") != null) && req.getParameter("firstTopicPost").equals("true"))
- {
- firstTopicPost = true;
- }
-
-
- if (authMod && (newTopic || firstTopicPost))
- {
- DelegateContext tt = root.next("switch_type_toggle");
- String type = req.getParameter("topictype");
- if (type != null)
- {
- if (type.equals("0"))
- {
- root.put("TOPIC_TYPE_NORMAL", "CHECKED");
- }
- else if (type.equals("1"))
- {
- root.put("TOPIC_TYPE_STICKY", "CHECKED");
- }
- else if (type.equals("2"))
- {
- root.put("TOPIC_TYPE_ANNOUNCEMENT", "CHECKED");
- }
-
- }
- else
- {
- root.put("TOPIC_TYPE_NORMAL", "CHECKED");
- }
- }
-
- if ((ForumsTools.hasPermission(req, "AddPollInPost") && newTopic) ||
- (ForumsTools.hasPermission(req, "EditPollInPost") && (req.getParameter("editPoll") != null) &&
- req.getParameter("editPoll").equals("true")))
- {
- DelegateContext poll = root.next("pollEnabled");
- poll.put("POLL_TITLE", req.getParameter("POLL_TITLE"));
- poll.put("POLL_LENGTH", req.getParameter("POLL_LENGTH"));
- if (ForumsTools.hasPermission(req, "EditPostInForum") &&
- (req.getParameter("switch_poll_delete_toggle") != null)
- )
- {
- poll.next("switch_poll_delete_toggle");
- }
- /*response.setRenderParameter("POLL_TITLE", poll.getTitle());
- response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));*/
- /*if (action instanceof EditPostAction)
- {
- response.setRenderParameter("switch_poll_delete_toggle", "true");
- //root.next("switch_poll_delete_toggle");
- }*/
- /*int index = 0;
- for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
- {
- String text = (String) iterator.next();
- if (text != null)
- {
- DelegateContext poll_option_rows = root.next("poll_option_rows");
- poll_option_rows.put("POLL_OPTION", text);
- poll_option_rows.put("S_POLL_OPTION_NUM", "" + index++);
- }
- }*/
- //boolean option_deleted = false;
-
- for (int index = 0; true; index++)
- {
- String param = "poll_option_text[" + index + "]";
- String value = req.getParameter(param);
- if (value != null)
- {
- DelegateContext poll_option_rows = poll.next("poll_option_rows");
- poll_option_rows.put("POLL_OPTION", value);
- poll_option_rows.put("S_POLL_OPTION_NUM", "" + index);
- }
- else
- {
- break;
- }
-
- /* boolean deleted = req.getParameter("del_poll_option[" + index + "]") != null;
- option_deleted |= deleted;*/
- /*if(value != null)
- {
- p_poll.getOptions().add(deleted ? null : value);
- }
- else
- {
- break;
- }*/
- }
- //pollBox = theme.TPL_THEME_POSTING_POLL_BODY.render(temp);
- }
-
- if (authAddAttach)
- {
- DelegateContext attach = root.next("attachmentsEnabled");
-
- for (int i = 0; ; i++)
- {
-
- String name = req.getParameter("ATTACHMENT[" + i + "]_NAME");
- String id = req.getParameter("ATTACHMENT[" + i + "]_ID");
- String comment = req.getParameter("ATTACHMENT[" + i + "]_COMMENT");
- if ((name != null) && (id != null))
- {
- DelegateContext row = attach.next("attach_row");
- row.put("ATTACH_FILENAME", name);
- row.put("ATTACH_ID", id);
- row.put("FILE_COMMENT", comment);
- }
- else
- {
- break;
- }
- }
- }
-
-
- return root;
- }
-
- private DelegateContext fillShowSplitTopicContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- Integer topicId = req.getParameters().getIntObject("t", -1);
- Integer forumId = req.getParameters().getIntObject("f", -1);
-
- /*resp.setProperty("t", "" + topicId);
- resp.setProperty("f", "" + forumId);*/
- if (topicId.intValue() == -1)
- {
- return root;
- }
- //TODO: index on top of page is not used now...
- Topic topic = null;
- List posts = null;
- try
- {
- topic = forumsModule.findTopicById(topicId);
- posts = forumsModule.findPostsByTopicId(topicId);
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- //TODO:some nice error message
- return root;
- }
-
- // form action
- PortletURL actionURL = resp.createActionURL();
- actionURL.setParameter(getOperationName(), "moderate_forum");
- actionURL.setParameter("t", "" + topicId);
- actionURL.setParameter("f", "" + forumId);
- root.put("S_SPLIT_ACTION", actionURL.toString());
-
- //Main index link
- PortletURL indexURL = resp.createActionURL();
- indexURL.setParameter(getOperationName(), OP_MAIN);
- root.put("U_INDEX", indexURL.toString());
-
- //This topics forum index
- PortletURL forumURL = resp.createActionURL();
- forumURL.setParameter(getOperationName(), OP_SHOWFORUM);
- forumURL.setParameter("f", "" + topic.getForum().getId());
- root.put("U_VIEW_FORUM", forumURL.toString());
- root.put("FORUM_NAME", topic.getForum().getName());
-
-
- int rowindex = 0;
- for (IndexIterator pi = IndexIterator.wrap(posts.iterator(), -1); pi.hasNext(); rowindex++)
- {
- Post post = (Post)pi.next();
- String rowColor = theme
- .getProperty(((pi.getIndex() % 2) == 0) ? "td_color1"
- : "td_color2");
- String rowClass = theme
- .getProperty(((pi.getIndex() % 2) == 0) ? "td_class1"
- : "td_class2");
-
- DelegateContext postRow = root.next("postrow");
-
- postRow.put("ROW_COLOR", rowColor);
- postRow.put("ROW_CLASS", rowClass);
- postRow.put("POSTER_NAME", post.getPoster().getUser().getUserName());
- postRow.put("POST_DATE", getSDF(req).format(post.getCreateDate()));
- postRow.put("POST_SUBJECT", post.getMessage().getSubject());
- String message = post.getMessage().getText();
- PropertyMap upm = post.getPoster().getUser().getProperties();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
- if ((addsign != null) && (sign != null) && addsign.equals("1"))
- {
- message += "\n\n" + sign;
- }
- postRow.put("MESSAGE", formatMessage(req, message, true, true));
- postRow.put("POST_ROW_INDEX", "" + rowindex);
- postRow.put("POST_ID", post.getId());
- postRow.put("IMG_MINIPOST", theme.resourceIconMinipostURL);
- //TODO:this spacer link is corrupted
- postRow.put("IMG_SPACER", theme.resourceIconSpacerURL);
- }
-
- try
- {
- String selectTo = new StringBuffer().
- append("<select name=\"forum_to_id\">").
- append("<option value=\"-1\"").
- append(" selected=\"selected\">").
- append("Select destination forum").append("</option>\n").
- append(ForumsTools.listForums(forumsModule.findForums(), -1)).
- append("</select>").toString();
- root.put("S_FORUM_SELECT", selectTo);
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
-
- return root;
- }
-
- private DelegateContext fillShowTopicContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- Integer topicId = req.getParameters().getIntObject("t", -1);
- Integer postId = req.getParameters().getIntObject("p", -1);
- int start = req.getParameters().getInt("start", 0);
- String view = req.getParameter("view");
- int postDays = req.getParameters().getInt("postdays", 0);
- String vote = req.getParameter("vote");
-
- if ((topicId.intValue() == -1) && (postId.intValue() == -1))
- {
- // Die.exit(GENERAL_MESSAGE, "${bb.Topic_post_not_exist}");
- }
-
- Topic topic = null;
- Forum forum = null;
- Category category = null;
- User user = req.getUser();
- //boolean loggedIn = isUserLoggedIn(user);
- boolean loggedIn = req.getRemoteUser() != null;
-
- // try
- // {
- if (postId.intValue() == -1)
- {
- if (view != null)
- {
- if ("newest".equals(view))
- {
- //if (isUserLoggedIn(user))
- if (req.getRemoteUser() != null)
- {
- // Date lastVisit = user.getPreviousLastVisitDate();
- Date lastVisit = user.getLastVisitDate();
- try
- {
- topic = forumsModule.findTopicById(topicId);
- Post post = topic.getLastPost();
-
- // homesRO.post.findLatestPost(lastVisit, topic);
- // resp. sendRedirect("index.html?module=bb&op=viewtopic&p=" + post.getID() + "#" + post.getID());
- return null;
- }
- catch (ModuleException e)
- {
- // Die.exit(GENERAL_MESSAGE, "${No_new_posts_last_visit}");
- }
- }
- else
- {
- // page.sendRedirect("index.html?module=bb&op=viewtopic&t=" + topicId);
- // return;
- }
- }
- else if ("next".equals(view))
- {
- /*
- try
- {
- topic = (TopicEJBLocal)BBTools.head(homesRO.topic.findNext(topicId));
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain newer/older topic information", e);
- }
- */
- }
- else if ("previous".equals(view))
- {
- /*
- try
- {
- topic = (TopicEJBLocal)BBTools.head(homesRO.topic.findPrevious(topicId));
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain newer/older topic information", e);
- }
- */
- }
-
- /*
- if (topic == null)
- {
- Die.exit(GENERAL_MESSAGE, "next".equals(view) ? "${bb.No_newer_topics}" : "${bb.No_older_topics}");
- }
- topicId = topic.getId();
- forum = topic.getForum();
- category = forum.getCategory();
- */
- }
- else
- // Common use case, showing the topic with topicID as is, no postId defined
- {
- try
- {
- topic = forumsModule.findTopicById(topicId);
- forum = topic.getForum();
- category = forum.getCategory();
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- else
- {
- Post post;
- try
- {
- post = forumsModule.findPostById(postId);
- topic = post.getTopic();
- forum = topic.getForum();
- category = forum.getCategory();
-
- // start = (int)(Math.floor(((double)(size.intValue() - 1) / postPerPage)) * postPerPage);
- topicId = topic.getId();
- }
- catch (ModuleException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- // Long size = homesRO.post.countPostsBefore(post);
- }
- // }
- // catch (ObjectNotFoundException e)
- // {
- // Die.exit(GENERAL_MESSAGE, "${bb.Topic_post_not_exist}");
- // }
- // catch (FinderException e)
- // {
- // Die.exit(GENERAL_ERROR, "Could not obtain topic information", e);
- // }
- String[] testArray = {category.getTitle(), forum.getName()};
- boolean authView = ForumsTools.hasPermission(req, testArray, "ReadForum");
- boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadForum");
- boolean authDelete = ForumsTools.hasPermission(req, testArray, "DeletePostInForum");
- boolean authPost = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
- boolean authVote = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
- boolean authEdit = ForumsTools.hasPermission(req, testArray, "EditPostInForum");
- boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum");
-
- if (authPost)
- {
- root.next("DISPLAY_REPLY_BOX");
- }
-
- // if (!authView || !authRead)
- // {
- if (loggedIn)
- {
- // $redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
- // $redirect .= ( isset($start) ) ? "&start=$start" : '';
- // redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
- // page.sendRedirect("index.html?module=user&=getlogin");
- // return;
- }
-
- // Die.exit(GENERAL_MESSAGE, !authView ? "${bb.Topic_post_not_exist}" : "${bb.Sorry_auth_read_0}TODO:$is_auth['auth_read_type']${bb.Sorry_auth_read_1}");
- // }
- Integer forumId = forum.getId();
- int forumStatus = forum.getStatus();
- int topicStatus = topic.getStatus();
- String forumName = forum.getName();
- String topicTitle = topic.getSubject();
-
- // Is user watching this thread ?
- boolean isWatching = false;
- boolean canWatch = false;
- if (loggedIn)
- {
- // try
- // {
- canWatch = true;
-
- /*
- try
- {
- TopicWatchEJBPK key = new TopicWatchEJBPK(user.getId(), topic.getId());
- TopicWatchEJBLocal watch = homesRO.topicWatch.findByPrimaryKey(key);
- String unwatch = page.getParameter("unwatch");
- if (unwatch != null)
- {
- if ("topic".equals(unwatch))
- {
- isWatching = false;
- watch.remove();
- }
- Die.exit(GENERAL_MESSAGE, "${bb.No_longer_watching}<br/><br/>${bb.Click_return_topic_0}" +
- "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
- "&start=" + start + "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}");
- }
- else
- {
- isWatching = true;
- }
- }
- catch (ObjectNotFoundException e)
- {
- String watch = page.getParameter("watch");
- if (watch != null)
- {
- if ("topic".equals(watch))
- {
- homesRO.topicWatch.create(user, topic);
- isWatching = true;
- }
- String message = "${bb.You_are_watching}<br/><br/>${bb.Click_return_topic_0}" +
- "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
- "&start=" + start + "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}";
- Die.exit(GENERAL_MESSAGE, message);
- }
- else
- {
- isWatching = false;
- }
- }
- }
- catch (RemoveException e)
- {
- Die.rollback(GENERAL_ERROR, "Could not delete topic watch information", e);
- }
- catch (CreateException ce)
- {
- Die.rollback(GENERAL_ERROR, "Could not insert topic watch information", ce);
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain topic watch information", e);
- }*/
- }
- else
- {
- /*
- if ("topic".equals(page.getParameter("unwatch")))
- {
- // redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
- // page.sendRedirect("index.html?module=user&op=getlogin");
- // return;
- }
- else
- {
- canWatch = false;
- isWatching = false;
- }
- */
- }
- int totalReplies = 0;
- Date minPostDate = null;
- if (postDays > 0)
- {
- Calendar c = Calendar.getInstance();
- c.add(Calendar.DATE, -postDays);
- minPostDate = c.getTime();
-
- /*
- try
- {
- Collection result = homesRO.post.selectGeneric("SELECT p.id FROM post AS p WHERE p.topic=?1 AND p.postDate>=?2",
- new Object[]{topic, minPostDate});
- totalReplies = result.size();
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain limited topics count information", e);
- }
- */
-
- // if ( !empty($HTTP_POST_VARS['postdays']))
- // {
- // $start = 0;
- // }
- }
- else
- {
- totalReplies = topic.getReplies();
- postDays = 0;
- }
-
- // String selectPostDays = BBTools.selectDays("postdays", postDays);
- /*boolean postOrderAsc = true;*/
- boolean postOrderAsc = true;
- if (req.getPreferences().getValue("postorder", "ascending").equals("ascending"))
- {
- //System.out.println("Show posts ascending");
- postOrderAsc = true;
- }
- else
- {
- //System.out.println("Show posts descending");
- postOrderAsc = false;
- }
-
- // String asc = req.getParameter("postorder");
- // boolean postOrderAsc = asc != null ? "asc".equals(asc) : user == null ? true : !user.getSortOrderDescending();
- // Decide how to order the post display
- // String selectPostOrder = "<select name=\"postorder\"><option value=\"asc\">" +
- // "${bb.Oldest_First}</option><option value=\"desc\" selected=\"selected\">" +
- // "${bb.Newest_First}</option></select>";
-
- /* if (postOrderAsc)
- {
- selectPostOrder = "<select name=\"postorder\"><option value=\"asc\" selected=\"selected\">" +
- "${bb.Oldest_First}</option><option value=\"desc\">" +
- "${bb.Newest_First}</option></select>";
- }
- */
-
- List posts = null;
- int totalPosts = 0;
- //int allTopicPostsNum = 0;
-
- /*int postsPerPage = 10;*/
- int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
- try
- {
- /*
- posts = postOrderAsc ?
- (minPostDate != null ?
- homesRO.post.findByTopicBeforeAsc(topic, minPostDate, start, postPerPage) :
- homesRO.post.findByTopicAsc(topic, start, postPerPage)) :
- (minPostDate != null ?
- homesRO.post.findByTopicBeforeDesc(topic, minPostDate, start, postPerPage) :
- homesRO.post.findByTopicDesc(topic, start, postPerPage));
- */
-
- //To get proper pagination when jump to latest post
- if (postId.intValue() != -1)
- {
- if (postOrderAsc)
- {
- posts = forumsModule.findPostsByTopicIdAsc(topicId, 0, 0);
- }
- else
- {
- posts = forumsModule.findPostsByTopicIdDesc(topicId, 0, 0);
- }
- int page = 0;
- int postposition = 1;
- for (Iterator i = posts.iterator(); i.hasNext(); postposition++)
- {
- if (postposition > ((page + 1) * postsPerPage))
- {
- page++;
- }
- if (((Post)i.next()).getId().intValue() == postId.intValue())
- {
- break;
- }
- }
- start = page * postsPerPage;
- }
- //else
- //{
- if (postOrderAsc)
- {
- posts = forumsModule.findPostsByTopicIdAsc(topicId, start,
- postsPerPage);
- }
- else
- {
- posts = forumsModule.findPostsByTopicIdDesc(topicId, start,
- postsPerPage);
- }
- totalPosts = posts.size();
- //}
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
-
- //Die.exit(GENERAL_ERROR, "Could not obtain post/user information.", e);
- }
- if (totalPosts == 0)
- {
- // Die.exit(GENERAL_MESSAGE, "${bb.No_posts_topic}");
- }
-
- // $sql = "SELECT *
- // FROM " . RANKS_TABLE . "
- // ORDER BY rank_special, rank_min";
- // if ( !($result = $db->sql_query($sql)) )
- // {
- // message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
- // }
- //
- // $ranksrow = array();
- // while ( $row = $db->sql_fetchrow($result) )
- // {
- // $ranksrow[] = $row;
- // }
- // $db->sql_freeresult($result);
- //
- ////
- topicTitle = formatTitle(req, topicTitle);
-
- //
- ////
- //// Was a highlight request part of the URI?
- ////
- // $highlight_match = $highlight = '';
- // if (isset($HTTP_GET_VARS['highlight']))
- // {
- // // Split words and phrases
- // $words = explode(' ', trim(htmlspecialchars(urldecode($HTTP_GET_VARS['highlight']))));
- //
- // for($i = 0; $i < sizeof($words); $i++)
- // {
- // if (trim($words[$i]) != '')
- // {
- // $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
- // }
- // }
- // unset($words);
- //
- // $highlight = urlencode($HTTP_GET_VARS['highlight']);
- // }
- PortletURL newTopicURL;
- newTopicURL = resp.createRenderURL();
- newTopicURL.setParameter("op", OP_POSTING);
- newTopicURL.setParameter("f", "" + forumId);
- newTopicURL.setParameter("mode", "newtopic");
-
- /*
- PortletURL replyTopicURL;
- replyTopicURL = resp.createRenderURL();
- replyTopicURL.setParameter("op", OP_POSTING);
- replyTopicURL.setParameter("mode", "reply");
- replyTopicURL.setParameter("p", "" + topic.getLastPost().getID());
- */
- PortletURL replyTopicURL;
- replyTopicURL = resp.createActionURL();
- replyTopicURL.setParameter("op", "posting");
- replyTopicURL.setParameter("mode", "reply");
- replyTopicURL.setParameter("p", "" + topic.getLastPost().getId());
- replyTopicURL.setParameter("f", "" + forumId);
-
- // replyTopicURL.setParameter("f", "" + forumId);
- // String replyTopicUrl = "index.html?module=bb&op=posting&mode=reply&p=" + topic.getLastPost().getID();
- PortletURL viewForumURL = resp.createRenderURL();
- viewForumURL.setParameter("op", OP_SHOWFORUM);
- viewForumURL.setParameter("f", "" + forumId);
- PortletURL viewCategoryURL = resp.createRenderURL();
- viewCategoryURL.setParameter("op", OP_MAIN);
- viewCategoryURL.setParameter("c", "" + category.getId());
- PortletURL replySubmitURL = resp.createActionURL();
- replySubmitURL.setParameter("op", "posting");
-
- String viewPrevTopicUrl = "index.html?module=bb&op=viewtopic&t="
- + topicId + "&view=previous";
- String viewNextTopicUrl = "index.html?module=bb&op=viewtopic&t="
- + topicId + "&view=next";
-
- String replyImg = theme.resourceReplyNewURL;
- String replyAlt = bundle.getString("Reply_to_topic");
- String postImg = theme.resourcePostNewURL;
- String postAlt = bundle.getString("Post_new_topic");
- if (forumStatus == FORUM_LOCKED)
- {
- replyImg = theme.resourceReplyLockedURL;
- replyAlt = bundle.getString("Topic_locked");
- postImg = theme.resourcePostLockedURL;
- postAlt = bundle.getString("Forum_locked");
- }
- else if (topicStatus == TOPIC_LOCKED)
- {
- replyImg = theme.resourceReplyLockedURL;
- replyAlt = bundle.getString("Topic_locked");
- }
- DelegateContext auth = null;
- if (authPost)
- {
- auth = root.next("AUTH_POST");
- }
- //disable <a href=> for posting when topic is locked
- if (authPost && !(topic.getStatus() == TOPIC_LOCKED))
- {
- auth.next("UNLOCKED");
- }
-
- if (loggedIn)
- {
- // Map trackingTopics = getTrackingTopics(page);
- // Map trackingForums = getTrackingForums(page);
- // Date topicDate = (Date)trackingTopics.get(topicId);
- // Date forumDate = (Date)trackingForums.get(forumId);
-
- /*
- Date topicLastRead = null;
- if (topicDate != null && forumDate != null)
- {
- topicLastRead = topicDate.after(forumDate) ? topicDate : forumDate;
- }
- else if (topicDate != null || forumDate != null)
- {
- topicLastRead = topicDate != null ? topicDate : forumDate;
- }
- else
- {
- // topicLastRead = user.getPreviousLastVisitDate();
- topicLastRead = user.getLastVisitDate();
- }
- // if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
- // {
- // asort($tracking_topics);
- // unset($tracking_topics[key($tracking_topics)]);
- // }
- trackingTopics.put(topicId, new Date());
- */
- }
-
- StringBuffer authCan = new StringBuffer();
-
- // BBTools.authCan(authCan, forum, loggedIn, level);
- String topicMod = "";
-
-
- if (authMod)
- {
- /*authCan.append(bundle.getString("Rules_moderate_0") + "<a href=\"index.html?module=bb&op=modcp&f=")
- .append(forumId).append("\">" + bundle.getString("Rules_moderate_1") + "</a>"
- + bundle.getString("Rules_moderate_2")); */
- PortletURL deleteTopicURL = resp.createActionURL();
- deleteTopicURL.setParameter(getOperationName(), "moderate_forum");
- deleteTopicURL.setParameter("delete", "delete");
- deleteTopicURL.setParameter("f", "" + topic.getForum().getId());
- deleteTopicURL.setParameter("t", "" + topic.getId());
- PortletURL moveTopicURL = resp.createActionURL();
- moveTopicURL.setParameter(getOperationName(), "moderate_forum");
- moveTopicURL.setParameter("move", "move");
- moveTopicURL.setParameter("f", "" + topic.getForum().getId());
- moveTopicURL.setParameter("t", "" + topic.getId());
- PortletURL lockTopicURL = resp.createActionURL();
- lockTopicURL.setParameter(getOperationName(), "moderate_forum");
- lockTopicURL.setParameter("lock", "lock");
- lockTopicURL.setParameter("f", "" + topic.getForum().getId());
- lockTopicURL.setParameter("t", "" + topic.getId());
- PortletURL unlockTopicURL = resp.createActionURL();
- unlockTopicURL.setParameter(getOperationName(), "moderate_forum");
- unlockTopicURL.setParameter("unlock", "unlock");
- unlockTopicURL.setParameter("f", "" + topic.getForum().getId());
- unlockTopicURL.setParameter("t", "" + topic.getId());
- PortletURL splitTopicURL = resp.createActionURL();
- splitTopicURL.setParameter(getOperationName(), "moderate_forum");
- splitTopicURL.setParameter("split", "split");
- splitTopicURL.setParameter("f", "" + topic.getForum().getId());
- splitTopicURL.setParameter("t", "" + topic.getId());
-
- topicMod =
- "<a href=\"" + deleteTopicURL.toString() + "\">" + "<img src=\""
- + theme.resourceTopicModeDeleteURL + "\" alt=\"" + bundle.getString("Delete_topic") + "\" title=\""
- + bundle.getString("Delete_topic") + "\" " + "border=\"0\"/></a> "
- + "<a href=\"" + moveTopicURL.toString() + "\">" + "<img src=\""
- + theme.resourceTopicModMoveURL + "\" alt=" + bundle.getString("Move_topic") + "\" " + "title=\""
- + bundle.getString("Move_topic") + "\" border=\"0\"/></a> "
- + ((topicStatus == TOPIC_UNLOCKED)
- ? ("<a href=\"" + lockTopicURL.toString() + "\">" + "<img src=\""
- + theme.resourceTopicModLockURL + "\" alt=\"" + bundle.getString("Lock_topic") + "\" " + "title=\""
- + bundle.getString("Lock_topic") + "\" border=\"0\" /></a> ")
- : ("<a href=\"" + unlockTopicURL.toString() + "\">" + "<img src=\""
- + theme.resourceTopicModUnlockURL + "\" alt=\"" + bundle.getString("Unlock_topic") + "\" "
- + "title=\"" + bundle.getString("Unlock_topic") + "\" border=\"0\"/></a> "))
- + "<a href=\"" + splitTopicURL.toString() + "\">" + "<img src=\""
- + theme.resourceTopicModSplitURL + "\" " + "alt=\"" + bundle.getString("Split_topic") + "\" title=\""
- + bundle.getString("Split_topic") + "\" border=\"0\"/></a> ";
- }
-
- String watchingTopic = "";
- String watchingTopicImg = "";
-
- /*
- if (canWatch)
- {
- if (isWatching)
- {
- watchingTopic = "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
- "&unwatch=topic&start=" + start + "\">${bb.Stop_watching_topic}</a>";
- String url = theme.resourceTopicUnWatchURL;
- watchingTopicImg = "".equals(url) ? "" : "<a href=\"index.html?module=bb&op=viewtopic&t=" +
- topicId + "&unwatch=topic&start=" + start + "\"><img src=\"" + url +
- "\" alt=\"" + bundle.getString("Stop_watching_topic") + "\" title=\"" + bundle.getString("Stop_watching_topic") + "\" border=\"0\"></a>";
- }
- else
- {
- watchingTopic = "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
- "&watch=topic&start=" + start + "\">${bb.Start_watching_topic}</a>";
- String url = theme.resourceTopicWatchURL;
- watchingTopicImg = "".equals(url) ? "" : "<a href=\"index.html?module=bb&op=viewtopic&t=" +
- topicId + "&watch=topic&start=" + start + "\"><img src=\"" + url +
- "\" alt=\"" + bundle.getString("Start_watching_topic") + "\" title=\"" + bundle.getString("Start_watching_topic") + "\" border=\"0\"></a>";
- }
- }
- */
-
- // $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : ;
- /*int postPerPage = 10;*/
- int postPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
-
- PortletURL gotoURL = resp.createRenderURL();
- gotoURL.setParameter("op", OP_SHOWTOPIC);
- gotoURL.setParameter("t", "" + topicId);
- gotoURL.setParameter("postDays", "" + postDays);
- gotoURL.setParameter("postorder", (postOrderAsc ? "asc" : "desc"));
- GotoWithOffset toPost = new GotoWithOffset(1 + totalReplies, start,
- postPerPage, gotoURL.toString() + "&start=", bundle
- .getString("Goto_page"), bundle.getString("Previous"), bundle
- .getString("Next"));
-
- String pageNumber = bundle.getString("Page_of_0")
- + ((int)Math.floor((double)start / (postPerPage)) + 1)
- + bundle.getString("Page_of_1")
- + ((int)Math.ceil((double)(totalReplies + 1) / postPerPage))
- + bundle.getString("Page_of_2");
-
- String instantReplyHiddenFormFields = "<input type=\"hidden\" name=\"attach_sig\" value=\"-1\"/>\n"
- + "<input type=\"hidden\" name=\"mode\" value=\"reply\"/>\n"
- + "<input type=\"hidden\" name=\"subject\" value=\"Re: "
- + topic.getSubject()
- + "\"/>\n"
- + "<input type=\"hidden\" name=\"p\" value=\""
- + topic.getLastPost().getId() + "\"/>\n";
- replySubmitURL.setParameter("attach_sig", "-1");
- replySubmitURL.setParameter("mode", "reply");
- replySubmitURL.setParameter("subject", "Re: " + topic.getSubject());
- replySubmitURL.setParameter("t", "" + topic.getId());
- replySubmitURL.setParameter("f", "" + topic.getForum().getId());
- replySubmitURL.setParameter("p", "" + topic.getLastPost().getId());
- // "<input type=\"hidden\" name=\"notify\" value=\"" + "checked" + "\"/>\n";
- // DelegateContext root = new DelegateContext();
- root.put("S_INSTANT_REPLY_HIDDEN_FORM_FIELDS",
- instantReplyHiddenFormFields);
- root.put("FORUM_ID", forumId.toString());
- root.put("FORUM_NAME", forumName);
- root.put("CATEGORY_NAME", category.getTitle());
- root.put("TOPIC_ID", topicId.toString());
- root.put("TOPIC_TITLE", topicTitle);
- root.put("PAGINATION", toPost.generate());
- root.put("PAGE_NUMBER", pageNumber);
- root.put("POST_IMG", postImg);
- root.put("REPLY_IMG", replyImg);
- root.put("L_POST_NEW_TOPIC", postAlt);
- root.put("L_POST_REPLY_TOPIC", replyAlt);
- root.put("S_TOPIC_LINK", "t");
-
- // root.put("S_SELECT_POST_DAYS", selectPostDays);
- // root.put("S_SELECT_POST_ORDER", selectPostOrder);
- root.put("S_POST_DAYS_ACTION", "index.html?module=bb&op=viewtopic&t="
- + topicId + "&start=" + start);
- root.put("S_AUTH_LIST", authCan.toString());
- root.put("S_TOPIC_ADMIN", topicMod);
- root.put("S_WATCH_TOPIC", watchingTopic);
- root.put("S_WATCH_TOPIC_IMG", watchingTopicImg);
- root.put("U_VIEW_FORUM", viewForumURL.toString());
- root.put("U_VIEW_OLDER_TOPIC", viewPrevTopicUrl);
- root.put("U_VIEW_NEWER_TOPIC", viewNextTopicUrl);
- root.put("U_POST_NEW_TOPIC", newTopicURL.toString());
- root.put("U_POST_REPLY_TOPIC", replyTopicURL.toString());
-
- // root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
- PortletURL viewMainPageURL = resp.createRenderURL();
- viewMainPageURL.setParameter("op", OP_MAIN);
- root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
- root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
- root.put("U_VIEW_CATEGORY", viewCategoryURL.toString());
- root.put("U_VIEW_TOPIC", "index.html?module=bb&op=viewtopic&t=" + topicId
- + "&start=" + start + "&postdays=" + "postDays" + "&postorder="
- + "postOrder" + "&highlight=" + "highlight");
- root.put("U_REPLY_SUBMIT", replySubmitURL.toString());
-
-
- Poll poll = topic.getPoll();
- boolean isPoll = poll != null;
- if (isPoll && poll.getOptions().size() == 0)
- {
- isPoll = false;
- }
- boolean pollVoted = false;
- boolean canVote = ForumsTools.hasPermission(req, "VotePollInPost");
- boolean pollExpired = false;
- //boolean pollEnded = poll.getIsEnded();
- boolean pollViewResultsMode = false;
- if (req.getParameter("poll_results_view_enable") != null &&
- req.getParameter("poll_results_view_enable").equals("true"))
- {
- pollViewResultsMode = true;
- }
- if (loggedIn && isPoll)
- {
- for (Iterator i = poll.getVoted().iterator(); i.hasNext();)
- {
- Integer userId = (Integer)i.next();
- if (pollVoted = (((Long)user.getId()).toString()).equals(userId.toString()))
- {
- break;
- }
- }
- }
- if (isPoll)
- {
- Calendar c = Calendar.getInstance();
- c.setTime(poll.getCreationDate());
- c.add(Calendar.DATE, poll.getLength());
- pollExpired = c.before(new Date());
-
- }
- if (isPoll && !pollVoted && loggedIn && !pollViewResultsMode && !pollExpired && canVote)
- {
- PortletURL voteSubmitURL = resp.createActionURL();
- voteSubmitURL.setParameter("op", "posting");
- voteSubmitURL.setParameter("mode", "vote");
- voteSubmitURL.setParameter("t", "" + topic.getId());
- voteSubmitURL.setParameter("f", "" + topic.getForum().getId());
- DelegateContext poll_ballot = root.next("poll_ballot_display");
- poll_ballot.put("POLL_QUESTION", poll.getTitle());
- Iterator i = poll.getOptions().iterator();
- int index = 0;
- while (i.hasNext())
- {
- PollOption po = (PollOption)i.next();
- DelegateContext poll_ballot_option = poll_ballot.next("poll_option");
- poll_ballot_option.put("POLL_OPTION_ID", "" + index);
- poll_ballot_option.put("POLL_OPTION_CAPTION", po.getQuestion());
- index++;
- }
-
- PortletURL viewPollResultsURL = resp.createRenderURL();
- viewPollResultsURL.setParameter("op", "showTopic");
- viewPollResultsURL.setParameter("t", "" + topic.getId());
- viewPollResultsURL.setParameter("poll_results_view_enable", "true");
- poll_ballot.put("U_VIEW_RESULTS", viewPollResultsURL.toString());
- //pollRoot.put("U_VIEW_RESULTS", "index.html?module=bb&op=viewtopic&t=" + topicId +
- //"&postdays=" + postDays + "&postorder=" + (postOrderAsc ? "asc" : "desc") +
- //"&vote=viewresult");
- String hiddenFields = "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
- "<input type=\"hidden\" name=\"op\" value=\"posting\"/>" +
- "<input type=\"hidden\" name=\"t\" value=\"" + topicId +
- "\"/><input type=\"hidden\" name=\"mode\" value=\"vote\"/>";
-
- // pollRoot.put("POLL_QUESTION", formatVoteTitle(voteTitle));
- poll_ballot.put("S_HIDDEN_FIELDS", hiddenFields);
- poll_ballot.put("VOTE_FORM_SUBMIT", voteSubmitURL.toString());
- }
- else if (isPoll)
- {
- DelegateContext poll_result = root.next("poll_result_display");
- poll_result.put("POLL_QUESTION", poll.getTitle());
- poll_result.put("TOTAL_VOTES", "" + poll.getVotesSum());
- float voteResultsSum = 0;
- for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
- {
- PollOption po = (PollOption)iterator.next();
- voteResultsSum += po.getVotes();
- }
-
- Iterator i = poll.getOptions().iterator();
- int numOfOpts = poll.getOptions().size();
- //int index = 0;
- while (i.hasNext())
- {
- PollOption po = (PollOption)i.next();
- DelegateContext poll_result_option = poll_result.next("poll_option");
- //poll_result_option.put("POLL_OPTION_ID", "" + index);
- poll_result_option.put("POLL_OPTION_CAPTION", po.getQuestion());
- poll_result_option.put("POLL_OPTION_L_IMG", "" + theme.resourcePollVotingLBar);
- poll_result_option.put("POLL_OPTION_R_IMG", "" + theme.resourcePollVotingRBar);
- poll_result_option.put("POLL_OPTION_IMG", "" + theme.resourcePollVotingBar);
-
- float votePercent = voteResultsSum > 0 ? po.getVotes() / voteResultsSum : 0f;
- int voteGraphicLength = Math.round(votePercent * 205); // 205 == voteGraphicLength
- //String voteGraphicImg = theme.resourcePollVotingBar //theme.getResourceURL("voting_graphic_" + voteGraphic);
-
- //optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
- poll_result_option.put("POLL_OPTION_RESULT", "" + po.getVotes());
- poll_result_option.put("POLL_OPTION_PERCENT", "" + votePercent); // sprintf("%.1d%%", ($vote_percent * 100))
- //optionRoot.put("POLL_OPTION_IMG",);
- poll_result_option.put("POLL_OPTION_IMG_WIDTH", "" + voteGraphicLength);
- //index++;
- }
-
-
- }
-
- /*
- PollEJBLocal poll = topic.getPoll();
- String pollBox = "";
- if (poll != null)
- {
- int voteOptions = -1;
- Collection options = null;
- try
- {
- options = homesRO.option.findByPoll(poll);
- voteOptions = options.size();
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain vote data for this topic", e);
- }
- String hiddenFields = "";
- if (voteOptions > 0)
- {
- String voteTitle = poll.getText();
- boolean userVoted = false;
- if (user != null)
- {
- try
- {
- userVoted = true;
- homesRO.vote.findByPollAndUser(poll, user);
- }
- catch (ObjectNotFoundException e)
- {
- userVoted = false;
- }
- catch (FinderException e)
- {
- Die.exit(GENERAL_ERROR, "Could not obtain user vote data for this topic", e);
- }
- }
- Template pollTpl = null;
- DelegateContext pollRoot = new DelegateContext();
- boolean viewResult = "viewresult".equals(vote);
- Calendar c = Calendar.getInstance();
- c.setTime(poll.getCreationDate());
- c.add(Calendar.DATE, poll.getLength());
- boolean pollExpired = c.before(new Date());
- if (userVoted || viewResult || pollExpired || !authVote || topic.getStatus() == TOPIC_LOCKED)
- {
- pollTpl = theme.TPL_THEME_VIEWTOPIC_POLL_RESULT;
- float voteResultsSum = 0;
- for (Iterator iterator = options.iterator();iterator.hasNext();)
- {
- OptionEJBLocal option = (OptionEJBLocal)iterator.next();
- voteResultsSum += option.getResult();
- }
- int voteGraphic = 0;
- for (Iterator iterator = options.iterator();iterator.hasNext();)
- {
- OptionEJBLocal option = (OptionEJBLocal)iterator.next();
- float votePercent = voteResultsSum > 0 ? option.getResult() / voteResultsSum : 0f;
- int voteGraphicLength = Math.round(votePercent * 205); // 205 == voteGraphicLength
- String voteGraphicImg = theme.getResourceURL("voting_graphic_" + voteGraphic);
- if ("".equals(voteGraphicImg))
- {
- voteGraphicImg = theme.getResourceURL("voting_graphic_0");
- voteGraphic = 0;
- }
- else
- {
- voteGraphic++;
- }
- DelegateContext optionRoot = pollRoot.next("poll_option");
- optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
- optionRoot.put("POLL_OPTION_RESULT", "" + option.getResult());
- optionRoot.put("POLL_OPTION_PERCENT", "" + votePercent); // sprintf("%.1d%%", ($vote_percent * 100))
- optionRoot.put("POLL_OPTION_IMG", voteGraphicImg);
- optionRoot.put("POLL_OPTION_IMG_WIDTH", "" + voteGraphicLength);
- }
- pollRoot.put("TOTAL_VOTES", "" + voteResultsSum);
- }
- else
- {
- pollTpl = theme.TPL_THEME_VIEWTOPIC_POLL_BALLOT;
- for (Iterator iterator = options.iterator();iterator.hasNext();)
- {
- Option option = (Option)iterator.next();
- DelegateContext optionRoot = pollRoot.next("poll_option");
- optionRoot.put("POLL_OPTION_ID", option.getId().toString());
- optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
- }
- pollRoot.put("U_VIEW_RESULTS", "index.html?module=bb&op=viewtopic&t=" + topicId +
- "&postdays=" + postDays + "&postorder=" + (postOrderAsc ? "asc" : "desc") +
- "&vote=viewresult");
- hiddenFields += "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
- "<input type=\"hidden\" name=\"op\" value=\"posting\"/>" +
- "<input type=\"hidden\" name=\"t\" value=\"" + topicId +
- "\"/><input type=\"hidden\" name=\"mode\" value=\"vote\"/>";
- }
- // pollRoot.put("POLL_QUESTION", formatVoteTitle(voteTitle));
- pollRoot.put("S_HIDDEN_FIELDS", hiddenFields);
- pollBox = pollTpl.render(pollRoot);
- }
- }
- root.put("POLL_DISPLAY", pollBox);
- */
- topic.setViewCount(topic.getViewCount() + 1);
-
- for (IndexIterator iterator = IndexIterator.wrap(posts.iterator(), -1); iterator
- .hasNext();)
- {
- Post post = (Post)iterator.next();
- User poster = post.getPoster().getUser();
-
- //below where " req.getRemoteUser() != null" was earlier "poster != null"
-
- String posterId = req.getRemoteUser() != null ? poster.getId().toString() : "0";
- /*String postDate = post.getCreateDate().toString();*/
- SimpleDateFormat sdf = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
- String postDate = sdf.format(post.getCreateDate());
- String posterPosts = req.getRemoteUser() != null ? (bundle.getString("Posts")
- + ":" + poster.getUserName()) : "";
- String location = (String)poster.getProperties().get("LOCATION");
- String posterFrom = (req.getRemoteUser() != null && (location != null)) ? (bundle
- .getString("Location")
- + ":" + location) : "";
- /*String posterJoined = (poster != null) ? (bundle.getString("Joined")
- + ":" + poster.getRegistrationDate()) : "";*/
- String posterJoined = req.getRemoteUser() != null ? (bundle.getString("Joined")
- + ":" + sdf.format(poster.getRegistrationDate())) : "";
-
- // String posterAvatar = "";
- // $poster_avatar = '';
- // if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
- // {
- // switch( $postrow[$i]['user_avatar_type'] )
- // {
- // case USER_AVATAR_UPLOAD:
- // $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
- // break;
- // case USER_AVATAR_REMOTE:
- // $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
- // break;
- // case USER_AVATAR_GALLERY:
- // $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
- // break;
- // }
- // }
- String miniPostImg = theme.resourceIconMinipostURL;
- String miniPostAlt = bundle.getString("Post");
- if (loggedIn && false) // $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read
- {
- miniPostImg = theme.resourceIconMinipostNewURL;
- miniPostAlt = bundle.getString("New_post");
- }
-
- // String miniPostUrl = "index.html?module=bb&op=viewtopic&p=" + post.getID() + "#" + postImg;
- // //
- // // Generate ranks, set them to empty string initially.
- // //
- // $poster_rank = '';
- // $rank_image = '';
- // if ( $postrow[$i]['user_id'] == ANONYMOUS )
- // {
- // }
- // else if ( $postrow[$i]['user_rank'] )
- // {
- // for($j = 0; $j < count($ranksrow); $j++)
- // {
- // if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
- // {
- // $poster_rank = $ranksrow[$j]['rank_title'];
- // $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
- // }
- // }
- // }
- // else
- // {
- // for($j = 0; $j < count($ranksrow); $j++)
- // {
- // if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
- // {
- // $poster_rank = $ranksrow[$j]['rank_title'];
- // $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
- // }
- // }
- // }
- //
- // compute the displayed poster name
- String posterName = post.getPoster().getUser().getUserName();
- String profileImgLnk = "";
- String profileLnk = "";
- String pmImgLnk = "";
- String pmLnk = "";
- String emailImgLnk = "";
- String emailLnk = "";
- String wwwImgLnk = "";
- String wwwLnk = "";
- String icqStatusImgLnk = "";
- String icqImgLnk = "";
- String icqLnk = "";
- String aimImgLnk = "";
- String aimLnk = "";
- String msnImgLnk = "";
- String msnLnk = "";
- String yimImgLnk = "";
- String yimLnk = "";
- String skypeImgLnk = "";
- String skypeImg = "";
- String editImgLnk = "";
- String editLnk = "";
- String repostImgLnk = "";
- String repostLnk = "";
- String ipImgLnk = "";
- String ipLnk = "";
-
- //theme
- PortletURL userProfileURL = resp.createRenderURL();
- userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
- userProfileURL.setParameter("uid", "" + poster.getId().toString());
- if ((req.getRemoteUser() != null))
- {
- //user.getPreferenceStore().
- String fakeEmail = poster.getFakeEmail();
- String homepage = (String)(poster.getProperties().get(CoreConstants.INFO_USER_HOMEPAGE));
- String icqAddr = (String)(poster.getProperties().get(CoreConstants.INFO_USER_IM_ICQ));
- String aimAddr = (String)(poster.getProperties().get(CoreConstants.INFO_USER_IM_AIM));
- String msnmAddr = (String)(poster.getProperties().get(CoreConstants.INFO_USER_IM_MSNM));
- String yimAddr = (String)(poster.getProperties().get(CoreConstants.INFO_USER_IM_YIM));
- String skypeAddr = (String)(poster.getProperties().get(CoreConstants.INFO_USER_IM_SKYPE));
-
- profileImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconProfileURL, "");
- if (fakeEmail != null && fakeEmail.length() > 0)
- {
- emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
- }
- if (homepage != null && homepage.length() > 0)
- {
- wwwImgLnk = ForumsTools.createImageLink(homepage, theme.resourceIconWWWURL, "");
- }
- String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + icqAddr;
- if (icqAddr != null && icqAddr.length() > 0)
- {
- icqImgLnk = ForumsTools.createImageLink(icqUrl, theme.resourceIconICQURL, "");
- }
- String aimUrl = "aim:goim?screenname=" + aimAddr + "&message=Hello+Are+you+there?";
- if (aimAddr != null && aimAddr.length() > 0)
- {
- aimImgLnk = ForumsTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "");
- }
- if (msnmAddr != null && msnmAddr.length() > 0)
- {
- msnImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconMSNMURL, "");
- }
- if (skypeAddr != null && skypeAddr.length() > 0)
- {
- skypeImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconSkypeURL, "");
- }
- String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + yimAddr + "&src=pg";
- if (yimAddr != null && yimAddr.length() > 0)
- {
- yimImgLnk = ForumsTools.createImageLink(yimUrl.toString(), theme.resourceIconYIMURL, "");
- }
- }
-
- /*
- if (poster != null)
- {
- String posterIcq = poster.getMessengerICQ();
- String posterAim = poster.getMessengerAIM();
- String posterMsn = poster.getMessengerMSNM();
- String posterYim = poster.getMessengerYIM();
- String profileUrl = "index.html?module=user&op=userinfo&uid=" + posterId;
- profileImgLnk = BBTools.createImageLink(profileUrl, theme.resourceIconProfileURL, "${bb.Read_profile}");
- profileLnk = BBTools.createLink(profileUrl, "${bb.Read_profile}");
- // String pmUrl = "privmsg.php?mode=post&u=" + posterId;
- String pmUrl = ""; // todo private message
- pmImgLnk = BBTools.createImageLink(pmUrl, theme.resourceIconPMURL, "${bb.Send_private_message}");
- pmLnk = BBTools.createLink(pmUrl, "${bb.Send_private_message}");
- if (!poster.getViewEmail() || authMod)
- {
- String emailUrl = emailForm ? "index.html?module=user&op=userinfo&uid=" + posterId :
- "mailto:" + poster.getEmail();
- emailImgLnk = BBTools.createImageLink(emailUrl, theme.resourceIconEmailURL, "${bb.Send_email}");
- emailLnk = BBTools.createLink(emailUrl, "${bb.Send_email}");
- }
- String websiteUrl = poster.getURL();
- if (websiteUrl != null && websiteUrl.length() > 0)
- {
- wwwImgLnk = BBTools.createImageLink(websiteUrl, "userwww", theme.resourceIconWWWURL, "${bb.Visit_website}", "${bb.Visit_website}");
- wwwLnk = BBTools.createLink(websiteUrl, "userwww", "${bb.Visit_website}");
- }
- if (posterIcq != null && posterIcq.length() > 0)
- {
- icqStatusImgLnk = "<a href=\"http://wwp.icq.com/" + posterIcq + "#pager\">" +
- "<img src=\"http://web.icq.com/" +
- "whitepages/online?icq=\"" + posterIcq +
- "&img=5\" width=\"18\" height=\"18\" border=\"0\"/></a>";
- String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + posterIcq;
- icqImgLnk = BBTools.createImageLink(icqUrl, theme.resourceIconICQURL, "${bb.ICQ}");
- icqLnk = BBTools.createLink(icqUrl, "${bb.ICQ}");
- }
- if (posterAim != null && posterAim.length() > 0)
- {
- String aimUrl = "aim:goim?screenname=\"" + posterAim + "&message=Hello+Are+you+there?";
- aimImgLnk = BBTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "${bb.AIM}");
- aimLnk = BBTools.createLink(aimUrl, "${bb.AIM}");
- }
- if (posterMsn != null && posterMsn.length() > 0)
- {
- String msnUrl = "index.html?module=user&op=userinfo&uid=" + posterId;
- msnImgLnk = BBTools.createImageLink(msnUrl, theme.resourceIconMSNMURL, "${bb.MSNM}");
- msnLnk = BBTools.createLink(msnUrl, "${bb.MSNM}");
- }
- if (posterYim != null && posterYim.length() > 0)
- {
- String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + posterYim + "&src=pg";
- yimImgLnk = BBTools.createImageLink(yimUrl, theme.resourceIconYIMURL, "${bb.YIM}");
- yimLnk = BBTools.createLink(yimUrl, "${bb.YIM}");
- }
- }
- */
- /*
- String searchUrl = "index.html?module=bb&op=search&search_authors=${encodeurl:" + post.getPoster().getAuthor(false) + "}" + "&showresults=posts";
- String searchImg = BBTools.createImageLink(searchUrl, theme.resourceIconSearchURL, "${bb.Search_user_posts}");
- String search = BBTools.createLink(searchUrl, "${bb.Search_user_posts}");
- if ((EJB.areIdentical(user, poster) && authEdit) || authMod)
- {
- String editUrl = "index.html?module=bb&op=posting&mode=editpost&p=" + post.getId();
- editImgLnk = "<a href=\"" + editUrl + "\"><img src=\"" + theme.resourceIconEditURL +
- "\" alt=\"${bb.Edit_delete_post}\" title=\"${bb.Edit_delete_post}\" border=\"0\"/></a>";
- editLnk = "<a href=\"" + editUrl + "\">${bb.Edit_delete_post}</a>";
- String repostUrl = "index.html?module=bb&op=posting&mode=repost&p=" + post.getId();
- repostImgLnk = "<a href=\"" + repostUrl + "\"><img src=\"" + theme.resourceIconRepostURL +
- "\" alt=\"${bb.Repost_post}\" title=\"${bb.Repost_post}\" border=\"0\"/></a>";
- repostLnk = "<a href=\"" + repostUrl + "\">${bb.Repost_post}</a>";
- }
- */
-
-
-
- boolean canDelete = false;
- boolean canIP = false;
-
- if (authMod)
- {
- canDelete = true;
- canIP = true;
- }
- else
- {
- canDelete = authDelete
- && poster.getUserName().equals(user.getUserName())
- && topic.getLastPost().getId().equals(post.getId());
- }
-
- // only moderators can use the IP function on a given topic
- if (canIP)
- {
- String url = "index.html?module=bb&op=modcp&mode=ip&p="
- + post.getId() + "&t=" + topicId;
-
- // ipImgLnk = BBTools.createImageLink(url, theme.resourceIconIPURL, "${bb.View_IP}");
- // ipLnk = BBTools.createLink(url, "${bb.View_IP}");
- }
-
- Message message = post.getMessage();
- String postSubject = message.getSubject();
- if (postSubject == null)
- {
- postSubject = "";
- }
- String text = "";
- if (message.getText() != null)
- {
- text = new String(message.getText());
- }
-
- PropertyMap upm = post.getPoster().getUser().getProperties();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
- if ((addsign != null) && (sign != null) && addsign.equals("1"))
- {
- text += "\n\n" + sign;
- }
-
- String signature = "";
-
- /*
- if (message.getSignatureEnabled() && signatureEnabled)
- {
- signature = poster.getSignature();
- if (!BBTools.isNullOrBlank(signature))
- {
- signature = formatSignature(signature, message.getBBCodeEnabled(), message.getHTMLEnabled());
- }
- }
- */
- PortletPreferences pp = req.getPreferences();
- //text = formatMessage(req, text, message.getBBCodeEnabled(), message.getHTMLEnabled());
- text = formatMessage(req, text, message.getBBCodeEnabled(), pp.getValue("allowhtml", "1").equals("1"));
- postSubject = formatTitle(req, postSubject);
-
- // //
- // // Highlight active words (primarily for search)
- // //
- // if ($highlight_match)
- // {
- // // This was shamelessly 'borrowed' from volker at multiartstudio dot de
- // // via php.net's annotated manual
- // $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
- // }
- int editCount = post.getEditCount();
- String editedBy = "";
- if (editCount > 0)
- {
- //check is it one or more and prepare nice sentence
- String[] ett = (editCount == 1) ? new String[]{
- bundle.getString("Edited_time_total_0"),
- bundle.getString("Edited_time_total_1"),
- bundle.getString("Edited_time_total_2"),
- bundle.getString("Edited_time_total_3")} : new String[]{
- bundle.getString("Edited_times_total_0"),
- bundle.getString("Edited_times_total_1"),
- bundle.getString("Edited_times_total_2"),
- bundle.getString("Edited_times_total_3")};
-
- editedBy = "<br/><br/>" + ett[0] + poster.getUserName() + ett[1] + sdf.format(post.getEditDate()) + ett[2] + editCount + ett[3];
- }
-
- String rowColor = theme
- .getProperty(((iterator.getIndex() % 2) == 0) ? "td_color1"
- : "td_color2");
- String rowClass = theme
- .getProperty(((iterator.getIndex() % 2) == 0) ? "td_class1"
- : "td_class2");
-
- DelegateContext postRow = root.next("postrow");
-
- postRow.put("ROW_COLOR", rowColor);
- postRow.put("ROW_CLASS", rowClass);
- postRow.put("POSTER_NAME", posterName);
- if ((req.getRemoteUser() != null))
- {
- postRow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
- }
- postRow.put("POSTER_RANK", ""); // $poster_rank
- postRow.put("RANK_IMAGE", ""); // $rank_image
- postRow.put("POSTER_JOINED", posterJoined);
-
- // postRow.put("POSTER_POSTS", posterPosts);
- postRow.put("POSTER_FROM", posterFrom);
- postRow.put("POSTER_AVATAR", ""); // $poster_avatar
- postRow.put("POST_DATE", postDate);
- postRow.put("POST_SUBJECT", postSubject);
- postRow.put("MESSAGE", text);
- postRow.put("SIGNATURE", signature);
- postRow.put("EDITED_MESSAGE", editedBy);
- postRow.put("MINI_POST_IMG", miniPostImg);
-
- postRow.put("PROFILE_IMG", profileImgLnk);
- postRow.put("PROFILE", profileLnk);
-
- // postRow.put("SEARCH_IMG", searchImg);
- // postRow.put("SEARCH", search);
- postRow.put("PM_IMG", pmImgLnk);
- postRow.put("PM", pmLnk);
- postRow.put("EMAIL_IMG", emailImgLnk);
- postRow.put("EMAIL", emailLnk);
- postRow.put("WWW_IMG", wwwImgLnk);
- postRow.put("WWW", wwwLnk);
- postRow.put("ICQ_STATUS_IMG", icqStatusImgLnk);
- postRow.put("ICQ_IMG", icqImgLnk);
- postRow.put("ICQ", icqLnk);
- postRow.put("AIM_IMG", aimImgLnk);
- postRow.put("AIM", aimLnk);
- postRow.put("MSN_IMG", msnImgLnk);
- postRow.put("MSN", msnLnk);
- postRow.put("SKYPE_IMG", skypeImgLnk);
- postRow.put("YIM_IMG", yimImgLnk);
- postRow.put("YIM", yimLnk);
- //postRow.put("EDIT_IMG", editImgLnk);
- //postRow.put("EDIT", editLnk);
- postRow.put("REPOST_IMG", repostImgLnk);
- postRow.put("REPOST", repostLnk);
-
- if (authPost)
- {
- PortletURL quoteURL = resp.createActionURL();
- quoteURL.setParameter("mode", "quote");
- quoteURL.setParameter("op", "posting");
- quoteURL.setParameter("p", String.valueOf(post.getId()));
- quoteURL.setParameter("f", String.valueOf(forum.getId()));
-
- //String quoteUrl = "index.html?module=bb&op=posting&mode=quote&p=" + post.getID();
- String quoteImg = ForumsTools.createImageLink(quoteURL.toString(),
- theme.resourceIconQuoteURL, bundle
- .getString("Reply_with_quote"));
- String quote = ForumsTools.createLink(quoteURL.toString(), bundle
- .getString("Reply_with_quote"));
- postRow.put("QUOTE_IMG", quoteImg);
- postRow.put("QUOTE", quote);
- }
-
- if (authMod)
- {
- PortletURL editURL = resp.createActionURL();
- editURL.setParameter("mode", "editpost");
- editURL.setParameter("op", "posting");
- editURL.setParameter("p", String.valueOf(post.getId()));
- editURL.setParameter("f", String.valueOf(forum.getId()));
- //Set this param to inform posting() that it will be it's first call
- editURL.setParameter("editPostInit", "true");
- boolean firstTopicPost = false;
- firstTopicPost |= post.getTopic().getFirstPost().getId().equals(post.getId());
- editURL.setParameter("firstTopicPost", "" + firstTopicPost);
- if (firstTopicPost)
- {
- editURL.setParameter("topictype", "" + post.getTopic().getType());
- }
- editURL.setParameter("subject", post.getMessage().getSubject());
-
- String editImg = ForumsTools.createImageLink(editURL.toString(),
- theme.resourceIconEditURL, bundle
- .getString("Edit_Post"));
- String edit = ForumsTools.createLink(editURL.toString(), bundle
- .getString("Edit_Post"));
- postRow.put("EDIT_IMG", editImg);
- postRow.put("EDIT", edit);
- }
-
-
- postRow.put("IP_IMG", ipImgLnk);
- postRow.put("IP", ipLnk);
-
- // only moderators can delete all messages from a given topic
- // if a user has the delete privilege on a forum that means he
- // in this forum can delete his own posts
- if (canDelete)
- {
- PortletURL deleteURL = resp.createActionURL();
- deleteURL.setParameter("mode", "delete");
- deleteURL.setParameter("op", "posting");
- deleteURL.setParameter("p", "" + post.getId());
-
- String delPostImgLnk = ForumsTools.createImageLink(deleteURL
- .toString(), theme.resourceIconDelpostURL, bundle
- .getString("Delete_post"));
- String delPostLnk = ForumsTools.createLink(deleteURL.toString(),
- bundle.getString("Delete_post"));
- postRow.put("DELETE_IMG", delPostImgLnk);
- postRow.put("DELETE", delPostLnk);
- }
-
- postRow.put("L_MINI_POST_ALT", miniPostAlt);
-
- // postRow.put("U_MINI_POST", miniPostUrl);
- postRow.put("U_POST_ID", post.getId().toString());
-
- //Here we display post attachments
- List attachments = post.getAttachments();
- DelegateContext attachDisplayCtx = null;
- DelegateContext attachContext = null;
- if (attachments.size() > 0)
- {
- attachDisplayCtx = postRow.next("attachments_display");
- attachContext = attachDisplayCtx.next("attach");
- }
- //For every attachment we must create Token and place it in the AttachmentTokenManager
- //to pass to DownloadServlet aggrement to download each.
- AttachmentTokenManager atm = getAttachmentManager(req);
- //Generate url to servlet
- String hostURL = ((req.isSecure()) ? "https" : "http")
- + "://"
- + req.getServerName()
- + ((req.getServerPort() == 80) ? "" : ":"
- + req.getServerPort());
- String servletURL = hostURL + req.getContextPath() + "/files?tokenId=";
- for (Iterator i = attachments.iterator(); i.hasNext();)
- {
- Attachment attach = (Attachment)i.next();
- //TODO:BD set some nice expire date (maybe in config)
- Calendar c = Calendar.getInstance();
- //15 minutes for downloading?
- c.add(Calendar.MINUTE, 15);
-
- AttachmentToken token = atm.createNewToken(attach.getId(), c.getTime());
- atm.addToken(token);
-
- if (attach.getFile().getContentType().startsWith("image/"))
- {
- //Date expireDate = newDate();
- //expireDate.
- DelegateContext catImagesContext = attachContext.next("cat_images");
- catImagesContext.put("COMMENT", attach.getComment());
- catImagesContext.put("DOWNLOAD_NAME", attach.getFile().getName());
- catImagesContext.put("IMG_SRC", servletURL + token.getId());
- catImagesContext.put("FILSIZE", "" + attach.getFile().getSize() / 1024 + "kB");
- //catImagesContext.put("SIZE_VAR", "${bb.Bytes}");
- }
- else
- {
- DelegateContext attachRowContext = attachContext.next("attachrow");
- attachRowContext.put("COMMENT", attach.getComment());
- attachRowContext.put("DOWNLOAD_NAME", attach.getFile().getName());
- attachRowContext.put("U_DOWNLOAD_LINK", servletURL + token.getId());
- attachRowContext.put("FILESIZE", "" + attach.getFile().getSize() / 1024 + "kB");
- }
- }
- //}
- //attachments = theme.TPL_THEME_VIEWTOPIC_ATTACH_BODY.render(attachmentsContext);
- //postRow.put("ATTACHMENTS", attachments);
-
- //try
- //{
-
- /*File tmp = File.createTempFile(attach.getFile().getName(),"");
- Blob blob = (Blob) attach.getFile().getContent();*/
-/* OutputStream out = blob.();
-String fileName = "oraclejdbc.jar";
-File f = new File(fileName);
-FileInputStream fin = new FileInputStream(f);
-int count = -1, total = 0;
-byte[] data = new byte[(int)fin.available()];
-fin.read(data);
-out.write(data);
-fin.close();
-out.close();*/
- // Get the image Blob from the database
-
- /*InputStream in = null;
- try
- {
- in = blob.getBinaryStream();
- BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(tmp) );
-
-byte by[] = new byte[ 32768 ];
-int index = in.read( by, 0, 32768 );
-while ( index != -1 )
-{
-out.write( by, 0, index );
-index = in.read( by, 0, 32768 );
-}
-out.flush();
- System.out.println("Stored attachment into: " + tmp.getAbsolutePath());
- }
- catch (SQLException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }*/
-
- /*}
- catch (IOException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }*/
- //}
- /*
- Collection attachmentsCollection = post.getAttachments();
- String attachments = "";
- DelegateContext attachmentsContext = new DelegateContext();
- DelegateContext attachContext = attachmentsContext.next("attach");
- Iterator i = attachmentsCollection.iterator();
- AttachmentEJBLocal attachment = null;
- while (i.hasNext())
- {
- attachment = (AttachmentEJBLocal)i.next();
- if (attachment.getMimetype().startsWith("image/"))
- {
- DelegateContext catImagesContext = attachContext.next("cat_images");
- catImagesContext.put("COMMENT", attachment.getComment());
- catImagesContext.put("DOWNLOAD_NAME", attachment.getRealFilename());
- catImagesContext.put("IMG_SRC", "modules/bb/attach?id=" + attachment.getId());
- catImagesContext.put("FILESIZE", "" + attachment.getFilesize());
- catImagesContext.put("SIZE_VAR", "${bb.Bytes}");
- }
- else
- {
- DelegateContext attachRowContext = attachContext.next("attachrow");
- attachRowContext.put("COMMENT", attachment.getComment());
- attachRowContext.put("DOWNLOAD_NAME", attachment.getRealFilename());
- attachRowContext.put("U_DOWNLOAD_LINK", "modules/bb/attach?id=" + attachment.getId());
- attachRowContext.put("FILESIZE", attachment.getFilesize() + " ${bb.Bytes}");
- }
- }
- attachments = theme.TPL_THEME_VIEWTOPIC_ATTACH_BODY.render(attachmentsContext);
- postRow.put("ATTACHMENTS", attachments);
- */
- }
-
- return root;
- }
-
- private DelegateContext fillShowAddEditForumContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- String mode = req.getParameters().get("mode", "");
-
- // default values for addforum case, miss only the forum name which is calculated under
- String title = bundle.getString("Create_forum");
- String newMode = "createforum";
- String buttonValue = bundle.getString("Create_forum");
- String forumName = "";
- String forumDesc = "";
- int forumStatus = FORUM_UNLOCKED;
- int forumId = -1;
- int categoryId = -1;
- String pruneEnabled = "";
-
- if ("editforum".equals(mode))
- {
- // if edit forum, we override the addforum values
- title = bundle.getString("Edit_forum");
- newMode = "modforum";
- buttonValue = bundle.getString("Update");
- try
- {
- Forum forum = forumsModule.findForumById(req.getParameters()
- .getIntObject("f"));
- forumId = forum.getId().intValue();
- categoryId = forum.getCategory().getId().intValue();
- forumName = forum.getName();
- forumDesc = forum.getDescription();
- forumStatus = forum.getStatus();
-
- /*
- if (forum.getPruneEnable())
- {
- pruneEnabled = "checked=\"checked\"";
- // $sql = "SELECT *
- // FROM " . PRUNE_TABLE . "
- // WHERE forum_id = $forum_id";
- // if(!$pr_result = $db->sql_query($sql))
- // {
- // message_die(GENERAL_ERROR, "Auto-Prune: Couldn't read auto_prune table.", __LINE__, __FILE__);
- // }
- // $pr_row = $db->sql_fetchrow($pr_result);
- }
- */
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
-
- // Die.exit(GENERAL_ERROR, "Couldn't get Forum/Category information", e);
- }
- }
- else
- {
- categoryId = req.getParameters().getInt("c", -1);
-
- // for the addforum mode we setup the forum name
- forumName = req.getParameter("forumname_" + categoryId);
- }
-
- String forumLocked = "";
- String forumUnlocked = "selected=\"selected\"";
- if (forumStatus == FORUM_LOCKED)
- {
- forumLocked = forumUnlocked;
- forumUnlocked = "";
- }
-
- String catList;
- try
- {
- catList = ForumsTools.listCategories(forumsModule.findCategories(),
- categoryId);
- root.put("S_CAT_LIST", catList);
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- String statusList = "<option value=\"" + FORUM_UNLOCKED + "\" "
- + forumUnlocked + ">" + bundle.getString("Status_unlocked")
- + "</option>\n" + "<option value=\"" + FORUM_LOCKED + "\" "
- + forumLocked + ">" + bundle.getString("Status_locked")
- + "</option>\n";
- String hiddenFields = "<input type=\"hidden\" name=\"mode\" value=\""
- + newMode + "\"/>" + "<input type=\"hidden\" name=\"f\" value=\""
- + forumId + "\"/>"
- + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
- + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>";
-
- PortletURL postURL = resp.createActionURL();
- root.put("POST_URL", postURL.toString());
- root.put("S_HIDDEN_FIELDS", hiddenFields);
- root.put("S_SUBMIT_VALUE", buttonValue);
- root.put("S_STATUS_LIST", statusList);
- root.put("S_PRUNE_ENABLED", pruneEnabled);
- root.put("L_FORUM_TITLE", title);
- root.put("PRUNE_DAYS", "TODO_PRUNE_DAYS"); // ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7
- root.put("PRUNE_FREQ", "TODO_PRUNE_FREQ"); // ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1
- root.put("FORUM_NAME", forumName);
- root.put("DESCRIPTION", forumDesc);
-
- return root;
- }
-
- private DelegateContext fillShowAdminForumsContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- String mode = req.getParameters().get("mode", "");
- boolean addCategory = req.getParameter("addcategory") != null;
- Category addforum = null;
-
- try
- {
- for (Iterator i = forumsModule.findCategories().iterator(); i
- .hasNext();)
- {
- Category category = (Category)i.next();
- if (req.getParameter("addforum_" + category.getId()) != null)
- {
- addforum = category;
- break;
- }
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
-
- // Die.exit(GENERAL_ERROR, "Cannot process command", e);
- }
-
- if ((addforum != null) || addCategory)
- {
- if (addforum != null)
- {
- mode = "addforum";
- }
- else
- {
- mode = "addcat";
- }
- }
-
- try
- {
- PortletURL postURL = resp.createActionURL();
- postURL.setParameters(req.getParameterMap());
- postURL.setParameter("op", "admin_forums");
- root.put("POST_URL", postURL.toString());
- for (Iterator i = forumsModule.findCategories().iterator(); i
- .hasNext();)
- {
- Category category = (Category)i.next();
- Integer categoryId = category.getId();
-
- DelegateContext catrow = root.next("catrow");
- catrow.put("S_ADD_FORUM_SUBMIT", "addforum_" + categoryId);
- catrow.put("S_ADD_FORUM_NAME", "forumname_" + categoryId);
- catrow.put("CAT_ID", categoryId.toString());
- catrow.put("CAT_DESC", category.getTitle());
- PortletURL categoryEditURL = resp.createActionURL();
- categoryEditURL.setParameter("op", "admin_forums");
- categoryEditURL.setParameter("mode", "editcat");
- categoryEditURL.setParameter("c", "" + categoryId);
- categoryEditURL.setParameter(POST_CAT_URL, "" + categoryId);
- catrow.put("U_CAT_EDIT", categoryEditURL.toString());
- PortletURL categoryDeleteURL = resp.createActionURL();
- categoryDeleteURL.setParameter("op", "admin_forums");
- categoryDeleteURL.setParameter("mode", "deletecat");
- categoryDeleteURL.setParameter(POST_CAT_URL, "" + categoryId);
- catrow.put("U_CAT_DELETE", categoryDeleteURL.toString());
- PortletURL catMoveUp = resp.createActionURL();
- catMoveUp.setParameter("op", "admin_forums");
- catMoveUp.setParameter("mode", "cat_order");
- catMoveUp.setParameter("move", "-15");
- catMoveUp.setParameter(POST_CAT_URL, "" + categoryId);
- catrow.put("U_CAT_MOVE_UP", catMoveUp.toString());
- PortletURL catMoveDown = resp.createActionURL();
- catMoveDown.setParameter("op", "admin_forums");
- catMoveDown.setParameter("mode", "cat_order");
- catMoveDown.setParameter("move", "15");
- catMoveDown.setParameter(POST_CAT_URL, "" + categoryId);
- catrow.put("U_CAT_MOVE_DOWN", catMoveDown.toString());
- PortletURL categoryViewURL = resp.createRenderURL();
- categoryViewURL.setParameter("op", OP_MAIN);
- categoryViewURL.setParameter(POST_CAT_URL, "" + categoryId);
- catrow.put("U_VIEWCAT", categoryViewURL.toString());
-
- for (Iterator j = forumsModule.findForumsByCategoryId(categoryId)
- .iterator(); j.hasNext();)
- {
- Forum forum = (Forum)j.next();
- Integer forumId = forum.getId();
- DelegateContext forumrow = catrow.next("forumrow");
- forumrow.put("FORUM_NAME", forum.getName());
- forumrow.put("FORUM_DESC", forum.getDescription());
- forumrow.put("ROW_COLOR'", "$row_color");
- forumrow.put("NUM_TOPICS", "" + forum.getTopicCount());
- forumrow.put("NUM_POSTS", "" + forum.getPostCount());
- PortletURL viewForumURL = resp.createRenderURL();
- viewForumURL.setParameter(getOperationName(), OP_SHOWFORUM);
- viewForumURL.setParameter("f", "" + forumId);
- forumrow.put("U_VIEWFORUM", viewForumURL.toString());
- PortletURL forumEditURL = resp.createActionURL();
- forumEditURL.setParameter("op", "admin_forums");
- forumEditURL.setParameter("mode", "editforum");
- forumEditURL.setParameter("f", "" + forumId);
- forumrow.put("U_FORUM_EDIT", forumEditURL.toString());
- PortletURL forumDeleteURL = resp.createActionURL();
- forumDeleteURL.setParameter("op", "admin_forums");
- forumDeleteURL.setParameter("mode", "deleteforum");
- forumDeleteURL.setParameter("f", "" + forumId);
- forumrow.put("U_FORUM_DELETE", forumDeleteURL.toString());
- PortletURL forumMoveUpURL = resp.createActionURL();
- forumMoveUpURL.setParameter("op", "admin_forums");
- forumMoveUpURL.setParameter("mode", "forum_order");
- forumMoveUpURL.setParameter("move", "-15");
- forumMoveUpURL.setParameter("f", "" + forumId);
- forumrow.put("U_FORUM_MOVE_UP", forumMoveUpURL.toString());
- PortletURL forumMoveDownURL = resp.createActionURL();
- forumMoveDownURL.setParameter("op", "admin_forums");
- forumMoveDownURL.setParameter("mode", "forum_order");
- forumMoveDownURL.setParameter("move", "15");
- forumMoveDownURL.setParameter("f", "" + forumId);
- forumrow.put("U_FORUM_MOVE_DOWN", forumMoveDownURL.toString());
-
- /*
- PortletURL forumResyncURL = resp.createActionURL();
- forumResyncURL.setParameter("op", "admin_forums");
- forumResyncURL.setParameter("mode", "forum_sync");
- forumResyncURL.setParameter("f", "" + forumId);
- forumrow.put("U_FORUM_RESYNC", forumResyncURL.toString());
- */
- }
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
-
- // Die.exit(GENERAL_ERROR, "Could not query categories list");
- }
-
- // display(theme.TPL_THEME_ADMIN_FORUM_ADMIN_BODY, root, page);
- return root;
- }
-
- private DelegateContext fillShowModerateForumContext(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- //System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
- //System.out.println("fillModerateForumContext()");
- ResourceBundle bundle = getResourceBundle(req.getLocale());
-
- int topicsPerPage = Integer.parseInt(req.getPreferences().getValue("topicsperforum", "10"));
- int hotThreshold = 10;
- int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
- Integer forumId = req.getParameters().getIntObject("f", -1);
- int start = req.getParameters().getInt("start", 0);
-
- // String markRead = page.getParameter("mark", "");
- int topicDays = req.getParameters().getInt("topicdays", 0);
-
- Forum forum = null;
- try
- {
- forum = forumsModule.findForumById(forumId);
- }
- catch (ModuleException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- Category category = forum.getCategory();
- User user = req.getUser();
- boolean loggedIn = req.getRemoteUser() != null;
-
- String categoryTitle = category.getTitle();
- String forumName = forum.getName();
-
- String[] testArray = new String[]{categoryTitle, forumName};
- boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum");
- if (!authMod)
- {
- System.out.println("You are not authorized to moderate this forum");
- return root;
- }
-
- Date minTopicTime = null;
- if (topicDays > 0)
- {
- Calendar c = Calendar.getInstance();
- c.add(Calendar.DATE, -topicDays);
- minTopicTime = c.getTime();
- }
- else
- {
- topicDays = 0;
- }
-
- List announcements = null;
- List topics = null;
-
- try
- {
- announcements = forumsModule.findAnnouncements(forum);
- topics = (minTopicTime == null) ? forumsModule.findTopicsDesc(forum,
- POST_ANNOUNCE, start, topicsPerPage) : forumsModule
- .findTopicsBefore(forum, POST_ANNOUNCE, start, topicsPerPage,
- minTopicTime);
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- int totalTopicsAndStickies = forum.getTopicCount();
-
-
- StringBuffer authCan = new StringBuffer();
-
- Iterator ci = new CompoundIterator(new Iterator[]{
- announcements.iterator(), topics.iterator()});
-
-
- PortletURL gotoURL = resp.createRenderURL();
- gotoURL.setParameter("op", OP_SHOWTOPIC);
- Goto toPost = new Goto(postsPerPage, bundle.getString("Goto_page"), gotoURL.toString());
- toPost.setImgUrl(theme.resourceIconGotopostURL);
- int row_index = 0;
- for (IndexIterator iterator = IndexIterator.wrap(ci, -1); iterator
- .hasNext(); row_index++)
- {
-
- Topic topic = (Topic)iterator.next();
-
- int replies = topic.getReplies();
- int status = topic.getStatus();
- /*Integer topicId = (status == TOPIC_MOVED) ? topic.getTarget().getID()
- : topic.getID();*/
- Integer topicId = topic.getId();
- String type = bundle.getString("Topic_Moved");
- String folderImage = theme.resourceFolderURL;
- String folderAlt = bundle.getString("Topic_Moved");
- String newestPostImg = "";
- /*Date topicLastPostDate = (topic.getLastPost()!=null) ? topic.getLastPost().getCreateDate() : null;*/
- Post firstPost = topic.getFirstPost();
- Post lastPost = topic.getLastPost();
- /*Poster lastPostUser = lastPost.getPoster();
- Poster poster = topic.getPoster();*/
-
- if (status != TOPIC_MOVED)
- {
- FolderType folderType = theme.getFolderType(topic.getType(),
- status, replies >= hotThreshold);
- boolean newest = loggedIn;
-
- if (newest)
- {
- folderImage = folderType.folderNew;
- folderAlt = (status == TOPIC_LOCKED) ? bundle
- .getString("Topic_locked") : bundle.getString("New_posts");
- /*newestPostImg = "<a href=\"index.html?module=bb&op=viewtopic&t="
- + topicId + "&view=newest\"><img src=\""
- + theme.resourceIconNewestReplyURL + "\" alt=\""
- + bundle.getString("View_newest_post") + "\" title=\""
- + bundle.getString("View_newest_post")
- + "\" border=\"0\"/></a>";*/
- }
- else
- {
- folderImage = folderType.folder;
- folderAlt = (status == TOPIC_LOCKED) ? bundle
- .getString("Topic_locked") : bundle
- .getString("No_new_posts");
- newestPostImg = "";
- }
-
- try
- {
- type = bundle.getString(folderType.type);
- }
- catch (java.util.MissingResourceException e)
- {
- type = "";
- }
-
- }
-
- toPost.setPostSize(replies);
- toPost.setTopicId(topicId.intValue());
- String gotoPage = toPost.generate();
- String topicAuthor = firstPost.getPoster().getUser().getUserName();
- String lastPostAuthor = lastPost.getPoster().getUser().getUserName();
-
- PortletURL lastPostURL = resp.createRenderURL();
- lastPostURL.setParameter("op", OP_SHOWTOPIC);
- lastPostURL.setParameter("p", "" + lastPost.getId());
-
- String lastPostUrl = "<a href=\"" + lastPostURL.toString() + "\">"
- + "<img src=\"" + theme.resourceIconLatestReplyURL + "\" alt=\""
- + bundle.getString("View_latest_post") + "\" title=\""
- + bundle.getString("View_latest_post") + "\" border=\"0\"/></a>";
-
- DelegateContext topicrow = root.next("topicrow");
- topicrow.put("TOPIC_ROW_INDEX", "" + row_index);
- topicrow.put("FORUM_ID", forumId.toString());
- topicrow.put("TOPIC_ID", topicId.toString());
- topicrow.put("TOPIC_FOLDER_IMG", folderImage);
- topicrow.put("TOPIC_AUTHOR", topicAuthor);
- topicrow.put("GOTO_PAGE", gotoPage);
- topicrow.put("REPLIES", "" + replies);
- //topicrow.put("NEWEST_POST_IMG", newestPostImg);
- topicrow.put("NEWEST_POST_IMG", lastPostUrl);
- topicrow.put("TOPIC_TITLE", formatTitle(req, topic.getSubject()));
- topicrow.put("TOPIC_TYPE", type);
- SimpleDateFormat sdfp = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
- topicrow.put("LAST_POST_TIME", sdfp.format(topic.getLastPostDate()));
-
- if ((req.getRemoteUser() != null))
- {
- PortletURL userProfileURL = resp.createRenderURL();
- userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
- userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
- topicrow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
- }
- topicrow.put("LAST_POST_AUTHOR", lastPostAuthor);
- topicrow.put("LAST_POST_IMG", lastPostUrl);
- topicrow.put("L_TOPIC_FOLDER_ALT", folderAlt);
- PortletURL viewTopicURL = resp.createRenderURL();
- viewTopicURL.setParameter("op", OP_SHOWTOPIC);
- viewTopicURL.setParameter("t", "" + topicId);
- topicrow.put("U_VIEW_TOPIC", viewTopicURL.toString());
- }
-
-
- PortletURL moderateActionURL = resp.createActionURL();
- moderateActionURL.setParameter(getOperationName(), "moderate_forum");
- moderateActionURL.setParameter("f", "" + forumId);
- root.put("S_POST_DAYS_ACTION", moderateActionURL.toString());
- //root.put("FORUM_ID", forum.getID().toString());
-
- //forum link on top of view
- root.put("FORUM_NAME", forum.getName());
-
- PortletURL viewForumURL = resp.createRenderURL();
- viewForumURL.setParameter("op", OP_SHOWFORUM);
- viewForumURL.setParameter("f", "" + forumId);
- root.put("U_VIEW_FORUM", viewForumURL.toString());
-
- //URL to go to moderate forum with specific page
- PortletURL pageNavigationURL = resp.createRenderURL();
- pageNavigationURL.setParameter("op", OP_SHOWMODERATEFORUM);
- pageNavigationURL.setParameter("f", "" + forumId);
- pageNavigationURL.setParameter("topicDays", "" + topicDays);
-
- //generate Page nav bar
- GotoWithOffset toForum = new GotoWithOffset(totalTopicsAndStickies,
- start, topicsPerPage, pageNavigationURL + "&start=", bundle
- .getString("Goto_page"), bundle.getString("Previous"), bundle
- .getString("Next"));
-
- String pageNumber = bundle.getString("Page_of_0")
- + ((int)Math.floor((double)start / topicsPerPage) + 1)
- + bundle.getString("Page_of_1")
- + ((int)Math.ceil((double)totalTopicsAndStickies / topicsPerPage));
- //page nav bar
- root.put("PAGE_NUMBER", pageNumber.toString());
- root.put("PAGINATION", toForum.generate());
-
- // root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
- return root;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param req DOCUMENT_ME
- * @param resp DOCUMENT_ME
- */
- public void forum_watches(JBossActionRequest req, JBossActionResponse resp)
- {
- try
- {
- if (req.getParameters().getParameterExists("watch"))
- {
- Integer id = req.getParameters().getIntObject("forum_id", -1);
- boolean linked = "linked".equals(req.getParameter("watch_mode"));
- Forum forum = forumsModule.findForumById(id);
- Poster poster = forumsModule.findPosterByUserId(req.getUser()
- .getId().toString());
- String[] test = new String[]{forum.getCategory().getTitle(),
- forum.getName()};
- if (ForumsTools.hasPermission(req, test, "ReadForum"))
- {
- if (poster == null)
- {
- poster = forumsModule.createPoster(req.getUser().getId().toString());
- }
- forumsModule.createWatch(poster, forum,
- linked ? ForumsConstants.WATCH_MODE_LINKED
- : ForumsConstants.WATCH_MODE_EMBEDED);
- }
- }
- else if (req.getParameters().getParameterExists("update"))
- {
- Integer forumWatchId = req.getParameters().getIntObject("forumwatch_id", -1);
- boolean linked = "linked".equals(req.getParameter("watch_mode"));
- ForumWatch watch = forumsModule.findForumWatchById(forumWatchId);
- watch.setMode(linked ? ForumsConstants.WATCH_MODE_LINKED
- : ForumsConstants.WATCH_MODE_EMBEDED);
- }
- else if (req.getParameters().getParameterExists("unwatch"))
- {
- Integer forumWatchId = req.getParameters().getIntObject("forumwatch_id", -1);
- ForumWatch watch = forumsModule.findForumWatchById(forumWatchId);
- forumsModule.removeWatch(watch);
- }
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param req DOCUMENT_ME
- * @param resp DOCUMENT_ME
- */
- public void topic_watches(JBossActionRequest req, JBossActionResponse resp)
- {
- try
- {
- Integer topicWatchId = req.getParameters().getIntObject("topicwatch_id", -1);
- TopicWatch watch = forumsModule.findTopicWatchById(topicWatchId);
- forumsModule.removeWatch(watch);
- }
- catch (ModuleException e)
- {
- e.printStackTrace();
- }
- }
-
- private DelegateContext fillShowWatchedForums(JBossRenderRequest req,
- JBossRenderResponse resp, DelegateContext root)
- {
- Set forumIds = new HashSet();
- Collection watches;
- try
- {
- watches = forumsModule.findForumWatchByUser(req.getUser());
- if (watches.size() > 0)
- {
- root.next("switch_watched_forums_block");
- for (IndexIterator i = IndexIterator.wrap(watches.iterator()); i
- .hasNext();)
- {
- ForumWatch watch = (ForumWatch)i.next();
- Forum forum = watch.getForum();
-
- // See if the user is authorized
- Category category = forum.getCategory();
- String[] test = new String[]{category.getTitle(),
- forum.getName()};
- if (ForumsTools.hasPermission(req, test, "ReadForum"))
- {
- boolean linked = watch.getMode() == ForumsConstants.WATCH_MODE_LINKED;
- Integer forumId = forum.getId();
- forumIds.add(forumId);
- String forumIdAsString = forumId.toString();
- PortletURL viewForumURL = resp.createRenderURL();
- viewForumURL.setParameter("op", OP_SHOWFORUM);
- viewForumURL.setParameter("f", forumIdAsString);
- root
- .next("forum_watch_row")
- .put("ROW_CLASS",
- theme
- .getProperty(((i.getIndex() & 1) == 0) ? "td_class1"
- : "td_class2")).put("U_FORUM_LINK",
- viewForumURL.toString()).put("FORUMWATCH_ID",
- watch.getId()).put("FORUM_ID", forumIdAsString)
- .put("S_FORUM_TITLE", forum.getName()).put("LINKED",
- linked ? "checked=\"checked\"" : "").put("EMBEDED", linked ? "" : "checked=\"checked\"");
- }
- }
- }
- else
- {
- root.next("switch_no_watched_forums");
- }
-
- StringBuffer select = new StringBuffer("<select name=\"forum_id\"><option value=\"\"></option>");
- Collection forums = forumsModule.findForums();
- for (Iterator i = forums.iterator(); i.hasNext();)
- {
- Forum forum = (Forum)i.next();
-
- // Get the forum level
- Category category = forum.getCategory();
- String[] test = new String[]{category.getTitle(), forum.getName()};
-
- // Display it only if the user is authorized
- if (ForumsTools.hasPermission(req, test, "ReadForum"))
- {
- Integer forumid = forum.getId();
- if (!forumIds.contains(forumid))
- {
- select.append("<option value=\"").append(forum.getId())
- .append("\">").append(forum.getName()).append("</option>");
- }
- }
- }
-
- select.append("</select>");
- root.put("S_FORUM_WATCH_SELECT", select.toString());
-
- // display(theme.TPL_THEME_WATCHED_FORUMS_BODY, root, page);
- // }
- // catch(Exception e)
- // {
- // Die.rollback(GENERAL_ERROR, "Could not obtain watch forum information");
- // }
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return root;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param text DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public String formatTitle(PortletRequest req, String text)
- {
- StringWriter stringWriter = new StringWriter();
- getToHTMLRenderer(req).setWriter(stringWriter);
-
- getToHTMLRenderer(req).render(text.toCharArray(), 0, text.length());
- return stringWriter.toString();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param text DOCUMENT_ME
- * @param allowBBCode DOCUMENT_ME
- * @param allowHTML DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public String formatMessage(PortletRequest req, String text, boolean allowBBCode, boolean allowHTML)
- {
- if (allowHTML)
- {
- getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT);
- getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
- }
- else
- {
- getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT);
- getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
- }
- return formatTitle(req, text);
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param text DOCUMENT_ME
- * @param allowBBCode DOCUMENT_ME
- * @param allowHTML DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public String formatSignature(PortletRequest req, String text, boolean allowBBCode, boolean allowHTML)
- {
- if (allowHTML)
- {
- getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT);
- getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
- }
- else
- {
- getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT);
- getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
- }
- return "<br/>_________________<br/>" + formatTitle(req, text);
- }
-
-
- /**
- *
- */
- public String formatUserName(User user)
- {
- return user.getUserName();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param cmd DOCUMENT_ME
- * @return DOCUMENT_ME
- * @throws CommandException DOCUMENT_ME
- */
- public Result executeForumCommand(JBossActionRequest request,
- JBossActionResponse response, ForumCommand cmd)
- throws CommandException
- {
- // Finish the command configuration
- cmd.setModule(forumsModule);
-
- // cmd.setHomes(homesRW);
- // Execute the command
- return forumsModule.invoke(cmd);
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param resp DOCUMENT_ME
- * @param key DOCUMENT_ME
- * @param error DOCUMENT_ME
- */
- public void addErrorMessage(JBossActionResponse resp, String key,
- String error)
- {
- resp.setRenderParameter(key.toLowerCase() + "_error", error);
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param resp DOCUMENT_ME
- * @param key DOCUMENT_ME
- * @param success DOCUMENT_ME
- */
- public void addSuccessMessage(JBossActionResponse resp, String key,
- String success)
- {
- resp.setRenderParameter(key.toLowerCase() + "_success", success);
- }
-
- /**
- * Get a <code>SimpleDateFormat</code> object from the session. The object is stored
- * in the session because it is expensive to create and we want to reuse it as
- * much as we can. Also it is configured with the date format taken from the preference
- * of the user if it exists.
- *
- * @param req the request that maybe contains the format object
- * @return the format object
- */
- public SimpleDateFormat getSDF(PortletRequest req)
- {
- // Get the pattern
- String pattern = req.getPreferences().getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
-
- // Get the simple date format if it exists
- SimpleDateFormat sdf = (SimpleDateFormat)req.getPortletSession().getAttribute("SDF");
-
- // Do we have it ?
- if (sdf == null)
- {
- // Create a new one
- sdf = new SimpleDateFormat(pattern, req.getLocale());
-
- // Put it in the session
- req.getPortletSession().setAttribute("SDF", sdf);
- }
- else
- {
- // Check if config has not changed
- if (!sdf.toPattern().equals(pattern))
- {
- sdf.applyPattern(pattern);
- }
- }
- return sdf;
- }
-
- private ToHTMLRenderer getToHTMLRenderer(PortletRequest req)
- {
- ToHTMLRenderer renderer = (ToHTMLRenderer)req.getPortletSession().getAttribute("RENDERER");
- if (renderer == null)
- {
- // Create the HTMLRenderer for BBCode
- ToHTMLConfig config = new ToHTMLConfig();
- config.setLoader(loader);
- Locale locale = req.getLocale();
- ResourceBundle bundle = getPortletConfig().getResourceBundle(locale);
- renderer = new ToHTMLRenderer(config, bundle);
- req.getPortletSession().setAttribute("RENDERER", renderer);
- }
- return renderer;
- }
-
- public AttachmentTokenManager getAttachmentManager(PortletRequest req)
- {
- // Get the simple date format if it exists
- AttachmentTokenManager atm = (AttachmentTokenManager)req.getPortletSession().getAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER, PortletSession.APPLICATION_SCOPE);
-
- // Do we have it ?
- if (atm == null)
- {
- // Create a new one
- atm = new AttachmentTokenManager();
- // Put it in the session
- req.getPortletSession().setAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER, atm, PortletSession.APPLICATION_SCOPE);
- }
- else
- {
- //what else?
- }
- return atm;
- }
-
-
-
-
-
-
-}
\ No newline at end of file
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentToken.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentToken.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentToken.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,96 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.Date;
-
-/**
- * Token that stores attachment id - to secure download
- *
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1018 $
- */
-public class AttachmentToken
-{
- private Date createDate;
- private Date expireDate;
- private int id;
- private Integer attachmentId;
-
-
- public AttachmentToken(int id)
- {
- this.id = id;
- createDate = new Date();
- }
-
- public AttachmentToken(int tokenId, Integer attachmentId, Date expireDate)
- {
- this.id = tokenId;
- this.attachmentId = attachmentId;
- this.expireDate = expireDate;
-
- }
-
- public Date getCreateDate()
- {
- return createDate;
- }
-
- public void setCreateDate(Date createDate)
- {
- this.createDate = createDate;
- }
-
- public Date getExpirationDate()
- {
- return expireDate;
- }
-
- public void setExpirationDate(Date expireDate)
- {
- this.expireDate = expireDate;
- }
-
- public int getId()
- {
- return id;
- }
-
- public void setId(int id)
- {
- this.id = id;
- }
-
- public Integer getAttachmentId()
- {
- return attachmentId;
- }
-
- public void setAttachmentId(Integer attachmentId)
- {
- this.attachmentId = attachmentId;
- }
-
-
- /**
- * compares createDate and expirationDate
- * @return
- */
- public boolean isValid()
- {
- if (expireDate == null)
- {
- return true;
- }
- Date currentDate = new Date();
- return currentDate.before(getExpirationDate());
- }
-
-}
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,158 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.List;
-import java.util.Vector;
-import java.util.Iterator;
-import java.util.Date;
-
-/**
- * Manager that stores and manages AttachmentToken object instances inside of session.
- *
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1018 $
- */
-public class AttachmentTokenManager
-{
- //user vector as it's thread safe
- private List tokens = new Vector();
-
- //lenght of tokens list above which it'll be purged from expired tokens
- private int autoPurgeSize = 100;
-
- //for id generation
- private int idCount;
-
- /**
- * Method adds new AttachmentToken into store. If there is one with same attachmentId already
- * it'll be replaced by the new one
- *
- * @param newToken
- */
-
- public synchronized void addToken(AttachmentToken newToken)
- {
- if (tokens.size() < autoPurgeSize)
- {
- removeExpiredTokens();
- }
-
- for (Iterator i = tokens.iterator(); i.hasNext();)
- {
- AttachmentToken at = (AttachmentToken)i.next();
- if (at.getAttachmentId().intValue() == newToken.getAttachmentId().intValue())
- {
- tokens.remove(at);
- tokens.add(newToken);
- return;
- }
- }
- tokens.add(newToken);
- }
-
- /**
- * checks if token is in store
- *
- * @param id
- * @return
- */
- public boolean hasToken(int id)
- {
- for (Iterator i = tokens.iterator(); i.hasNext();)
- {
- AttachmentToken at = (AttachmentToken)i.next();
- if (at.getId() == id)
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * returns token
- * @param id
- * @return
- */
- public AttachmentToken getToken(int id)
- {
-
- for (Iterator i = tokens.iterator(); i.hasNext();)
- {
- AttachmentToken at = (AttachmentToken)i.next();
- if (at.getId() == id)
- {
- return at;
- }
- }
- return null;
- }
-
-
-
-
- /**
- * new Tokens chould be obtained with this method to generate proper Id safely
- *
- * @return
- */
- public synchronized AttachmentToken createNewToken()
- {
- if (idCount == Integer.MAX_VALUE)
- {
- idCount = 0;
- }
- return new AttachmentToken(idCount++);
- }
-
- /**
- * new Tokens chould be obtained with this method to generate proper Id safely
- *
- * @return
- */
- public synchronized AttachmentToken createNewToken(Integer attachmentId, Date expireDate)
- {
- /*if (idCount == Integer.MAX_VALUE)
- {
- idCount = 0;
- }*/
- AttachmentToken at = createNewToken();
- at.setAttachmentId(attachmentId);
- at.setExpirationDate(expireDate);
- return at;
- }
-
-
- /**
- * Validates all tokens.
- */
- public synchronized void removeExpiredTokens()
- {
- for (Iterator i = tokens.iterator(); i.hasNext();)
- {
- AttachmentToken at = (AttachmentToken)i.next();
- if (!at.isValid())
- {
- tokens.remove(at);
- }
- }
- }
-
-
- public int getAutoPurgeSize()
- {
- return autoPurgeSize;
- }
-
- public void setAutoPurgeSize(int autoPurgeSize)
- {
- this.autoPurgeSize = autoPurgeSize;
- }
-}
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/ForumsTools.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/ForumsTools.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/ForumsTools.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,671 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import javax.ejb.EJBLocalHome;
-import javax.ejb.EJBLocalObject;
-import javax.portlet.PortletRequest;
-
-import org.apache.log4j.Logger;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.JBossRenderRequest;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1409 $
- */
-public class ForumsTools
-{
- private static final Logger log = Logger.getLogger(ForumsTools.class);
- private static final StandardAnalyzer analyzer = new StandardAnalyzer();
-
-
- public static void authCan(StringBuffer authCan, JBossRenderRequest req, String[] testArray, ResourceBundle bundle)
- {
- boolean authPost = hasPermission(req, testArray, "AddPostInForum");
- boolean authEdit = hasPermission(req, testArray, "EditPostInForum");
- boolean authDelete = hasPermission(req, testArray, "DeletePostInForum");
- boolean authPoll = hasPermission(req, testArray, "AddPollInPost");
- boolean authVote = hasPermission(req, testArray, "VotePollInPost");
- //boolean authMod = hasPermission(req, testArray, "ModerateForum");
-
- authCan.append(authPost ? bundle.getString("Rules_post_can") : bundle.getString("Rules_post_cannot")).
- append("<br/>").
- /* append(authEdit ? bundle.getString("Rules_edit_can") : bundle.getString("Rules_edit_cannot")).
- append("<br/>").
- append(authDelete ? bundle.getString("Rules_delete_can") : bundle.getString("Rules_delete_cannot")).
- append("<br/>").*/
- append(authPoll ? bundle.getString("Rules_poll_can") : bundle.getString("Rules_poll_cannot")).
- append("<br/>").
- append(authVote ? bundle.getString("Rules_vote_can") : bundle.getString("Rules_vote_cannot")).
- append("<br/>");
- }
-
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param name DOCUMENT_ME
- * @param value DOCUMENT_ME
- * @param selected DOCUMENT_ME
- */
- public static void radioButton(StringBuffer buffer,
- String name,
- String value,
- boolean selected)
- {
- buffer.append("<input type=\"radio\" name=\"").append(name).append("\" value=\"").append(value).append("\"")
- .append(selected ? " checked=\"checked\"/>" : "/>");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param url DOCUMENT_ME
- * @param target DOCUMENT_ME
- * @param image DOCUMENT_ME
- * @param title DOCUMENT_ME
- * @param alt DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String createImageLink(String url,
- String target,
- String image,
- String title,
- String alt)
- {
- return "<a href=\"" + url + "\" target=\"" + target + "\"><img src=\"" + image + "\" " + "alt=\"" + alt
- + "\" title=\"" + title + "\" border=\"0\"></a>";
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param url DOCUMENT_ME
- * @param image DOCUMENT_ME
- * @param title DOCUMENT_ME
- * @param alt DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String createImageLink(String url,
- String image,
- String title,
- String alt)
- {
- return "<a href=\"" + url + "\"><img src=\"" + image + "\" " + "alt=\"" + alt + "\" title=\"" + title
- + "\" border=\"0\"></a>";
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param url DOCUMENT_ME
- * @param image DOCUMENT_ME
- * @param title DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String createImageLink(String url,
- String image,
- String title)
- {
- return createImageLink(url, image, title, title);
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param url DOCUMENT_ME
- * @param text DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String createLink(String url,
- String text)
- {
- return "<a href=\"" + url + "\">" + text + "</a>";
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param url DOCUMENT_ME
- * @param target DOCUMENT_ME
- * @param text DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String createLink(String url,
- String target,
- String text)
- {
- return "<a href=\"" + url + "\" target=\"" + target + "\">" + text + "</a>";
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param text DOCUMENT_ME
- * @param field DOCUMENT_ME
- * @param isOr DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static Query createQuery(String text,
- String field,
- boolean isOr)
- {
- try
- {
- QueryParser parser = new QueryParser(field, analyzer);
- parser.setOperator(isOr ? QueryParser.DEFAULT_OPERATOR_OR : QueryParser.DEFAULT_OPERATOR_AND);
- return parser.parse(text);
- }
- catch (ParseException e)
- {
- log.error("Cannot parse query " + text, e);
- return DUMMY_QUERY;
- }
- }
-
- private static final Query DUMMY_QUERY = new BooleanQuery();
-
-
- /**
- * returns html <options> containing forums
- *
- * @param forums DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String listTopics(List forums)
- {
- Iterator result = forums.iterator();
-
- // hold the result
- StringBuffer buffer = new StringBuffer();
-
- // do the work
- while (result.hasNext())
- {
- Forum forum = (Forum)result.next();
- buffer.append("<option value=\"").append(forum.getId()).append("\"")
- .append(">")
- .append(forum.getName()).append("</option>\n");
- }
-
- return buffer.toString();
- }
-
-
- /**
- * DOCUMENT_ME
- *
- * @param forums DOCUMENT_ME
- * @param selectedId DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String listForums(List forums,
- int selectedId)
- {
- Iterator result = forums.iterator();
-
- // hold the result
- StringBuffer buffer = new StringBuffer();
-
- // do the work
- while (result.hasNext())
- {
- Forum forum = (Forum)result.next();
- buffer.append("<option value=\"").append(forum.getId()).append("\"")
- .append((selectedId == forum.getId().intValue()) ? " selected=\"selected\"" : "").append(">")
- .append(forum.getName()).append("</option>\n");
- }
-
- return buffer.toString();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param categories DOCUMENT_ME
- * @param selectedId DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String listCategories(List categories,
- int selectedId)
- {
- Iterator result = categories.iterator();
-
- // hold the result
- StringBuffer buffer = new StringBuffer();
-
- // do the work
- while (result.hasNext())
- {
- Category category = (Category)result.next();
- buffer.append("<option value=\"").append(category.getId()).append("\"")
- .append((selectedId == category.getId().intValue()) ? " selected=\"selected\"" : "").append(">")
- .append(category.getTitle()).append("</option>\n");
- }
-
- return buffer.toString();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param categories DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String listForumsCategories(ForumsModule module)
- {
- Iterator resultCat = null;
- try
- {
- resultCat = module.findCategories().iterator();
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- return "";
- }
-
- // hold the result
- StringBuffer buffer = new StringBuffer();
-
- // do the work
- while (resultCat.hasNext())
- {
- Category category = (Category)resultCat.next();
- buffer.append("<option value=\"").append("cx" + category.getId()).append("\"")
- .append(">")
- .append(" " + category.getTitle()).append("</option>\n");
-
- Iterator resultForum = null;
- try
- {
- resultForum = module.findForumsByCategoryId(category.getId()).iterator();
- }
- catch (ModuleException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- return "";
- }
-
- // hold the result
- //StringBuffer buffer = new StringBuffer();
-
- // do the work
- while (resultForum.hasNext())
- {
- Forum forum = (Forum)resultForum.next();
- buffer.append("<option value=\"").append("fx" + forum.getId()).append("\"")
- .append(">")
- .append(" " + forum.getName()).append("</option>\n");
- }
-
- }
-
- return buffer.toString();
- }
-
-
- /**
- * DOCUMENT_ME
- *
- * @param name DOCUMENT_ME
- * @param days DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String selectDays(String name,
- int days)
- {
- StringBuffer selectDays = new StringBuffer("<select name=\"").append(name).append("\">");
- for (int i = 0; i < ForumsConstants.PREVIOUS_DAYS.length; i++)
- {
- selectDays.append("<option value=\"").append(ForumsConstants.PREVIOUS_DAYS[i]).append("\"")
- .append((days == ForumsConstants.PREVIOUS_DAYS[i]) ? " selected=\"selected\"" : "").append(">")
- .append(ForumsConstants.PREVIOUS_DAYS_TEXT_TOPICS[i]).append("</option>");
- }
-
- selectDays.append("</select>");
- return selectDays.toString();
- }
-
- /**
- * Performs a generic batch update.
- */
- public static void batchUpdate(Connection conn,
- String updateQuery,
- String selectQuery,
- int size)
- throws SQLException
- {
- PreparedStatement updater = null;
- PreparedStatement selecter = null;
- ResultSet rs = null;
- try
- {
- updater = conn.prepareStatement(updateQuery);
-
- // not yet implemented in MySQL Connector/J driver 3.0.9
- // int size = updater.getParameterMetaData().getParameterCount();
- selecter = conn.prepareStatement(selectQuery);
- rs = selecter.executeQuery();
- while (rs.next())
- {
- for (int i = 1; i <= size; i++)
- {
- updater.setObject(i,
- rs.getObject(i));
- }
-
- updater.executeUpdate();
- }
- }
- finally
- {
- if (!conn.getAutoCommit())
- {
- conn.commit();
- }
-
- Tools.safeClose(rs);
- Tools.safeClose(updater);
- Tools.safeClose(selecter);
- }
- }
-
-// /**
-// * DOCUMENT_ME
-// *
-// * @param authCan DOCUMENT_ME
-// * @param forum DOCUMENT_ME
-// * @param loggedIn DOCUMENT_ME
-// * @param level DOCUMENT_ME
-// */
-// public static void authCan(StringBuffer authCan,
-// Forum forum,
-// boolean loggedIn,
-// Level level)
-// {
-// /*
-// authCan.append(Auth.hasLevel(forum.getAuth().getPost(), loggedIn, level) ? "${bb.Rules_post_can}" : "${bb.Rules_post_cannot}").
-// append("<br/>").
-// append(Auth.hasLevel(forum.getAuth().getReply(), loggedIn, level) ? "${bb.Rules_reply_can}" : "${bb.Rules_reply_cannot}").
-// append("<br/>").
-// append(Auth.hasLevel(forum.getAuth().getEdit(), loggedIn, level) ? "${bb.Rules_edit_can}" : "${bb.Rules_edit_cannot}").
-// append("<br/>").
-// append(Auth.hasLevel(forum.getAuth().getDelete(), loggedIn, level) ? "${bb.Rules_delete_can}" : "${bb.Rules_delete_cannot}").
-// append("<br/>").
-// append(Auth.hasLevel(forum.getAuth().getVote(), loggedIn, level) ? "${bb.Rules_vote_can}" : "${bb.Rules_vote_cannot}").
-// append("<br/>");
-// */
-// }
-
- /**
- * DOCUMENT_ME
- *
- * @param start DOCUMENT_ME
- * @param size DOCUMENT_ME
- * @param per DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String pageNumber(int start,
- int size,
- int per)
- {
- return "${bb.Page_of_0}" + (int)Math.ceil((double)start / (double)(per)) + "${bb.Page_of_1}"
- + (int)Math.ceil((double)size / (double)per) + "${bb.Page_of_2}";
- }
-
- /**
- * @param home where the EJBs are taken
- * @param getter how to get some info about the EJB
- * @param key the key used to set the skip or select the item in the list according the all parameter
- * @param all force all the items to be displayed
- * @return
- */
- public static String selectEJBs(EJBLocalHome home,
- Method getter,
- Object key,
- boolean all)
- {
- try
- {
- // empty args for the reflection call
- Object[] empty = new Object[0];
-
- // the findAll method will give us all the EJBs
- Method findAll = home.getClass().getMethod("findAll",
- new Class[0]);
- Iterator result = ((Collection)findAll.invoke(home, empty)).iterator();
-
- // hold the result
- StringBuffer buffer = new StringBuffer();
-
- // do the work
- while (result.hasNext())
- {
- EJBLocalObject ejb = (EJBLocalObject)result.next();
- Object ejbKey = ejb.getPrimaryKey();
- boolean equals = ejbKey.equals(key);
- if (all || equals)
- {
- buffer.append("<option value=\"").append(ejbKey).append("\"")
- .append(equals ? " selected=\"selected\"" : "").append(">").append(getter.invoke(ejb, empty))
- .append("</option>\n");
- }
- }
-
- // return the string buffer content
- return buffer.toString();
- }
- catch (Exception e)
- {
- log.error("Cannot list ejbs", e);
- return "";
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param clazz DOCUMENT_ME
- * @param prefix DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static String[][] collectFields(Class clazz,
- String prefix)
- {
- Field[] fields = clazz.getDeclaredFields();
- List values = new ArrayList(fields.length);
- for (int i = 0; i < fields.length; i++)
- {
- Field field = fields[i];
- int modifier = field.getModifiers();
- if (field.getName().startsWith(prefix)
- && Modifier.isFinal(modifier)
- && Modifier.isPublic(modifier)
- && Modifier.isStatic(modifier))
- {
- try
- {
- values.add(new String[]
- {
- field.getName(),
- (String)field.get(null)
- });
- }
- catch (Exception ignore)
- {
- Logger.getLogger(clazz).error("", ignore);
- }
- }
- }
-
- return (String[][])values.toArray(new String[values.size()][]);
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param c DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static Object head(Collection c)
- {
- Iterator iterator = c.iterator();
- return iterator.hasNext() ? iterator.next() : null;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param format_1_00 DOCUMENT_ME
- * @param forumId DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static final String computeCacheKey(boolean format_1_00,
- String forumId)
- {
- return (format_1_00 ? "rss/1.00" : "rss/0.91") + ((forumId != null) ? ("/" + forumId) : "");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param s DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static boolean isNullOrBlank(String s)
- {
- if (s != null)
- {
- for (int i = 0; i < s.length(); i++)
- {
- if (!Character.isWhitespace(s.charAt(i)))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- public static boolean hasPermission(PortletRequest req, String[] test, String permission)
- {
- return hasPermission(req, permission);
- }
-
- public static boolean hasPermission(PortletRequest req, String perm)
- {
-
- if (perm.equals("Admin")
- || perm.equals("Delete")
- || perm.equals("AdminCategory")
- || perm.equals("DeleteForumInCategory")
- || perm.equals("AddForumInCategory")
- || perm.equals("EditCategory")
- || perm.equals("AddForumInCategory")
- || perm.equals("EditForumInCategory")
- )
- {
- if (req.isUserInRole("ForumsAdmin"))
- {
- return true;
- }
- }
-
- if (perm.equals("ModerateForum")
- || perm.equals("AddPollInPost")
- || perm.equals("EditPollInPost")
- || perm.equals("AddAttachmentInPost")
- || perm.equals("DeletePostInForum")
- || perm.equals("EditPostInForum")
- )
- {
- if (req.isUserInRole("ForumsAdmin")
- || req.isUserInRole("ForumsModerator"))
- {
- return true;
- }
- }
-
- if (perm.equals("AddPollInPost"))
- {
- if (req.isUserInRole("ForumsAdmin")
- || req.isUserInRole("ForumsModerator")
- || req.isUserInRole("ForumsPolls"))
- {
- return true;
- }
- }
-
-
- if (perm.equals("AddAttachmentInPost"))
- {
- if (req.isUserInRole("ForumsAdmin")
- || req.isUserInRole("ForumsModerator")
- || req.isUserInRole("ForumsAttachments"))
- {
- return true;
- }
- }
-
- if (perm.equals("AddPostInForum")
- || perm.equals("VotePollInPost")
-
- )
- {
- if (req.isUserInRole("ForumsAdmin")
- || req.isUserInRole("ForumsModerator")
- || req.isUserInRole("ForumsAttachments")
- || req.isUserInRole("ForumsPolls")
- || req.isUserInRole("ForumsUser"))
- {
- return true;
- }
- }
-
-
- if (perm.equals("ReadCategory")
- || perm.equals("ReadForum"))
- {
- return true;
- }
-
- return false;
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Goto.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Goto.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Goto.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,194 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 878 $
- */
-public class Goto
- extends Range
-{
- private int postSize;
- private int postsPerPage;
- private int topicId;
- private String imgUrl;
- private String gotoText;
- private String url;
-
- /**
- * Creates a new {@link Goto} object.
- *
- * @param postsPerPage DOCUMENT_ME
- * @param gotoText DOCUMENT_ME
- */
- public Goto(int postsPerPage,
- String gotoText, String url)
- {
- super(3, 0, 3);
- this.postsPerPage = postsPerPage;
- this.gotoText = gotoText;
- this.url = url;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public int getPostSize()
- {
- return postSize;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param postSize DOCUMENT_ME
- */
- public void setPostSize(int postSize)
- {
- this.postSize = postSize;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public int getTopicId()
- {
- return topicId;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param topicId DOCUMENT_ME
- */
- public void setTopicId(int topicId)
- {
- this.topicId = topicId;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public String getImgUrl()
- {
- return imgUrl;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param imgUrl DOCUMENT_ME
- */
- public void setImgUrl(String imgUrl)
- {
- this.imgUrl = imgUrl;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public String generate()
- {
- if (postSize >= postsPerPage)
- {
- return build((int)Math.ceil((double)(postSize + 1) / (double)postsPerPage), -1);
- }
- else
- {
- return "";
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- */
- protected void start(StringBuffer buffer)
- {
- buffer.append("[ <img src=\"").append(imgUrl).append("\" alt=\"" + gotoText + "\" title=\"" + gotoText
- + "\"/>" + gotoText + ": ");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- */
- protected final void end(StringBuffer buffer)
- {
- buffer.append(" ] ");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void normal(StringBuffer buffer,
- int index)
- {
- lastNormal(buffer, index);
- buffer.append(", ");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void enhanced(StringBuffer buffer,
- int index)
- {
- lastNormal(buffer, index);
- buffer.append(", ");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void lastNormal(StringBuffer buffer,
- int index)
- {
- buffer.append("<a href=\"").append(url).append("&t=").append(topicId) .append("&start=")
- .append(index * postsPerPage).append("\">").append(index + 1).append("</a>");
- /*buffer.append("<a href=\"index.html?module=bb&op=viewtopic&t=").append(topicId).append("&start=")
- .append(index * postsPerPage).append("\">").append(index + 1).append("</a>");*/
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void lastEnhanced(StringBuffer buffer,
- int index)
- {
- lastNormal(buffer, index);
- }
-}
\ No newline at end of file
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/GotoWithOffset.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/GotoWithOffset.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/GotoWithOffset.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,167 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 878 $
- */
-public class GotoWithOffset
- extends Range
-{
- private int perPage;
- private String URL;
- private int offset;
- private int size;
- private String gotoPageLabel;
- private String previousLabel;
- private String nextLabel;
-
- /**
- * Creates a new {@link GotoWithOffset} object.
- *
- * @param size DOCUMENT_ME
- * @param offset DOCUMENT_ME
- * @param perPage DOCUMENT_ME
- * @param URL DOCUMENT_ME
- * @param gotoPageLabel DOCUMENT_ME
- * @param previousLabel DOCUMENT_ME
- * @param nextLabel DOCUMENT_ME
- */
- public GotoWithOffset(int size,
- int offset,
- int perPage,
- String URL,
- String gotoPageLabel,
- String previousLabel,
- String nextLabel)
- {
- super(3, 3, 3);
- this.size = size;
- this.offset = offset;
- this.perPage = perPage;
- this.URL = URL;
- this.gotoPageLabel = gotoPageLabel;
- this.previousLabel = previousLabel;
- this.nextLabel = nextLabel;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param offset DOCUMENT_ME
- */
- public void setOffset(int offset)
- {
- this.offset = offset;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- */
- protected final void start(StringBuffer buffer)
- {
- buffer.append(gotoPageLabel);
- buffer.append(" ");
- int offset = (int)Math.floor((double)this.offset / (double)perPage);
- if (offset > 0)
- {
- offset = (offset - 1) * perPage;
- buffer.append(" <a href=\"").append(URL).append(offset).append("\">").append(previousLabel).append("</a> ");
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- */
- protected final void end(StringBuffer buffer)
- {
- int nextOffset = (int)(Math.floor((double)this.offset / (double)perPage) + 1) * perPage;
- if (nextOffset < size)
- {
- buffer.append(" <a href=\"").append(URL).append(nextOffset).append("\">").append(nextLabel)
- .append("</a> ");
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void normal(StringBuffer buffer,
- int index)
- {
- lastNormal(buffer, index);
- buffer.append(", ");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void enhanced(StringBuffer buffer,
- int index)
- {
- lastEnhanced(buffer, index);
- buffer.append(", ");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void lastNormal(StringBuffer buffer,
- int index)
- {
- buffer.append("<a href=\"").append(URL).append(index * perPage).append("\">").append(index + 1).append("</a>");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param buffer DOCUMENT_ME
- * @param index DOCUMENT_ME
- */
- protected final void lastEnhanced(StringBuffer buffer,
- int index)
- {
- buffer.append("<b>").append(index + 1).append("</b>");
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public String generate()
- {
- if (size > perPage)
- {
- return build((int)Math.ceil(size / (double)perPage), (int)Math.floor(offset / (double)perPage));
- }
- else
- {
- return "";
- }
- }
-}
\ No newline at end of file
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/IndexIterator.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/IndexIterator.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/IndexIterator.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,112 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.Iterator;
-
-/**
- * An iterator wrapper than keeps track of the index.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 878 $
- */
-public class IndexIterator
- implements Iterator
-{
- private int index;
- private Iterator iterator;
-
- /**
- * Creates a new {@link IndexIterator} object.
- *
- * @param iterator DOCUMENT_ME
- */
- public IndexIterator(Iterator iterator)
- {
- this(iterator, 0);
- }
-
- /**
- * Creates a new {@link IndexIterator} object.
- *
- * @param iterator DOCUMENT_ME
- * @param start DOCUMENT_ME
- */
- public IndexIterator(Iterator iterator,
- int start)
- {
- this.iterator = iterator;
- this.index = start;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public boolean hasNext()
- {
- return iterator.hasNext();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public Object next()
- {
- index++;
- return iterator.next();
- }
-
- /**
- * DOCUMENT_ME
- */
- public void remove()
- {
- iterator.remove();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public int getIndex()
- {
- return index;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param iterator DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static IndexIterator wrap(Iterator iterator)
- {
- return new IndexIterator(iterator);
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param iterator DOCUMENT_ME
- * @param start DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static IndexIterator wrap(Iterator iterator,
- int start)
- {
- return new IndexIterator(iterator, start);
- }
-}
\ No newline at end of file
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Range.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Range.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Range.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,248 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-
-/**
- * Generate a jump bar like : [0,1,2,...,10,11,12,...,21,22,23]
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 878 $
- */
-public class Range
-{
- /**
- * @param left is the max number of items displayed on the left part
- * @param middle is the max number of items displayed in the middle part
- * @param right is the max number of items displayed in the right part
- */
- public Range(int left,
- int middle,
- int right)
- {
- this.left = left;
- this.middle = middle;
- this.right = right;
- }
-
- /**
- * DOCUMENT_ME
- */
- protected final int left;
-
- /**
- * DOCUMENT_ME
- */
- protected final int middle;
-
- /**
- * DOCUMENT_ME
- */
- protected final int right;
-
- /**
- * Begin the generated string.
- */
- protected void start(StringBuffer buffer)
- {
- buffer.append("[");
- }
-
- /**
- * End the generated string.
- */
- protected void end(StringBuffer buffer)
- {
- buffer.append("]");
- }
-
- /**
- * Generates a non last normal item.
- */
- protected void normal(StringBuffer buffer,
- int index)
- {
- buffer.append(index).append(",");
- }
-
- /**
- * Generates a last normal item.
- */
- protected void lastNormal(StringBuffer buffer,
- int index)
- {
- buffer.append(index);
- }
-
- /**
- * Generates a non last enhanced item.
- */
- protected void enhanced(StringBuffer buffer,
- int index)
- {
- buffer.append("-").append(index).append("-,");
- }
-
- /**
- * Generates a last enhanced item.
- */
- protected void lastEnhanced(StringBuffer buffer,
- int index)
- {
- buffer.append("-").append(index).append("-");
- }
-
- /**
- * Generates a gap.
- */
- protected void gap(StringBuffer buffer)
- {
- buffer.append(" ... ");
- }
-
- /**
- * Generates a separator.
- */
- protected void separe(StringBuffer buffer)
- {
- buffer.append(", ");
- }
-
- /**
- * Do the job.
- */
- protected final String build(int size,
- int offset)
- {
- // Computes the boundaries a priori
- int l1 = 0;
- int r1 = left;
- int l2 = offset - (middle / 2);
- int r2 = offset + ((middle + 1) / 2);
- int l3 = size - right;
- int r3 = size;
-
- // Check that the left part is not bigger than the entire range
- if (size < r1)
- {
- r1 = size;
- }
-
- // Check that the right part does not span on the left one
- if (l3 < r1)
- {
- l3 = r1;
- }
-
- // Correct the left boundary of the mid part if necessary
- if (l2 < r1)
- {
- l2 = r1;
- }
-
- // Correct the right boundary of the mid part if necessary
- if (l3 < r2)
- {
- r2 = l3;
- }
-
- StringBuffer buffer = new StringBuffer();
- start(buffer);
-
- // Displays the left part
- range(buffer, l1, offset, r1);
-
- if (l2 < r2)
- {
- gap(buffer, r1, l2);
- range(buffer, l2, offset, r2);
- gap(buffer, r2, l3);
- range(buffer, l3, offset, r3);
- }
- else if (l3 < r3)
- {
- gap(buffer, r1, l3);
- range(buffer, l3, offset, r3);
- }
-
- end(buffer);
-
- return buffer.toString();
- }
-
- private void gap(StringBuffer buffer,
- int from,
- int to)
- {
- if (from < to)
- {
- gap(buffer);
- }
- else if (from == to)
- {
- separe(buffer);
- }
- }
-
- /**
- * @param buffer the output buffer
- * @param from inclusive
- * @param offset the highlighted offset
- * @param to exclusive
- */
- private void range(StringBuffer buffer,
- int from,
- int offset,
- int to)
- {
- boolean last = from < to--;
- if ((from <= offset) && (offset <= to))
- {
- while (from < offset)
- {
- normal(buffer, from++);
- }
-
- if (from < to)
- {
- enhanced(buffer, from++);
- }
- while (from < to)
- {
- normal(buffer, from++);
- }
-
- if (last)
- {
- if (offset == from)
- {
- lastEnhanced(buffer, from);
- }
- else
- {
- lastNormal(buffer, from);
- }
- }
- }
- else
- {
- while (from < to)
- {
- normal(buffer, from++);
- }
-
- if (last)
- {
- lastNormal(buffer, from);
- }
- }
- }
-}
\ No newline at end of file
Deleted: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Time.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Time.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/helper/Time.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -1,84 +0,0 @@
-/*****************************************
- * *
- * JBoss Portal: The OpenSource Portal *
- * *
- * Forums JBoss Portlet *
- * *
- * Distributable under GPL license. *
- * See terms of license at gnu.org. *
- * *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.Date;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 878 $
- */
-public class Time
-{
- /**
- * DOCUMENT_ME
- */
- public static final int SAME_DATE = 0x01;
-
- /**
- * DOCUMENT_ME
- */
- public static final int LEFT_NULL = 0x02;
-
- /**
- * DOCUMENT_ME
- */
- public static final int RIGHT_NULL = 0x04;
-
- /**
- * DOCUMENT_ME
- */
- public static final int BOTH_NULL = 0x08;
-
- /**
- * DOCUMENT_ME
- */
- public static final int LEFT_AFTER = 0x10;
-
- /**
- * DOCUMENT_ME
- */
- public static final int RIGHT_AFTER = 0x20;
-
- /**
- * DOCUMENT_ME
- *
- * @param left DOCUMENT_ME
- * @param right DOCUMENT_ME
- * @return DOCUMENT_ME
- */
- public static int compare(Date left,
- Date right)
- {
- if (left == null)
- {
- return (right == null) ? BOTH_NULL : LEFT_NULL;
- }
-
- if (right == null)
- {
- return (left == null) ? BOTH_NULL : RIGHT_NULL;
- }
-
- if (left.equals(right))
- {
- return SAME_DATE;
- }
- else if (left.after(right))
- {
- return LEFT_AFTER;
- }
- else
- {
- return RIGHT_AFTER;
- }
- }
-}
\ No newline at end of file
Modified: labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2007-02-16 23:24:01 UTC (rev 9564)
@@ -15,11 +15,6 @@
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.filter.CommandFilter;
-import org.jboss.portal.common.command.filter.CompositeFilter;
-import org.jboss.portal.common.command.filter.ExecuteFilter;
-import org.jboss.portal.common.command.result.Result;
import org.jboss.portal.core.modules.AbstractModule;
import org.jboss.portal.core.modules.ModuleException;
import org.jboss.portal.core.model.User;
@@ -27,7 +22,6 @@
import org.jboss.portlet.command.ActionCommand;
import org.jboss.portlet.forums.ForumsConstants;
import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.interceptors.FloodControlInterceptor;
import org.jboss.portlet.forums.model.Attachment;
import org.jboss.portlet.forums.model.Category;
import org.jboss.portlet.forums.model.Forum;
@@ -77,11 +71,11 @@
// private final ResourceCacheInvalidatorInterceptor resourceInterceptor;
// private final IndexInterceptor indexInterceptor;
- private CompositeFilter compositeInterceptor;
+// private CompositeFilter compositeInterceptor;
// private NotificationInterceptor notificationInterceptor;
- private FloodControlInterceptor floodControlInterceptor;
- private ExecuteFilter executeInterceptor;
- private CommandFilter chain;
+// private FloodControlInterceptor floodControlInterceptor;
+// private ExecuteFilter executeInterceptor;
+// private CommandFilter chain;
protected void startService() throws Exception
{
@@ -92,21 +86,21 @@
notificationEngine = new NotificationEngine(this);
notificationEngine.setFrom(fromAddress);
// Define the chain of interceptors
- chain = compositeInterceptor = new CompositeFilter();
+// chain = compositeInterceptor = new CompositeFilter();
// resourceInterceptor = new ResourceCacheInvalidatorInterceptor();
// indexInterceptor = new IndexInterceptor();
- floodControlInterceptor = new FloodControlInterceptor();
- floodControlInterceptor.setFloodInterval(floodInterval);
- executeInterceptor = new ExecuteFilter();
+// floodControlInterceptor = new FloodControlInterceptor();
+// floodControlInterceptor.setFloodInterval(floodInterval);
+// executeInterceptor = new ExecuteFilter();
// Assemble the chain
// compositeInterceptor.setNext(resourceInterceptor);
// resourceInterceptor.setNext(indexInterceptor);
// indexInterceptor.setNext(notificationInterceptor);
- compositeInterceptor.setNext(executeInterceptor);
+// compositeInterceptor.setNext(executeInterceptor);
// notificationInterceptor.setNext(floodControlInterceptor);
- floodControlInterceptor.setNext(executeInterceptor);
+// floodControlInterceptor.setNext(executeInterceptor);
}
/**
@@ -1690,12 +1684,6 @@
throw new ModuleException(message, e);
}
}
-
- public Result invoke(ActionCommand cmd) throws CommandException
- {
- //throw new UnsupportedOperationException();
- return chain.filter(cmd);
- }
public void processNotifications (Integer postId, int watchType , String postUrl , String replyUrl ) {
notificationEngine.schedule(postId, watchType, postUrl , replyUrl );
Modified: labs/jbossforums/branches/forums22/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml
===================================================================
--- labs/jbossforums/branches/forums22/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml 2007-02-16 23:14:54 UTC (rev 9563)
+++ labs/jbossforums/branches/forums22/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml 2007-02-16 23:24:01 UTC (rev 9564)
@@ -3,88 +3,7 @@
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd /opt/SUNWps/dtd/portlet.xsd"
- version="1.0">
- <portlet>
- <portlet-name>ForumsPortlet</portlet-name>
- <portlet-class>org.jboss.portlet.forums.ForumsPortlet</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>VIEW</portlet-mode>
- <portlet-mode>EDIT</portlet-mode>
- </supports>
- <supported-locale>en</supported-locale>
- <resource-bundle>Resource</resource-bundle>
- <portlet-info>
- <title>Forums portlet</title>
- </portlet-info>
- <security-role-ref>
- <role-name>ForumsAdmin</role-name>
- <role-link>Admin</role-link>
- </security-role-ref>
- <security-role-ref>
- <role-name>ForumsModerator</role-name>
- <role-link>Admin</role-link>
- </security-role-ref>
- <security-role-ref>
- <role-name>ForumsAttachments</role-name>
- <role-link>Admin</role-link>
- </security-role-ref>
- <security-role-ref>
- <role-name>ForumsPolls</role-name>
- <role-link>Admin</role-link>
- </security-role-ref>
- <security-role-ref>
- <role-name>ForumsUser</role-name>
- <role-link>User</role-link>
- </security-role-ref>
- <portlet-preferences>
- <preference>
- <name>notifyreply</name>
- <value>1</value>
- </preference>
- <preference>
- <name>allowhtml</name>
- <value>1</value>
- <!--
- <read-only>true</read-only>
- -->
- </preference>
- <preference>
- <name>postorder</name>
- <value>ascending</value>
- </preference>
- <preference>
- <name>topicsperforum</name>
- <value>10</value>
- </preference>
- <preference>
- <name>postspertopic</name>
- <value>15</value>
- </preference>
- <preference>
- <name>dateformat</name>
- <value>EEE MMM d, yyyy HH:mm aaa</value>
- </preference>
- <preference>
- <name>summarymode</name>
- <value>0</value>
- </preference>
- <preference>
- <name>summarytopiclimit</name>
- <value>6</value>
- </preference>
- <preference>
- <name>summarytopicdays</name>
- <value>20</value>
- </preference>
- <preference>
- <name>summarytopicreplies</name>
- <value>15</value>
- </preference>
-
-
- </portlet-preferences>
- </portlet>
+ version="1.0">
<portlet>
<portlet-name>JSFForumsPortlet</portlet-name>
More information about the jboss-svn-commits
mailing list