mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -69,28 +69,22 @@ namespace Orchard.Comments.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CommentPart CreateComment(CreateCommentContext context, bool moderateComments) {
|
public CommentPart CreateComment(CreateCommentContext context, bool moderateComments) {
|
||||||
var comment = _orchardServices.ContentManager.Create<CommentPart>("Comment");
|
return _orchardServices.ContentManager.Create<CommentPart>("Comment", comment => {
|
||||||
|
comment.Record.Author = context.Author;
|
||||||
comment.Record.Author = context.Author;
|
comment.Record.CommentDateUtc = _clock.UtcNow;
|
||||||
comment.Record.CommentDateUtc = _clock.UtcNow;
|
comment.Record.CommentText = context.CommentText;
|
||||||
comment.Record.CommentText = context.CommentText;
|
comment.Record.Email = context.Email;
|
||||||
comment.Record.Email = context.Email;
|
comment.Record.SiteName = context.SiteName;
|
||||||
comment.Record.SiteName = context.SiteName;
|
comment.Record.UserName = (_orchardServices.WorkContext.CurrentUser != null ? _orchardServices.WorkContext.CurrentUser.UserName : null);
|
||||||
comment.Record.UserName = (_orchardServices.WorkContext.CurrentUser != null ? _orchardServices.WorkContext.CurrentUser.UserName : null);
|
comment.Record.CommentedOn = context.CommentedOn;
|
||||||
comment.Record.CommentedOn = context.CommentedOn;
|
comment.Record.Status = _commentValidator.ValidateComment(comment)
|
||||||
|
? moderateComments ? CommentStatus.Pending : CommentStatus.Approved
|
||||||
comment.Record.Status = _commentValidator.ValidateComment(comment)
|
: CommentStatus.Spam;
|
||||||
? moderateComments ? CommentStatus.Pending : CommentStatus.Approved
|
var commentedOn = _orchardServices.ContentManager.Get<ICommonPart>(comment.Record.CommentedOn);
|
||||||
: CommentStatus.Spam;
|
if (commentedOn != null && commentedOn.Container != null) {
|
||||||
|
comment.Record.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
|
||||||
// store id of the next layer for large-grained operations, e.g. rss on blog
|
}
|
||||||
//TODO:(rpaquay) Get rid of this (comment aspect takes care of container)
|
});
|
||||||
var commentedOn = _orchardServices.ContentManager.Get<ICommonPart>(comment.Record.CommentedOn);
|
|
||||||
if (commentedOn != null && commentedOn.Container != null) {
|
|
||||||
comment.Record.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return comment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status) {
|
public void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status) {
|
||||||
|
Reference in New Issue
Block a user