[jboss-svn-commits] JBL Code SVN: r13498 - in labs/jbossforums/branches/forums26/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:54:22 EDT 2007
Author: dejp
Date: 2007-07-14 09:54:22 -0400 (Sat, 14 Jul 2007)
New Revision: 13498
Added:
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java
Modified:
labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
Log:
JBFORUMS-221
Added: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java (rev 0)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/event/FloodControlListener.java 2007-07-14 13:54:22 UTC (rev 13498)
@@ -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/forums26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2007-07-14 13:52:35 UTC (rev 13497)
+++ labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2007-07-14 13:54:22 UTC (rev 13498)
@@ -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>
 
<h:commandButton action="#{newTopic.cancel}" value="${resource.Cancel}" accesskey="c" tabindex="7" styleClass="mainoption"/>
</td>
Modified: labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml 2007-07-14 13:52:35 UTC (rev 13497)
+++ labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml 2007-07-14 13:54:22 UTC (rev 13498)
@@ -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>
 
<h:commandButton action="#{replyTopic.cancel}" value="${resource.Cancel}" accesskey="c" tabindex="7" styleClass="mainoption"/>
</td>
Modified: labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2007-07-14 13:52:35 UTC (rev 13497)
+++ labs/jbossforums/branches/forums26/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2007-07-14 13:54:22 UTC (rev 13498)
@@ -757,7 +757,9 @@
styleClass="liteoption" onclick="return checkForm();"/>
 
<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