[jboss-svn-commits] JBL Code SVN: r13497 - in labs/jbossforums/trunk/forums/src: resources/portal-forums-war/views/topics and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Jul 14 09:52:35 EDT 2007


Author: dejp
Date: 2007-07-14 09:52:35 -0400 (Sat, 14 Jul 2007)
New Revision: 13497

Added:
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java
Modified:
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
Log:
JBFORUMS-221

Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java	                        (rev 0)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java	2007-07-14 13:52:35 UTC (rev 13497)
@@ -0,0 +1,58 @@
+package org.jboss.portlet.forums.ui.event;
+
+import java.util.Date;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import org.jboss.portal.identity.User;
+import org.jboss.portlet.forums.ui.BaseController;
+import org.jboss.portlet.forums.ui.PortalUtil;
+
+public class FloodControlListener implements ActionListener {
+
+    private long floodInterval;
+
+    public FloodControlListener() {
+        super();
+        
+        try 
+        {
+            floodInterval = BaseController.getForumsModule().getFloodInterval();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public void processAction(ActionEvent event) throws AbortProcessingException {
+        
+        long lastPostTime = 0;
+        
+        try 
+        {
+            User user = PortalUtil.getUser();
+            
+            Date lastPost = BaseController.getForumsModule().findLastPostDateForUser(user);
+            
+            if (lastPost != null)
+            {
+                lastPostTime = lastPost.getTime();
+            }
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if (lastPostTime > 0)
+        {
+           long now = new Date().getTime();
+           
+           long interval = (now - lastPostTime) / 1000;
+           
+           if (interval < floodInterval)
+           {
+               throw new AbortProcessingException("interval < floodInterval");
+           }
+        }
+    }
+    
+}

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml	2007-07-14 13:45:03 UTC (rev 13496)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml	2007-07-14 13:52:35 UTC (rev 13497)
@@ -630,7 +630,9 @@
 	      <!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
 	      <h:commandButton action="#{newTopic.execute}" value="${resource.Submit}" 	      
 	      styleClass="mainoption"
-	      accesskey="s" tabindex="6"/>	      	
+	      accesskey="s" tabindex="6">
+            <f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
+          </h:commandButton>
 	      &#160;
 	      <h:commandButton action="#{newTopic.cancel}" value="${resource.Cancel}" accesskey="c" tabindex="7" styleClass="mainoption"/>	      
 	   </td>

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml	2007-07-14 13:45:03 UTC (rev 13496)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml	2007-07-14 13:52:35 UTC (rev 13497)
@@ -539,7 +539,9 @@
 	      <!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
 	      <h:commandButton action="#{replyTopic.execute}" value="${resource.Submit}" 	      
 	      styleClass="mainoption"
-	      accesskey="s" tabindex="6"/>	      	
+	      accesskey="s" tabindex="6">
+            <f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
+          </h:commandButton>
 	      &#160;
 	      <h:commandButton action="#{replyTopic.cancel}" value="${resource.Cancel}" accesskey="c" tabindex="7" styleClass="mainoption"/>	      
 	   </td>

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	2007-07-14 13:45:03 UTC (rev 13496)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml	2007-07-14 13:52:35 UTC (rev 13497)
@@ -759,7 +759,9 @@
 	      		  	styleClass="liteoption" onclick="return checkForm();"/>
                   	&#160;                  
                   	<h:commandButton action="#{replyTopic.executeInstantReply}" value="${resource.Submit}" 	      
-	      		  	styleClass="mainoption" onclick="return checkForm();"/>	      	
+	      		  	styleClass="mainoption" onclick="return checkForm();">
+                      <f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
+                    </h:commandButton>    	
                </span>
              </h:form>
             </td>




More information about the jboss-svn-commits mailing list