public BlogPostCommentWrapper(Comment comment)
 {
     CreatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(comment.UserID));
     Updated = Created = (ApiDateTime)comment.Datetime;
     Id = comment.ID;
     Text = comment.Content;
     ParentId = comment.ParentId;
    
 }
Ejemplo n.º 2
0
        private static string GetHTMLComment(string text, string commentID)
        {
            var comment = new Comment
                {
                    Content = text,
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            if (!String.IsNullOrEmpty(commentID))
            {
                comment = GetEngine().GetCommentById(new Guid(commentID));
                comment.Content = text;
            }

            return GetHTMLComment(comment, true);
        }
Ejemplo n.º 3
0
        private static string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
                {
                    CommentID = comment.ID.ToString(),
                    UserID = comment.UserID,
                    TimeStamp = comment.Datetime,
                    TimeStampStr = comment.Datetime.Ago(),
                    IsRead = true,
                    Inactive = comment.Inactive,
                    CommentBody = comment.Content,
                    UserFullName = DisplayUserSettings.GetFullUserName(comment.UserID),
                    UserAvatar = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID),
                    UserPost = CoreContext.UserManager.GetUsers(comment.UserID).Title
                };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(comment, Constants.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(comment.Post, Constants.Action_AddComment);
            }
            var defComment = new CommentsList();
            ConfigureComments(defComment, 0, null);

            return CommentsHelper.GetOneCommentHtmlWithContainer(
                defComment,
                info,
                comment.IsRoot(),
                false);
        }
Ejemplo n.º 4
0
        public AjaxResponse AddComment(string parrentCommentID, string blogID, string text, string pid)
        {
            Guid postId;
            Guid? parentId = null;
            try
            {
                postId = new Guid(blogID);

                if (!String.IsNullOrEmpty(parrentCommentID))
                    parentId = new Guid(parrentCommentID);
            }
            catch
            {
                return new AjaxResponse();
            }

            var engine = GetEngine();

            var resp = new AjaxResponse { rs1 = parrentCommentID };

            var post = engine.GetPostById(postId);

            if (post == null)
            {
                return new AjaxResponse { rs10 = "postDeleted", rs11 = Constants.DefaultPageUrl };
            }

            CommunitySecurity.DemandPermissions(post, Constants.Action_AddComment);

            var newComment = new Comment
                {
                    PostId = postId,
                    Content = text,
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            if (parentId.HasValue)
                newComment.ParentId = parentId.Value;

            engine.SaveComment(newComment, post);

            //mark post as seen for the current user
            engine.SavePostReview(post, SecurityContext.CurrentAccount.ID);
            resp.rs2 = GetHTMLComment(newComment, false);

            return resp;
        }
Ejemplo n.º 5
0
        public void SaveComment(Comment comment)
        {
            var isInsert = (comment.ID == Guid.Empty);
            if (isInsert) comment.ID = Guid.NewGuid();

            var query = Insert("blogs_comments")
                .InColumns("id", "post_id", "parent_id", "content", "created_by", "created_when", "inactive")
                .Values(comment.ID, comment.PostId, comment.ParentId, comment.Content, comment.UserID.ToString(), TenantUtil.DateTimeToUtc(comment.Datetime), comment.Inactive ? 1 : 0);

            using (var tx = Db.BeginTransaction())
            {
                Db.ExecuteNonQuery(query);

                if (isInsert)
                {
                    var update = Update("blogs_posts")
                        .Set("LastCommentId", comment.ID.ToString())
                        .Where("id", comment.PostId.ToString());

                    Db.ExecuteNonQuery(update);
                }

                tx.Commit();
            }
        }
Ejemplo n.º 6
0
        public BlogPostCommentWrapper AddComment(Guid postid, string content, Guid parentId)
        {
            var post = BlogEngine.GetPostById(postid).NotFoundIfNull();
            
            var newComment = new Comment
                                 {
                                     PostId = postid,
                                     Content = content,
                                     Datetime = DateTime.UtcNow,
                                     UserID = SecurityContext.CurrentAccount.ID
                                 };

            if (parentId!=Guid.Empty)
                newComment.ParentId = parentId;
            BlogEngine.SaveComment(newComment, post);
            return new BlogPostCommentWrapper(newComment);
        }
Ejemplo n.º 7
0
 public CommentSecurityObjectProvider(Comment comment)
 {
     _author = comment.UserID;
 }
Ejemplo n.º 8
0
 private static FeedComment ToFeedComment(Comment comment)
 {
     return new FeedComment(comment.UserID)
         {
             Id = comment.ID.ToString(),
             Description = HtmlSanitizer.Sanitize(comment.Content),
             Date = comment.Datetime
         };
 }
Ejemplo n.º 9
0
        private static Comment ToComment(object[] r)
        {
            var comment = new Comment
                {
                    Post = new Post
                        {
                            ID = new Guid(Convert.ToString(r[0])),
                            Title = Convert.ToString(r[1]),
                            Content = Convert.ToString(r[2]),
                            UserID = new Guid(Convert.ToString(r[3])),
                            Datetime = Convert.ToDateTime(r[4])
                        }
                };

            if (r[5] != null)
            {
                comment.ID = new Guid(Convert.ToString(r[5]));
                comment.Content = Convert.ToString(r[6]);
                comment.UserID = new Guid(Convert.ToString(r[7]));
                comment.Datetime = Convert.ToDateTime(r[8]);
            }
            return comment;
        }
Ejemplo n.º 10
0
 public CommentSecurityObjectProvider(Comment comment)
 {
     author = comment.UserID;
 }
        public static void UpdateComment(Comment comment, Post post, Guid authorID)
        {
            var ua =
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(post),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_EditComment,
                    authorID,
                    UserActivityConstants.ActivityActionType,
                    Constants.EditCommentBusinessValue);
            ua.URL += "#" + comment.ID;

            PublishInternal(ua);
        }
        public static void AddComment(Comment newComment,Post post)
        {
            var ua = 
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(post),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_AddComment,
                    newComment.UserID,
                    UserActivityConstants.ActivityActionType,
                    Constants.AddCommentBusinessValue);
            ua.URL += "#" + newComment.ID;
            ua.HtmlPreview = newComment.Content;

            PublishInternal(ua);
        }