mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-16 00:49:49 +08:00
- Comments: Comment moderation and the pending comments queue with related Admin.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045638
This commit is contained in:
parent
52793d5860
commit
0011f70e9a
@ -50,6 +50,9 @@ namespace Orchard.Comments.Controllers {
|
||||
case CommentIndexFilter.Approved:
|
||||
comments = _commentService.GetComments(CommentStatus.Approved);
|
||||
break;
|
||||
case CommentIndexFilter.Pending:
|
||||
comments = _commentService.GetComments(CommentStatus.Pending);
|
||||
break;
|
||||
case CommentIndexFilter.Spam:
|
||||
comments = _commentService.GetComments(CommentStatus.Spam);
|
||||
break;
|
||||
@ -70,7 +73,7 @@ namespace Orchard.Comments.Controllers {
|
||||
[FormValueRequired("submit.BulkEdit")]
|
||||
public ActionResult Index(FormCollection input) {
|
||||
var viewModel = new CommentsIndexViewModel { Comments = new List<CommentEntry>(), Options = new CommentIndexOptions() };
|
||||
UpdateModel(viewModel, input.ToValueProvider());
|
||||
UpdateModel(viewModel);
|
||||
|
||||
try {
|
||||
IEnumerable<CommentEntry> checkedEntries = viewModel.Comments.Where(c => c.IsChecked);
|
||||
@ -85,6 +88,22 @@ namespace Orchard.Comments.Controllers {
|
||||
_commentService.MarkCommentAsSpam(entry.Comment.Id);
|
||||
}
|
||||
break;
|
||||
case CommentIndexBulkAction.Pend:
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't moderate comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
//TODO: Transaction
|
||||
foreach (CommentEntry entry in checkedEntries) {
|
||||
_commentService.PendComment(entry.Comment.Id);
|
||||
}
|
||||
break;
|
||||
case CommentIndexBulkAction.Approve:
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't moderate comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
//TODO: Transaction
|
||||
foreach (CommentEntry entry in checkedEntries) {
|
||||
_commentService.ApproveComment(entry.Comment.Id);
|
||||
}
|
||||
break;
|
||||
case CommentIndexBulkAction.Delete:
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't delete comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
@ -155,6 +174,9 @@ namespace Orchard.Comments.Controllers {
|
||||
case CommentDetailsFilter.Approved:
|
||||
comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Approved);
|
||||
break;
|
||||
case CommentDetailsFilter.Pending:
|
||||
comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Pending);
|
||||
break;
|
||||
case CommentDetailsFilter.Spam:
|
||||
comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Spam);
|
||||
break;
|
||||
@ -181,7 +203,7 @@ namespace Orchard.Comments.Controllers {
|
||||
[FormValueRequired("submit.BulkEdit")]
|
||||
public ActionResult Details(FormCollection input) {
|
||||
var viewModel = new CommentsDetailsViewModel { Comments = new List<CommentEntry>(), Options = new CommentDetailsOptions() };
|
||||
UpdateModel(viewModel, input.ToValueProvider());
|
||||
UpdateModel(viewModel);
|
||||
|
||||
try {
|
||||
IEnumerable<CommentEntry> checkedEntries = viewModel.Comments.Where(c => c.IsChecked);
|
||||
@ -196,6 +218,22 @@ namespace Orchard.Comments.Controllers {
|
||||
_commentService.MarkCommentAsSpam(entry.Comment.Id);
|
||||
}
|
||||
break;
|
||||
case CommentDetailsBulkAction.Pend:
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't moderate comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
foreach (CommentEntry entry in checkedEntries) {
|
||||
_commentService.PendComment(entry.Comment.Id);
|
||||
}
|
||||
break;
|
||||
case CommentDetailsBulkAction.Approve:
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't moderate comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
foreach (CommentEntry entry in checkedEntries) {
|
||||
_commentService.ApproveComment(entry.Comment.Id);
|
||||
}
|
||||
break;
|
||||
case CommentDetailsBulkAction.Delete:
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't delete comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
@ -214,7 +252,7 @@ namespace Orchard.Comments.Controllers {
|
||||
return Details(viewModel.CommentedItemId, viewModel.Options);
|
||||
}
|
||||
|
||||
return RedirectToAction("Details", new { viewModel.CommentedItemId, viewModel.Options });
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult Close(int commentedItemId, string returnUrl) {
|
||||
@ -279,7 +317,7 @@ namespace Orchard.Comments.Controllers {
|
||||
public ActionResult Edit(FormCollection input) {
|
||||
var viewModel = new CommentsEditViewModel();
|
||||
try {
|
||||
UpdateModel(viewModel, input.ToValueProvider());
|
||||
UpdateModel(viewModel);
|
||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't edit comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
|
@ -19,6 +19,7 @@ namespace Orchard.Comments.Models {
|
||||
}
|
||||
|
||||
public enum CommentStatus {
|
||||
Pending,
|
||||
Approved,
|
||||
Spam
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace Orchard.Comments.Services {
|
||||
ContentItemMetadata GetDisplayForCommentedContent(int id);
|
||||
void CreateComment(Comment comment);
|
||||
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
|
||||
void ApproveComment(int commentId);
|
||||
void PendComment(int commentId);
|
||||
void MarkCommentAsSpam(int commentId);
|
||||
void DeleteComment(int commentId);
|
||||
bool CommentsClosedForCommentedContent(int id);
|
||||
@ -86,7 +88,7 @@ namespace Orchard.Comments.Services {
|
||||
}
|
||||
|
||||
public void CreateComment(Comment comment) {
|
||||
comment.Status = _commentValidator.ValidateComment(comment) ? CommentStatus.Approved : CommentStatus.Spam;
|
||||
comment.Status = _commentValidator.ValidateComment(comment) ? CommentStatus.Pending : CommentStatus.Spam;
|
||||
_commentRepository.Create(comment);
|
||||
}
|
||||
|
||||
@ -99,6 +101,16 @@ namespace Orchard.Comments.Services {
|
||||
comment.Status = status;
|
||||
}
|
||||
|
||||
public void ApproveComment(int commentId) {
|
||||
Comment comment = GetComment(commentId);
|
||||
comment.Status = CommentStatus.Approved;
|
||||
}
|
||||
|
||||
public void PendComment(int commentId) {
|
||||
Comment comment = GetComment(commentId);
|
||||
comment.Status = CommentStatus.Pending;
|
||||
}
|
||||
|
||||
public void MarkCommentAsSpam(int commentId) {
|
||||
Comment comment = GetComment(commentId);
|
||||
comment.Status = CommentStatus.Spam;
|
||||
|
@ -17,12 +17,15 @@ namespace Orchard.Comments.ViewModels {
|
||||
|
||||
public enum CommentDetailsBulkAction {
|
||||
None,
|
||||
Delete,
|
||||
Pend,
|
||||
Approve,
|
||||
MarkAsSpam,
|
||||
Delete,
|
||||
}
|
||||
|
||||
public enum CommentDetailsFilter {
|
||||
All,
|
||||
Pending,
|
||||
Approved,
|
||||
Spam,
|
||||
}
|
||||
|
@ -21,12 +21,15 @@ namespace Orchard.Comments.ViewModels {
|
||||
|
||||
public enum CommentIndexBulkAction {
|
||||
None,
|
||||
Delete,
|
||||
Pend,
|
||||
Approve,
|
||||
MarkAsSpam,
|
||||
Delete
|
||||
}
|
||||
|
||||
public enum CommentIndexFilter {
|
||||
All,
|
||||
Pending,
|
||||
Approved,
|
||||
Spam,
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.Comments.ViewModels {
|
||||
namespace Orchard.Comments.ViewModels {
|
||||
public class EditCommentsViewModel {
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,10 @@
|
||||
<label for="publishActions"><%=_Encoded("Actions:") %></label>
|
||||
<select id="publishActions" name="<%=Html.NameOf(m => m.Options.BulkAction)%>">
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentDetailsBulkAction.None, _Encoded("Choose action...").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentDetailsBulkAction.Delete, _Encoded("Delete").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentDetailsBulkAction.Approve, _Encoded("Approve").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentDetailsBulkAction.Pend, _Encoded("Pend").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentDetailsBulkAction.MarkAsSpam, _Encoded("Mark as Spam").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentDetailsBulkAction.Delete, _Encoded("Delete").ToString())%>
|
||||
</select>
|
||||
<input class="button" type="submit" name="submit.BulkEdit" value="<%=_Encoded("Apply") %>" />
|
||||
</fieldset>
|
||||
@ -18,6 +20,7 @@
|
||||
<select id="filterResults" name="<%=Html.NameOf(m => m.Options.Filter)%>">
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentDetailsFilter.All, _Encoded("All Comments").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentDetailsFilter.Approved, _Encoded("Approved Comments").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentDetailsFilter.Pending, _Encoded("Pending Comments").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentDetailsFilter.Spam, _Encoded("Spam").ToString())%>
|
||||
</select>
|
||||
<input class="button" type="submit" name="submit.Filter" value="<%=_Encoded("Apply") %>"/>
|
||||
@ -61,7 +64,11 @@
|
||||
<input type="hidden" value="<%=Model.DisplayNameForCommentedItem %>" name="DisplayNameForCommentedtem" />
|
||||
<input type="hidden" value="<%=Model.CommentedItemId %>" name="CommentedItemId" />
|
||||
</td>
|
||||
<td><% if (commentEntry.Comment.Status == CommentStatus.Spam) { %><%=_Encoded("Spam") %><% } else { %><%=_Encoded("Approved") %><% } %></td>
|
||||
<td>
|
||||
<% if (commentEntry.Comment.Status == CommentStatus.Spam) { %><%=_Encoded("Spam") %><% }
|
||||
else if (commentEntry.Comment.Status == CommentStatus.Pending) { %><%=_Encoded("Pending") %><% }
|
||||
else { %><%=_Encoded("Approved") %><% } %>
|
||||
</td>
|
||||
<td><%=Html.Encode(commentEntry.Comment.UserName) %></td>
|
||||
<td>
|
||||
<% if (commentEntry.Comment.CommentText != null) {%>
|
||||
|
@ -26,6 +26,10 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<%=Html.RadioButton("Status", "Pending", (Model.Status == CommentStatus.Pending), new { id = "Status_Pending" }) %>
|
||||
<label class="forcheckbox" for="Status_Pending"><%=_Encoded("Pending") %></label>
|
||||
</div>
|
||||
<div>
|
||||
<%=Html.RadioButton("Status", "Approved", (Model.Status == CommentStatus.Approved), new { id = "Status_Approved" }) %>
|
||||
<label class="forcheckbox" for="Status_Approved"><%=_Encoded("Approved") %></label>
|
||||
|
@ -8,8 +8,10 @@
|
||||
<label for="publishActions"><%=_Encoded("Actions:") %></label>
|
||||
<select id="publishActions" name="<%=Html.NameOf(m => m.Options.BulkAction)%>">
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentIndexBulkAction.None, _Encoded("Choose action...").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentIndexBulkAction.Delete, _Encoded("Delete").ToString())%>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentIndexBulkAction.Approve, _Encoded("Approve").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentIndexBulkAction.Pend, _Encoded("Pend").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentIndexBulkAction.MarkAsSpam, _Encoded("Mark as Spam").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.BulkAction, CommentIndexBulkAction.Delete, _Encoded("Delete").ToString())%>
|
||||
</select>
|
||||
<input class="button" type="submit" name="submit.BulkEdit" value="<%=_Encoded("Apply") %>" />
|
||||
</fieldset>
|
||||
@ -18,6 +20,7 @@
|
||||
<select id="filterResults" name="<%=Html.NameOf(m => m.Options.Filter)%>">
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentIndexFilter.All, _Encoded("All Comments").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentIndexFilter.Approved, _Encoded("Approved Comments").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentIndexFilter.Pending, _Encoded("Pending Comments").ToString()) %>
|
||||
<%=Html.SelectOption(Model.Options.Filter, CommentIndexFilter.Spam, _Encoded("Spam").ToString())%>
|
||||
</select>
|
||||
<input class="button" type="submit" name="submit.Filter" value="<%=_Encoded("Apply") %>"/>
|
||||
@ -54,7 +57,9 @@
|
||||
<input type="hidden" value="<%=Model.Comments[commentIndex].Comment.Id %>" name="<%=Html.NameOf(m => m.Comments[ci].Comment.Id) %>"/>
|
||||
<input type="checkbox" value="true" name="<%=Html.NameOf(m => m.Comments[ci].IsChecked) %>"/>
|
||||
</td>
|
||||
<td><% if (commentEntry.Comment.Status == CommentStatus.Spam) { %><%=_Encoded("Spam") %><% } else { %><%=_Encoded("Approved") %><% } %></td>
|
||||
<td><% if (commentEntry.Comment.Status == CommentStatus.Spam) { %><%=_Encoded("Spam") %><% }
|
||||
else if (commentEntry.Comment.Status == CommentStatus.Pending) { %><%=_Encoded("Pending") %><% }
|
||||
else { %><%=_Encoded("Approved") %><% } %></td>
|
||||
<td><%=Html.Encode(commentEntry.Comment.UserName) %></td>
|
||||
<td>
|
||||
<% if (commentEntry.Comment.CommentText != null) {%>
|
||||
|
Loading…
Reference in New Issue
Block a user