[jboss-svn-commits] JBL Code SVN: r13511 - in labs/jbossforums/branches/forums110P26/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 15:47:36 EDT 2007


Author: unibrew
Date: 2007-07-14 15:47:36 -0400 (Sat, 14 Jul 2007)
New Revision: 13511

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

Copied: labs/jbossforums/branches/forums110P26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java (from rev 13492, labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java)
===================================================================
--- labs/jbossforums/branches/forums110P26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java	                        (rev 0)
+++ labs/jbossforums/branches/forums110P26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java	2007-07-14 19:47:36 UTC (rev 13511)
@@ -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/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml	2007-07-14 18:49:31 UTC (rev 13510)
+++ labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml	2007-07-14 19:47:36 UTC (rev 13511)
@@ -757,7 +757,9 @@
             <!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
             <h:commandButton action="#{newTopic.execute}" value="${resource.Submit}"
                              styleClass="buttonMed"
-                             accesskey="s" tabindex="6"/>
+                             accesskey="s" tabindex="6">
+              <f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
+            </h:commandButton>
         </li>
         <li>
             <h:commandButton action="#{newTopic.cancel}" value="${resource.Cancel}"

Modified: labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml	2007-07-14 18:49:31 UTC (rev 13510)
+++ labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml	2007-07-14 19:47:36 UTC (rev 13511)
@@ -659,7 +659,9 @@
             <!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
             <h:commandButton action="#{replyTopic.execute}" value="${resource.Submit}"
                              styleClass="buttonMed"
-                             accesskey="s" tabindex="6"/>
+                             accesskey="s" tabindex="6">
+              <f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
+            </h:commandButton>
         </li>
         <li>
             <h:commandButton action="#{replyTopic.cancel}" value="${resource.Cancel}"

Modified: labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml	2007-07-14 18:49:31 UTC (rev 13510)
+++ labs/jbossforums/branches/forums110P26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml	2007-07-14 19:47:36 UTC (rev 13511)
@@ -828,7 +828,9 @@
                         <h:commandButton action="#{replyTopic.executeInstantReply}"
                                          value="${resource.Submit}"
                                          styleClass="buttonMed"
-                                         onclick="return checkForm();"/>
+                                         onclick="return checkForm();">
+                          <f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
+                        </h:commandButton>
                     </li>
                 </ul>
             </div>




More information about the jboss-svn-commits mailing list