[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum ...
Christian Bauer
christian at hibernate.org
Fri Jan 4 17:28:52 EST 2008
User: cbauer
Date: 08/01/04 17:28:52
Modified: examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum
ForumQuery.java ReplyHome.java TopicHome.java
ForumPreferences.java
Log:
Configurable forum reply e-mail notification and Safari3 fixes
Revision Changes Path
1.6 +1 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumQuery.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ForumQuery.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumQuery.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ForumQuery.java 4 Jan 2008 00:21:28 -0000 1.5
+++ ForumQuery.java 4 Jan 2008 22:28:51 -0000 1.6
@@ -95,6 +95,7 @@
@Observer(value = {"Forum.topicListRefresh", "PersistenceContext.filterReset"}, create = false)
public void loadTopics() {
+ log.debug("loading forum topics");
pager.setNumOfRecords( forumDAO.findTopicCount(currentDirectory) );
if (pager.getNumOfRecords() == 0) {
1.5 +22 -4 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ReplyHome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ReplyHome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ReplyHome.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ReplyHome.java 3 Jan 2008 09:06:04 -0000 1.4
+++ ReplyHome.java 4 Jan 2008 22:28:51 -0000 1.5
@@ -2,13 +2,14 @@
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.faces.Renderer;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.AuthorizationException;
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.FlushModeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.*;
import org.jboss.seam.wiki.core.action.CommentHome;
+import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
+import org.jboss.seam.wiki.preferences.Preferences;
import static javax.faces.application.FacesMessage.SEVERITY_INFO;
@@ -22,6 +23,23 @@
markTopicRead();
}
+ @In(create = true)
+ private Renderer renderer;
+
+ @Observer(value = "Comment.persisted", create = false)
+ public void notifyOriginalPoster() {
+ // Triggered by superclass after reply was persisted
+ if (documentHome.getInstance().macroPresent(TopicHome.TOPIC_NOTIFY_ME_MACRO)
+ && !documentHome.getInstance().getCreatedBy().getUsername().equals(
+ getInstance().getCreatedBy().getUsername()
+ )) {
+ getLog().debug("sending confirmation e-mail to original poster");
+ renderer.render("/themes/"
+ + ((WikiPreferences) Preferences.getInstance("Wiki")).getThemeName()
+ + "/mailtemplates/forumNotifyReply.xhtml");
+ }
+ }
+
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public String replyToDocument() {
1.4 +25 -3 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TopicHome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- TopicHome.java 19 Dec 2007 04:29:25 -0000 1.3
+++ TopicHome.java 4 Jan 2008 22:28:51 -0000 1.4
@@ -1,6 +1,7 @@
package org.jboss.seam.wiki.plugin.forum;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.faces.Redirect;
import org.jboss.seam.annotations.*;
import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.core.Conversation;
@@ -10,6 +11,7 @@
import org.jboss.seam.wiki.core.model.WikiDirectory;
import org.jboss.seam.wiki.core.model.WikiDocument;
import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+import org.jboss.seam.wiki.preferences.Preferences;
import static javax.faces.application.FacesMessage.SEVERITY_INFO;
@@ -17,11 +19,14 @@
@Scope(ScopeType.CONVERSATION)
public class TopicHome extends DocumentHome {
+ public static final String TOPIC_NOTIFY_ME_MACRO = "forumNotifyReplies";
+
@In
WikiDirectory currentDirectory;
private boolean showForm = false;
private boolean sticky = false;
+ private boolean notifyReplies = false;
/* -------------------------- Basic Overrides ------------------------------ */
@@ -39,6 +44,9 @@
public void create() {
super.create();
setParentNodeId(currentDirectory.getId());
+
+ Boolean preferencesNotifyReplies = ((ForumPreferences) Preferences.getInstance("Forum")).getNotifyMeOfReplies();
+ notifyReplies = preferencesNotifyReplies != null && preferencesNotifyReplies;
}
@Override
@@ -77,17 +85,22 @@
@Override
protected boolean beforePersist() {
+ // TODO: Use macro parameters for "sticky" and "notify" options instead of additional macros
if (isSticky())
- getInstance().setHeader(
- getInstance().getHeader().replaceAll("forumPosting", "forumStickyPosting")
- );
+ getInstance().replaceHeaderMacro("forumPosting", "forumStickyPosting");
+ if (isNotifyReplies())
+ getInstance().addHeaderMacro(TOPIC_NOTIFY_ME_MACRO);
return super.beforePersist();
}
@Override
public String persist() {
+ // Only owners or admins can edit topics
+ getInstance().setWriteAccessLevel(org.jboss.seam.wiki.core.model.Role.ADMINROLE_ACCESSLEVEL);
+
String outcome = super.persist();
if (outcome != null) {
+
endConversation();
}
return null; // Prevent navigation
@@ -139,6 +152,7 @@
/* -------------------------- Internal Methods ------------------------------ */
private void endConversation() {
+ getLog().debug("ending conversation and hiding topic form");
showForm = false;
Conversation.instance().end();
getEntityManager().clear(); // Need to force re-read in the topic list refresh
@@ -167,6 +181,14 @@
this.sticky = sticky;
}
+ public boolean isNotifyReplies() {
+ return notifyReplies;
+ }
+
+ public void setNotifyReplies(boolean notifyReplies) {
+ this.notifyReplies = notifyReplies;
+ }
+
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public void newTopic() {
setEdit(true);
1.3 +10 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumPreferences.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ForumPreferences.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumPreferences.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ForumPreferences.java 30 Dec 2007 02:33:26 -0000 1.2
+++ ForumPreferences.java 4 Jan 2008 22:28:51 -0000 1.3
@@ -20,7 +20,17 @@
@NotNull
private Long topicsPerPage;
+ @PreferenceProperty(
+ description = "#{messages['forum.preferences.NotifyMeOfReplies']}",
+ visibility = PreferenceVisibility.USER
+ )
+ private Boolean notifyMeOfReplies;
+
public Long getTopicsPerPage() {
return topicsPerPage;
}
+
+ public Boolean getNotifyMeOfReplies() {
+ return notifyMeOfReplies;
+ }
}
More information about the jboss-cvs-commits
mailing list