|
From: <jbo...@li...> - 2006-07-07 17:50:43
|
Author: soh...@jb...
Date: 2006-07-07 13:50:33 -0400 (Fri, 07 Jul 2006)
New Revision: 4946
Modified:
labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java
labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java
labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java
labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java
labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java
labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java
labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties
labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml
labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/web.xml
labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
Log:
Added check to make sure a topic is not changed (no reply, edit post, delete post) if its locked
Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-07-07 17:50:33 UTC (rev 4946)
@@ -69,6 +69,8 @@
public static final String SUMMARY_REPLIES_KEY = "summarytopicreplies";
public static final String TOPICS_FORUM_KEY = "topicsperforum";
public static final String POSTS_TOPIC_KEY = "postspertopic";
+ public static final String TOPIC_LOCKED_ERR_KEY = "topiclockederr";
+ public static final String BUNDLE_NAME = "ResourceJSF";
/**
* DOCUMENT_ME
Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-07-07 17:50:33 UTC (rev 4946)
@@ -22,8 +22,10 @@
package org.jboss.portlet.forums.ui;
//core java classes
+import java.util.Locale;
import java.util.Map;
import java.util.Iterator;
+import java.util.ResourceBundle;
//logging related
@@ -227,4 +229,24 @@
return msg;
}
+
+ /**
+ *
+ *
+ */
+ public static String getBundleMessage(String bundleName,String messageKey)
+ {
+ String bundleMessage = null;
+
+ //Getting ResourceBundle with current Locale
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ UIViewRoot uiRoot = ctx.getViewRoot();
+ Locale locale = uiRoot.getLocale();
+ ClassLoader ldr = Thread.currentThread().getContextClassLoader();
+ ResourceBundle bundle = ResourceBundle.getBundle(bundleName,locale,ldr);
+
+ bundleMessage = bundle.getString(messageKey);
+
+ return bundleMessage;
+ }
}
Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java 2006-07-07 17:50:33 UTC (rev 4946)
@@ -68,6 +68,15 @@
Post post = BaseController.getForumsModule().findPostById(new Integer(postId));
Topic topic = post.getTopic();
Forum forum = topic.getForum();
+
+ //make sure this topic is not locked
+ if(topic.getStatus()==Constants.TOPIC_LOCKED)
+ {
+ //should not allow posting a reply since the topic is locked
+ throw new Exception(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME,Constants.TOPIC_LOCKED_ERR_KEY));
+ }
+
+
boolean isFirstPost = false;
boolean isLastPost = false;
if(topic.getFirstPost().getId().intValue()==post.getId().intValue())
Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java 2006-07-07 17:50:33 UTC (rev 4946)
@@ -154,6 +154,15 @@
//setup the business objects to be updated
Post post = BaseController.getForumsModule().findPostById(new Integer(this.postId));
Topic topic = post.getTopic();
+
+ //make sure this topic is not locked
+ if(topic.getStatus()==Constants.TOPIC_LOCKED)
+ {
+ //should not allow posting a reply since the topic is locked
+ throw new Exception(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME,Constants.TOPIC_LOCKED_ERR_KEY));
+ }
+
+
boolean isFirstPost = false;
if(topic.getFirstPost().getId().intValue()==post.getId().intValue())
{
Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java 2006-07-07 17:50:33 UTC (rev 4946)
@@ -548,6 +548,7 @@
*/
public String cancel()
{
+ this.cleanup();
return Constants.CANCEL;
}
Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java 2006-07-07 17:50:33 UTC (rev 4946)
@@ -173,6 +173,12 @@
Topic topic = BaseController.getForumsModule().findTopicById(new Integer(topicId));
Poster poster = PortalUtil.getPoster();
+ //make sure this topic is not locked
+ if(topic.getStatus()==Constants.TOPIC_LOCKED)
+ {
+ //should not allow posting a reply since the topic is locked
+ throw new Exception(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME,Constants.TOPIC_LOCKED_ERR_KEY));
+ }
//actually post a reply to this topic in the forum
Post post = BaseController.getForumsModule().createPost(topic,
@@ -184,8 +190,7 @@
);
poster.incrementPostCount();
-
-
+
//setup the navigation state
navState = Constants.SUCCESS;
@@ -223,11 +228,18 @@
public String executeInstantReply()
{
String navState = null;
+
+ //setup the instantReply message
String message = this.getMessage();
this.start();
this.setMessage(message);
+
+ //make the actual post
this.execute();
+
+ //setup proper navigation
navState = "instantReply";
+
return navState;
}
}
Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-07-07 17:50:33 UTC (rev 4946)
@@ -2350,3 +2350,5 @@
Message_wrote=wrote
Category_delete=Delete Category
+
+topiclockederr=This topic is locked. Modifying any posts or replying to this topic is not allowed
Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-07-07 17:50:33 UTC (rev 4946)
@@ -79,14 +79,15 @@
<function-signature>float getVotePercent(org.jboss.portlet.forums.model.Poll,org.jboss.portlet.forums.model.PollOption)</function-signature>
</function>
- <!--
- Method for processing posts' messages.
- -->
- <function>
+ <!--
+ Method for processing posts's messages.
+ -->
+ <function>
<function-name>formatMessage</function-name>
<function-class>org.jboss.portlet.forums.ui.PortalUtil</function-class>
<function-signature>java.lang.String formatMessage(java.lang.String,boolean)</function-signature>
</function>
+
<!--
function to get theme URL location
-->
Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/web.xml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/web.xml 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/web.xml 2006-07-07 17:50:33 UTC (rev 4946)
@@ -8,7 +8,10 @@
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
-version="2.4">
+version="2.4">
+ <!--listener>
+ <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+ </listener-->
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-07-07 17:41:07 UTC (rev 4945)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-07-07 17:50:33 UTC (rev 4946)
@@ -706,20 +706,19 @@
<input type="hidden" name="f" value="#{topic.topic.forum.id}"/>
<input type="hidden" name="t" value="#{topic.topic.id}"/>
<!-- add this reply and navigate to the page that will have this reply -->
- <input type="hidden" name="page" value="#{topic.pageNavigator.pageAfterAdd}"/>
-
+ <input type="hidden" name="page" value="#{topic.pageNavigator.pageAfterAdd}"/>
<span class="genmed">
<b>${resource.Instant_reply}</b>
<br/>
<br/>
- <h:inputTextarea id="message" value="#{replyTopic.message}" rows="10" cols="50" styleClass="post"></h:inputTextarea>
+ <h:inputTextarea id="message" value="#{replyTopic.message}" rows="10" cols="50" styleClass="post"></h:inputTextarea>
<br/>
<br/>
- <h:commandButton action="#{replyTopic.startInstantReplyPreview}" value="${resource.Preview}"
- styleClass="liteoption" onclick="return checkForm();"/>
- &nbsp;
- <h:commandButton action="#{replyTopic.executeInstantReply}" value="${resource.Submit}"
- styleClass="mainoption" onclick="return checkForm();"/>
+ <h:commandButton action="#{replyTopic.startInstantReplyPreview}" value="${resource.Preview}"
+ styleClass="liteoption" onclick="return checkForm();"/>
+ &nbsp;
+ <h:commandButton action="#{replyTopic.executeInstantReply}" value="${resource.Submit}"
+ styleClass="mainoption" onclick="return checkForm();"/>
</span>
</h:form>
</td>
|