コード例 #1
0
        public string GetPreview(string text, string commentID)
        {
            var storage = FeedStorageFactory.Create();

            var comment = new FeedComment(1)
            {
                Date    = TenantUtil.DateTimeNow(),
                Creator = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(commentID))
            {
                comment = storage.GetFeedComment(long.Parse(commentID, CultureInfo.CurrentCulture));
            }

            comment.Comment = text;

            var commentInfo = GetCommentInfo(comment);

            commentInfo.IsEditPermissions     = false;
            commentInfo.IsResponsePermissions = false;

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment, commentInfo, true, false));
        }
コード例 #2
0
        public AjaxResponse AddComment(string parentCommentId, string pageName, string text, string pid)
        {
            text = HtmlUtility.GetFull(text);
            var resp = new AjaxResponse();

            resp.rs1 = parentCommentId;

            var parentIdGuid = String.IsNullOrEmpty(parentCommentId) ? Guid.Empty : new Guid(parentCommentId);
            var newComment   = Wiki.CreateComment(new Comment {
                Body = text, PageName = pageName, ParentId = parentIdGuid
            });

            var info = GetCommentInfo(newComment);

            var defComment = new CommentsList();

            ConfigureComments(defComment, pageName);

            var visibleCommentsCount = Wiki.GetComments(pageName).Count;

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(
                defComment,
                info,
                string.IsNullOrEmpty(parentCommentId),
                visibleCommentsCount % 2 == 1);

            return(resp);
        }
コード例 #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));
        }
コード例 #4
0
        public AjaxResponse AddComment(string parentCommentId, string newsId, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = parentCommentId
            };

            var comment = new FeedComment(long.Parse(newsId));

            comment.Comment = text;
            var storage = FeedStorageFactory.Create();

            if (!string.IsNullOrEmpty(parentCommentId))
            {
                comment.ParentId = Convert.ToInt64(parentCommentId);
            }

            var feed = storage.GetFeed(long.Parse(newsId, CultureInfo.CurrentCulture));

            comment = storage.SaveFeedComment(feed, comment);

            var commentInfo = GetCommentInfo(comment);
            var defComment  = new CommentsList();

            ConfigureComments(defComment, feed);

            var visibleCommentsCount = 0;

            storage.GetFeedComments(feed.Id).ForEach((cmm) => { visibleCommentsCount += (cmm.Inactive ? 0 : 1); });

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(
                defComment, commentInfo, comment.IsRoot(), visibleCommentsCount % 2 == 1);

            return(resp);
        }
コード例 #5
0
        private string GetHTMLComment(Comment comment)
        {
            var creator      = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo;
            var oCommentInfo = new CommentInfo
            {
                TimeStamp             = comment.CreateOn,
                TimeStampStr          = comment.CreateOn.Ago(),
                CommentBody           = comment.Content,
                CommentID             = comment.ID.ToString(),
                UserID                = comment.CreateBy,
                UserFullName          = creator.DisplayUserName(),
                Inactive              = comment.Inactive,
                IsEditPermissions     = ProjectSecurity.CanEditComment(Task != null ? Task.Project : null, comment),
                IsResponsePermissions = ProjectSecurity.CanCreateComment(),
                IsRead                = true,
                UserAvatar            = Global.GetHTMLUserAvatar(creator),
                UserPost              = creator.Title
            };

            if (commentList == null)
            {
                commentList = new CommentsList();

                ConfigureComments(commentList, null);
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       commentList,
                       oCommentInfo,
                       comment.Parent == Guid.Empty,
                       false));
        }
コード例 #6
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var creator = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo;
            var info    = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = creator.Title,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(creator),
                UserAvatar   = Global.GetHTMLUserAvatar(creator)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                info.IsRead                = true;
                info.IsEditPermissions     = ProjectSecurity.CanEditComment(Task.Project, comment);
                info.IsResponsePermissions = ProjectSecurity.CanCreateComment();
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       info,
                       comment.Parent == Guid.Empty,
                       false));
        }
コード例 #7
0
        private 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 = _serviceHelper.GetCommentById(commentID);

                comment.Content = text;
                comment.Parent  = string.Empty;
            }

            var defComment = new CommentsList();

            ConfigureComments(defComment);

            var ci = BookmarkingConverter.ConvertComment(comment, BookmarkingServiceHelper.GetCurrentInstanse().BookmarkToAdd.Comments);

            ci.IsEditPermissions     = false;
            ci.IsResponsePermissions = false;

            var isRoot = string.IsNullOrEmpty(comment.Parent) || comment.Parent.Equals(Guid.Empty.ToString(), StringComparison.CurrentCultureIgnoreCase);

            return(CommentsHelper.GetOneCommentHtmlWithContainer(defComment, ci, isRoot, false));
        }
コード例 #8
0
 private string GetOneCommentHtmlWithContainer(Comment comment)
 {
     return(CommentsHelper.GetOneCommentHtmlWithContainer(
                Comments,
                BookmarkingConverter.ConvertComment(comment, BookmarkingServiceHelper.GetCurrentInstanse().BookmarkToAdd.Comments),
                comment.Parent.Equals(Guid.Empty.ToString(), StringComparison.CurrentCultureIgnoreCase),
                false));
 }
コード例 #9
0
        public AjaxResponse AddComment(string parrentCommentID, string photoID, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = parrentCommentID
            };

            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddComment);

            var storage = StorageFactory.GetStorage();

            image = storage.GetAlbumItem(Convert.ToInt64(photoID));

            var newComment = new Comment(image.Id)
            {
                Text      = text,
                Timestamp = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                UserID    = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(parrentCommentID))
            {
                newComment.ParentId = Convert.ToInt64(parrentCommentID);
            }

            var count = storage.SaveComment(image, newComment);

            storage.ReadAlbumItem(newComment.ItemID, SecurityContext.CurrentAccount.ID.ToString());

            var odd = count % 2 == 1;

            var comment = newComment;

            var info = new CommentInfo
            {
                CommentID             = comment.Id.ToString(),
                UserID                = new Guid(comment.UserID),
                TimeStampStr          = comment.Timestamp.Ago(),
                IsRead                = true,
                Inactive              = comment.Inactive,
                CommentBody           = comment.Text,
                UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                UserAvatar            = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                UserPost              = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                IsEditPermissions     = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
            };

            //postParser.Parse(comment.Text);

            var defComment = new CommentsList();

            ConfigureCommentsList(defComment, image);

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, newComment.ParentId == 0, odd);


            return(resp);
        }
コード例 #10
0
        public string GetPreview(string text, string commentID)
        {
            var info       = GetPrevHTMLComment(text, commentID);
            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            return(CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, true, false));
        }
コード例 #11
0
ファイル: Comments.cs プロジェクト: Wifisoft/teamlab.v6.5
        private string RenderComments(IList <CommentInfo> comments, string userPageLinkWithParam, int commentLevel)
        {
            var sb = new StringBuilder();

            if (comments != null && comments.Count > 0)
            {
                foreach (var comment in comments)
                {
                    comment.CommentBody = HtmlUtility.GetFull(comment.CommentBody, ProductId);
                    sb.Append(
                        CommentsHelper.GetOneCommentHtmlWithContainer(
                            this,
                            comment,
                            commentLevel == 1 || commentLevel > maxDepthLevel,
                            cmnts => RenderComments(cmnts, userPageLinkWithParam, commentLevel + 1),
                            ref commentIndex
                            )
                        );
                }
            }
            return(sb.ToString());
        }
コード例 #12
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var creator     = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy);
            var commentInfo = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = creator.UserInfo.Title,
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(creator.UserInfo),
                UserAvatar   = Global.GetHTMLUserAvatar(creator.UserInfo)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                var targetID = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);

                var target = Global.EngineFactory.GetMessageEngine().GetByID(targetID);
                Discussion = target;

                commentInfo.IsEditPermissions     = ProjectSecurity.CanEditComment(Discussion, comment);
                commentInfo.IsResponsePermissions = ProjectSecurity.CanCreateComment(Discussion);
                commentInfo.IsRead = true;
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       commentInfo,
                       comment.Parent == Guid.Empty,
                       false));
        }
コード例 #13
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var commentInfo = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo.Title,
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(
                    Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo),
                UserAvatar = Global.GetHTMLUserAvatar(comment.CreateBy)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                commentInfo.IsEditPermissions     = ProjectSecurity.CanEditComment(Discussion.Project, comment);
                commentInfo.IsResponsePermissions = ProjectSecurity.CanCreateComment();

                var when = Global.EngineFactory.GetParticipantEngine().WhenReaded(Page.Participant.ID, Discussion.UniqID);
                commentInfo.IsRead = when.HasValue && when.Value > comment.CreateOn;
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       commentInfo,
                       comment.Parent == Guid.Empty,
                       false));
        }