mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
- Comments: Ability to re-enable comments for content items where comments were closed/disabled.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041946
This commit is contained in:
@@ -166,6 +166,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
Options = options,
|
Options = options,
|
||||||
DisplayNameForCommentedItem = _commentService.GetDisplayForCommentedContent(id).DisplayText,
|
DisplayNameForCommentedItem = _commentService.GetDisplayForCommentedContent(id).DisplayText,
|
||||||
CommentedItemId = id,
|
CommentedItemId = id,
|
||||||
|
CommentsClosedOnItem = _commentService.CommentsClosedForCommentedContent(id),
|
||||||
};
|
};
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
@@ -228,6 +229,19 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Enable(int commentedItemId) {
|
||||||
|
try {
|
||||||
|
if (!_authorizer.Authorize(Permissions.EnableComment, T("Couldn't enable comments")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
_commentService.EnableCommentsForCommentedContent(commentedItemId);
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
_notifier.Error(T("Enabling Comments failed: " + exception.Message));
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult Edit(int id) {
|
public ActionResult Edit(int id) {
|
||||||
try {
|
try {
|
||||||
Comment comment = _commentService.GetComment(id);
|
Comment comment = _commentService.GetComment(id);
|
||||||
|
@@ -5,6 +5,7 @@ namespace Orchard.Comments {
|
|||||||
public class Permissions : IPermissionProvider {
|
public class Permissions : IPermissionProvider {
|
||||||
public static readonly Permission AddComment = new Permission { Description = "Adding a Comment", Name = "AddComment" };
|
public static readonly Permission AddComment = new Permission { Description = "Adding a Comment", Name = "AddComment" };
|
||||||
public static readonly Permission AddCommentWithoutValidation = new Permission { Description = "Adding a Comment without validation", Name = "AddCommentWithoutValidation" };
|
public static readonly Permission AddCommentWithoutValidation = new Permission { Description = "Adding a Comment without validation", Name = "AddCommentWithoutValidation" };
|
||||||
|
public static readonly Permission EnableComment = new Permission { Description = "Enabling Comments on content items", Name = "EnableComment" };
|
||||||
public static readonly Permission CloseComment = new Permission { Description = "Closing Comments", Name = "CloseComment" };
|
public static readonly Permission CloseComment = new Permission { Description = "Closing Comments", Name = "CloseComment" };
|
||||||
public static readonly Permission CloseCommentOnOwnItems = new Permission { Description = "Closing Comments on own items", Name = "CloseCommentOnOwnItems" };
|
public static readonly Permission CloseCommentOnOwnItems = new Permission { Description = "Closing Comments on own items", Name = "CloseCommentOnOwnItems" };
|
||||||
public static readonly Permission ModerateComment = new Permission { Description = "Moderating Comments", Name = "ModerateComment" };
|
public static readonly Permission ModerateComment = new Permission { Description = "Moderating Comments", Name = "ModerateComment" };
|
||||||
@@ -20,6 +21,7 @@ namespace Orchard.Comments {
|
|||||||
return new List<Permission> {
|
return new List<Permission> {
|
||||||
AddComment,
|
AddComment,
|
||||||
AddCommentWithoutValidation,
|
AddCommentWithoutValidation,
|
||||||
|
EnableComment,
|
||||||
CloseComment,
|
CloseComment,
|
||||||
CloseCommentOnOwnItems,
|
CloseCommentOnOwnItems,
|
||||||
ModerateComment,
|
ModerateComment,
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.Comments.Models;
|
using Orchard.Comments.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
@@ -20,7 +21,9 @@ namespace Orchard.Comments.Services {
|
|||||||
void UpdateComment(int id, string name, string email, string siteName, string commentText);
|
void UpdateComment(int id, string name, string email, string siteName, string commentText);
|
||||||
void MarkCommentAsSpam(int commentId);
|
void MarkCommentAsSpam(int commentId);
|
||||||
void DeleteComment(int commentId);
|
void DeleteComment(int commentId);
|
||||||
|
bool CommentsClosedForCommentedContent(int id);
|
||||||
void CloseCommentsForCommentedContent(int id);
|
void CloseCommentsForCommentedContent(int id);
|
||||||
|
void EnableCommentsForCommentedContent(int id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CommentService : ICommentService {
|
public class CommentService : ICommentService {
|
||||||
@@ -97,10 +100,21 @@ namespace Orchard.Comments.Services {
|
|||||||
_commentRepository.Delete(GetComment(commentId));
|
_commentRepository.Delete(GetComment(commentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CommentsClosedForCommentedContent(int id) {
|
||||||
|
return _closedCommentsRepository.Get(x => x.ContentItemId == id) == null ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
public void CloseCommentsForCommentedContent(int id) {
|
public void CloseCommentsForCommentedContent(int id) {
|
||||||
_closedCommentsRepository.Create(new ClosedComments { ContentItemId = id });
|
_closedCommentsRepository.Create(new ClosedComments { ContentItemId = id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnableCommentsForCommentedContent(int id) {
|
||||||
|
ClosedComments closedComments = _closedCommentsRepository.Get(x => x.ContentItemId == id);
|
||||||
|
if (closedComments != null) {
|
||||||
|
_closedCommentsRepository.Delete(closedComments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ namespace Orchard.Comments.ViewModels {
|
|||||||
public CommentDetailsOptions Options { get; set; }
|
public CommentDetailsOptions Options { get; set; }
|
||||||
public string DisplayNameForCommentedItem { get; set; }
|
public string DisplayNameForCommentedItem { get; set; }
|
||||||
public int CommentedItemId { get; set; }
|
public int CommentedItemId { get; set; }
|
||||||
|
public bool CommentsClosedOnItem { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CommentDetailsOptions {
|
public class CommentDetailsOptions {
|
||||||
|
@@ -81,8 +81,16 @@
|
|||||||
} %>
|
} %>
|
||||||
</table>
|
</table>
|
||||||
<li class="clearLayout">
|
<li class="clearLayout">
|
||||||
<%=Html.ActionLink("Close Comments", "Close", new {commentedItemId = Model.CommentedItemId}, new {@class="floatRight topSpacer"}) %>
|
<% if (Model.CommentsClosedOnItem) {%>
|
||||||
|
<%=Html.ActionLink("Enable Comments", "Enable",
|
||||||
|
new {commentedItemId = Model.CommentedItemId},
|
||||||
|
new {@class="floatRight topSpacer"}) %>
|
||||||
|
<%} else {%>
|
||||||
|
<%=Html.ActionLink("Close Comments", "Close",
|
||||||
|
new {commentedItemId = Model.CommentedItemId},
|
||||||
|
new {@class = "floatRight topSpacer"})%>
|
||||||
</li>
|
</li>
|
||||||
|
<% }%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% Html.EndForm(); %>
|
<% Html.EndForm(); %>
|
||||||
|
@@ -14,8 +14,7 @@
|
|||||||
</ol>
|
</ol>
|
||||||
<% if (Model.Closed) { %>
|
<% if (Model.Closed) { %>
|
||||||
<p>Comments have been disabled for this content.</p>
|
<p>Comments have been disabled for this content.</p>
|
||||||
<% } %>
|
<% } else { %>
|
||||||
<% else { %>
|
|
||||||
<% Html.BeginForm("Create", "Admin", new { area = "Orchard.Comments" }); %>
|
<% Html.BeginForm("Create", "Admin", new { area = "Orchard.Comments" }); %>
|
||||||
<%= Html.ValidationSummary() %>
|
<%= Html.ValidationSummary() %>
|
||||||
<div class="yui-g">
|
<div class="yui-g">
|
||||||
|
Reference in New Issue
Block a user