[jboss-svn-commits] JBL Code SVN: r13493 - in labs/jbossforums/branches/forums101P22/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:06:21 EDT 2007
Author: dejp
Date: 2007-07-14 09:06:20 -0400 (Sat, 14 Jul 2007)
New Revision: 13493
Added:
labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java
Modified:
labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
Log:
JBFORUMS-221
Added: labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java (rev 0)
+++ labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java 2007-07-14 13:06:20 UTC (rev 13493)
@@ -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.core.model.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/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2007-07-14 13:03:19 UTC (rev 13492)
+++ labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2007-07-14 13:06:20 UTC (rev 13493)
@@ -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/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml 2007-07-14 13:03:19 UTC (rev 13492)
+++ labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml 2007-07-14 13:06:20 UTC (rev 13493)
@@ -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/forums101P22/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2007-07-14 13:03:19 UTC (rev 13492)
+++ labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2007-07-14 13:06:20 UTC (rev 13493)
@@ -830,7 +830,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