[seam-commits] Seam SVN: r13508 - in branches/community/Seam_2_2/examples/wiki: src/main/org/jboss/seam/wiki/core/action and 8 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jul 26 05:39:06 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-07-26 05:39:06 -0400 (Mon, 26 Jul 2010)
New Revision: 13508
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java
branches/community/Seam_2_2/examples/wiki/view/themes/default/img/btn.report.bg.gif
branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/img/btn.report.bg.gif
branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/img/btn.report.bg.gif
Modified:
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml
branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css
branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css
branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css
Log:
add report as spam button, added spam report to admin screen
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-26 09:39:06 UTC (rev 13508)
@@ -301,6 +301,10 @@
lacewiki.label.commentsDisplay.Comment=comment
lacewiki.label.commentsDisplay.Comments=comments
lacewiki.label.commentsDisplay.CommentThread=the whole comment thread
+lacewiki.button.commentsDisplay.ReportCommentAsSpam=Report as spam
+lacewiki.label.AreYouSureYouWantToReport=Are you sure you want to report the comment made by
+lacewiki.label.AsSpam=as spam
+lacewiki.label.ReportThankYou=Thank you for your assistance, the comment has been reported.
lacewiki.button.commentsDisplay.RemoveComment=Remove
lacewiki.button.commentsDisplay.ReplyTo=Reply
lacewiki.button.commentsDisplay.Quote=Quote
@@ -369,6 +373,7 @@
lacewiki.button.adminHome.LinkProtocols.accesskey=L
lacewiki.button.adminHome.Preferences=P<u>r</u>eferences
lacewiki.button.adminHome.Preferences.accesskey=R
+lacewiki.button.adminHome.SpamReport=Spam Reports
lacewiki.button.adminHome.SaveSettings=<u>S</u>ave Settings
lacewiki.button.adminHome.SaveSettings.accesskey=S
lacewiki.label.adminHome.SearchIndex=Search Index
@@ -378,6 +383,11 @@
lacewiki.button.adminHome.RebuildIndex=Rebuild Index
lacewiki.label.adminHome.Prefix=Prefix
lacewiki.label.adminHome.TargetLink=Target Link
+
+lacewiki.label.adminHome.spamReport.Reporter=Reporter
+lacewiki.label.adminHome.spamReport.Comment=Comment
+lacewiki.label.adminHome.spamReport.Poster=Comment Poster
+
lacewiki.label.adminHome.TargetWithPlaceHolder=Target with [[link]] placeholder
lacewiki.label.adminHome.NotAvailableForSkin=Administration is not available with this skin.
lacewiki.label.adminHome.plugins.InstalledPlugins=Installed Plugins
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -22,6 +22,7 @@
import org.jboss.seam.security.Identity;
import org.jboss.seam.wiki.core.model.LinkProtocol;
import org.jboss.seam.wiki.core.model.User;
+import org.jboss.seam.wiki.core.model.WikiSpamReport;
import org.jboss.seam.wiki.core.search.IndexManager;
import org.jboss.seam.wiki.core.search.metamodel.SearchRegistry;
import org.jboss.seam.wiki.core.search.metamodel.SearchableEntity;
@@ -115,6 +116,16 @@
public LinkProtocol getLinkProtocol() {
return linkProtocol;
}
+
+ @DataModel(value = "spamReports")
+ private List<WikiSpamReport> spamReports;
+
+ @Factory("spamReports")
+ public void loadSpamReports()
+ {
+ spamReports = entityManager.createQuery("select r from WikiSpamReport r")
+ .getResultList();
+ }
public void addLinkProtocol() {
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -185,7 +185,31 @@
return null; // Prevent navigation
}
+ /**
+ * Creates a spam report for the selected comment
+ *
+ * @param commentId
+ * @return
+ */
+ public String reportAsSpam(Long commentId)
+ {
+ WikiSpamReport report = new WikiSpamReport();
+ setNodeId(commentId);
+ report.setComment(getInstance());
+ report.setReporter(currentUser);
+
+ getEntityManager().persist(report);
+
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ INFO,
+ "lacewiki.label.ReportThankYou",
+ "Thank you for your assistance."
+ );
+
+ return "success";
+ }
+
@Override
protected NodeRemover getNodeRemover() {
return (CommentNodeRemover)Component.getInstance(CommentNodeRemover.class);
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -81,6 +81,9 @@
if ("Comment".equals(name) && "create".equals(action)) {
return checkCommentCreate((WikiDocument)args[0]);
} else
+ if ("Comment".equals(name) && "reportSpam".equals(action)) {
+ return checkCommentReportSpam((WikiNode)args[0]);
+ }
if ("Comment".equals(name) && "delete".equals(action)) {
return checkCommentDelete((WikiNode)args[0]);
} else
@@ -230,6 +233,11 @@
doc.isEnableComments() && doc.isEnableCommentForm()) return true;
return false;
}
+
+ private boolean checkCommentReportSpam(WikiNode node) {
+ if (currentAccessLevel > Role.GUESTROLE_ACCESSLEVEL) return true;
+ return false;
+ }
/*
Only admins can delete comments.
Added: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiSpamReport.java 2010-07-26 09:39:06 UTC (rev 13508)
@@ -0,0 +1,68 @@
+package org.jboss.seam.wiki.core.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * Stores user reports of comment spam
+ *
+ * @author Shane Bryzak
+ *
+ */
+ at Entity
+ at Inheritance(strategy = InheritanceType.JOINED)
+ at Table(name = "WIKI_SPAM_REPORT")
+public class WikiSpamReport implements Serializable
+{
+ private static final long serialVersionUID = -5259814434570251579L;
+
+ private Long reportId;
+ private WikiComment comment;
+ private User reporter;
+
+ @Id
+ @GeneratedValue(generator = "wikiSequenceGenerator")
+ @Column(name = "REPORT_ID")
+ public Long getReportId()
+ {
+ return reportId;
+ }
+
+ public void setReportId(Long reportId)
+ {
+ this.reportId = reportId;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "COMMENT_ID")
+ public WikiComment getComment()
+ {
+ return comment;
+ }
+
+ public void setComment(WikiComment comment)
+ {
+ this.comment = comment;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "REPORTER_USER_ID")
+ public User getReporter()
+ {
+ return reporter;
+ }
+
+ public void setReporter(User reporter)
+ {
+ this.reporter = reporter;
+ }
+}
Modified: branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-26 09:39:06 UTC (rev 13508)
@@ -87,6 +87,10 @@
accesskey="#{messages['lacewiki.button.adminHome.Preferences.accesskey']}">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.Preferences']}"/>
</a></li>
+ <li id="spamReportTab"><a href="#spamReport">
+ <h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.SpamReport']}"/>
+ </a></li>
+
</ul>
<div id="formTabsTitle"/>
@@ -246,7 +250,62 @@
</ui:include>
</div>
</div>
+
+ <div id="spamReport" style="padding: 20px">
+ <h:dataTable id="spamReportTable" var="report"
+ value="#{spamReports}"
+ rendered="#{spamReports.rowCount >0}"
+ styleClass="datatable topLeftBottomBorder"
+ headerClass="regularHeader rightBorder smallFont"
+ columnClasses="tenPercentColumn rightBorder alignLeft,
+ defaultColumn rightBorder alignLeft wrapWhitespace,
+ tenPercentColumn rightBorder alignCenter"
+ rowClasses="rowOdd,rowEven"
+ cellpadding="0" cellspacing="0" border="0">
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.spamReport.Reporter']}
+ </f:facet>
+
+ <h:outputLink value="#{wikiURLRenderer.renderUserProfileURL(report.reporter)}">
+ <h:outputText value="#{report.reporter.fullname}"/>
+ </h:outputLink>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.spamReport.Comment']}
+ </f:facet>
+
+ <s:div styleClass="commentText" rendered="#{report.comment.useWikiText and not empty report.comment.parent.areaNumber}">
+ <s:formattedText value="#{report.comment.content}"
+ linkStyleClass="regularLink"
+ brokenLinkStyleClass="brokenLink"
+ attachmentLinkStyleClass="regularLink"
+ thumbnailLinkStyleClass="regularLink"
+ enableMacroRendering="false"/>
+ </s:div>
+ <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name != report.comment.subject}" style="margin-top:15px;">
+ <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
+ </s:div>
+ <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name == report.comment.subject}">
+ <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
+ </s:div>
+
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.spamReport.Poster']}
+ </f:facet>
+
+ <h:outputLink value="#{wikiURLRenderer.renderUserProfileURL(report.comment.createdBy)}">
+ <h:outputText value="#{report.comment.createdBy}"/>
+ </h:outputLink>
+ </h:column>
+
+ </h:dataTable>
+ </div>
+
</div>
<div class="formControls wideLabels">
Modified: branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/docDisplay_d.xhtml 2010-07-26 09:39:06 UTC (rev 13508)
@@ -231,6 +231,27 @@
<ui:param name="titlePlural" value="#{messages['lacewiki.label.commentsDisplay.Comments']}"/>
<ui:define name="controls">
+ <s:fragment rendered="#{not commentHome.showForm and s:hasPermission('Comment', 'reportSpam', currentDocument)}">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.commentsDisplay.ReportCommentAsSpam']}"/>
+ <ui:param name="linkClass" value="buttonReport"/>
+ <ui:param name="jsFunctionName" value="reportCommentAsSpamId#{c.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToReport']
+ .concat(' ')
+ .concat(c.ownedByRegularUser ? c.createdBy.fullname : c.fromUserName)
+ .concat(' ')
+ .concat(messages['lacewiki.label.AsSpam'])
+ .concat('?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="commentDisplayForm, messageBoxContainer"
+ action="#{commentHome.reportAsSpam(c.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </s:fragment>
+
<h:panelGroup>
<s:fragment rendered="#{not commentHome.showForm and s:hasPermission('Comment', 'create', documentHome.instance)}">
Modified: branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/themes/default/css/template.css 2010-07-26 09:39:06 UTC (rev 13508)
@@ -448,6 +448,13 @@
font-size: 10px;
}
+.buttonReport {
+ background: #fff url(../img/btn.report.bg.gif) 0 0 repeat-x;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+ font-size: 10px;
+}
+
.buttonLabel{
color: #fff;
font-weight: bold;
Added: branches/community/Seam_2_2/examples/wiki/view/themes/default/img/btn.report.bg.gif
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_2/examples/wiki/view/themes/default/img/btn.report.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2010-07-26 09:39:06 UTC (rev 13508)
@@ -465,6 +465,12 @@
margin: 0 5px 0 5px;
}
+.buttonReport {
+ background: #fff url(../img/btn.report.bg.gif) 0 0 repeat-x;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.buttonLabel{
color: #fff;
font-weight: bold;
Added: branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/img/btn.report.bg.gif
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_2/examples/wiki/view/themes/inrelationto/img/btn.report.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2010-07-26 09:23:20 UTC (rev 13507)
+++ branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2010-07-26 09:39:06 UTC (rev 13508)
@@ -555,6 +555,12 @@
margin: 0 5px 0 5px;
}
+.buttonReport {
+ background: #fff url(../img/btn.report.bg.gif) 0 0 repeat-x;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.buttonLabel{
color: #fff;
font-weight: bold;
Added: branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/img/btn.report.bg.gif
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_2/examples/wiki/view/themes/sfwkorg/img/btn.report.bg.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the seam-commits
mailing list