diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs index 61ec52db3..3b899c886 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs @@ -104,6 +104,12 @@ namespace Orchard.Comments.Drivers { } } + // if editing from the admin, don't update the owner or the status + if (!string.IsNullOrEmpty(name) && String.Equals(name, "save", StringComparison.OrdinalIgnoreCase)) { + _orchardServices.Notifier.Information(T("Comment saved.")); + return Editor(part, shapeHelper); + } + part.CommentDateUtc = _clock.UtcNow; if (!String.IsNullOrEmpty(part.SiteName) && !part.SiteName.StartsWith("http://") && !part.SiteName.StartsWith("https://")) { @@ -121,10 +127,19 @@ namespace Orchard.Comments.Drivers { part.Status = moderateComments ? CommentStatus.Pending : CommentStatus.Approved; var commentedOn = _contentManager.Get(part.CommentedOn); + + // prevent users from commenting on a closed thread by hijacking the commentedOn property + var commentsPart = commentedOn.As(); + if (!commentsPart.CommentsActive) { + _orchardServices.TransactionManager.Cancel(); + return Editor(part, shapeHelper); + } + if (commentedOn != null && commentedOn.Container != null) { part.CommentedOnContainer = commentedOn.Container.ContentItem.Id; } - commentedOn.As().Record.CommentPartRecords.Add(part.Record); + + commentsPart.Record.CommentPartRecords.Add(part.Record); return Editor(part, shapeHelper); } 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 65fb4b3d0..683cedea2 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 @@ -32,7 +32,7 @@
- + @if (Model.Status == CommentStatus.Approved) {