diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs index 24f20ec6b..61ec52db3 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs @@ -9,9 +9,11 @@ using Orchard.Comments.Settings; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Aspects; +using Orchard.Security; using Orchard.Services; using Orchard.Localization; using Orchard.Comments.Services; +using Orchard.UI.Notify; namespace Orchard.Comments.Drivers { [UsedImplicitly] @@ -19,7 +21,9 @@ namespace Orchard.Comments.Drivers { private readonly IContentManager _contentManager; private readonly IWorkContextAccessor _workContextAccessor; private readonly IClock _clock; + private readonly ICommentService _commentService; private readonly IEnumerable _htmlFilters; + private readonly IOrchardServices _orchardServices; protected override string Prefix { get { return "Comments"; } } @@ -30,11 +34,14 @@ namespace Orchard.Comments.Drivers { IWorkContextAccessor workContextAccessor, IClock clock, ICommentService commentService, - IEnumerable htmlFilters) { + IEnumerable htmlFilters, + IOrchardServices orchardServices) { _contentManager = contentManager; _workContextAccessor = workContextAccessor; _clock = clock; + _commentService = commentService; _htmlFilters = htmlFilters; + _orchardServices = orchardServices; T = NullLocalizer.Instance; } @@ -69,6 +76,34 @@ namespace Orchard.Comments.Drivers { updater.TryUpdateModel(part, Prefix, null, null); var workContext = _workContextAccessor.GetContext(); + + // applying moderate/approve actions + var httpContext = workContext.HttpContext; + var name = httpContext.Request.Form["submit.Save"]; + if (!string.IsNullOrEmpty(name) && String.Equals(name, "moderate", StringComparison.OrdinalIgnoreCase)) { + if (_orchardServices.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) { + _commentService.UnapproveComment(part.Id); + _orchardServices.Notifier.Information(T("Comment successfully moderated.")); + return Editor(part, shapeHelper); + } + } + + if (!string.IsNullOrEmpty(name) && String.Equals(name, "approve", StringComparison.OrdinalIgnoreCase)) { + if (_orchardServices.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't approve comment"))) { + _commentService.ApproveComment(part.Id); + _orchardServices.Notifier.Information(T("Comment approved.")); + return Editor(part, shapeHelper); + } + } + + if (!string.IsNullOrEmpty(name) && String.Equals(name, "delete", StringComparison.OrdinalIgnoreCase)) { + if (_orchardServices.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) { + _commentService.DeleteComment(part.Id); + _orchardServices.Notifier.Information(T("Comment successfully deleted.")); + return Editor(part, shapeHelper); + } + } + part.CommentDateUtc = _clock.UtcNow; if (!String.IsNullOrEmpty(part.SiteName) && !part.SiteName.StartsWith("http://") && !part.SiteName.StartsWith("https://")) { diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts.Comment.AdminEdit.cshtml b/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts.Comment.AdminEdit.cshtml index f61a28119..65fb4b3d0 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts.Comment.AdminEdit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts.Comment.AdminEdit.cshtml @@ -1,4 +1,4 @@ -@model Orchard.Comments.Models.CommentPart +@model CommentPart @using Orchard.Comments.Models; @@ -6,15 +6,18 @@
  1. @Html.LabelFor(m => m.Author, T("Name")) - @Html.TextBoxFor(m => m.Author) + @Html.TextBoxFor(m => m.Author, new { @class = "textMedium"}) + @T("The author's name.")
  2. @Html.LabelFor(m => m.Email, T("Email")) - @Html.TextBoxFor(m => m.Email) + @Html.TextBoxFor(m => m.Email, new { @class = "textMedium"}) + @T("The email address the author has provided with the comment.")
  3. @Html.LabelFor(m => m.SiteName, T("Url")) - @Html.TextBoxFor(m => m.SiteName) + @Html.TextBoxFor(m => m.SiteName, new { @class = "text large"}) + @T("The website url the author has provided with the comment.")
@@ -22,20 +25,20 @@
@Html.LabelFor(m => m.CommentText, T("Comment")) @Html.TextAreaFor(m => m.CommentText, new { rows = 10, cols = 30, @class = "comment-text" }) + @T("The body of the comment.") @Html.HiddenFor(m => m.RepliedOn) @Html.HiddenFor(m => m.Id)
+
-
- @Html.RadioButtonFor(m => m.Status, CommentStatus.Pending) - -
-
- @Html.RadioButtonFor(m => m.Status, CommentStatus.Approved) - -
-
-
- + + + @if (Model.Status == CommentStatus.Approved) { + + } + + @if (Model.Status == CommentStatus.Pending) { + + }
\ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml index 85b48697b..018cb90a6 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml @@ -61,7 +61,7 @@
@if (Model.Name != "Administrator") { - + }
} \ No newline at end of file