public static CommentInfo ConvertComment(Comment comment, IList<Comment> commentList)
		{
			var userID = comment.UserID;

			CommentInfo c = new CommentInfo();

			c.CommentID = comment.ID.ToString();
			c.UserID = userID;
			c.TimeStamp = comment.Datetime;
			c.TimeStampStr = comment.Datetime.Ago();
						
			c.Inactive = comment.Inactive;
			c.CommentBody = comment.Content;
			c.UserFullName = DisplayUserSettings.GetFullUserName(userID);
			c.UserAvatar = BookmarkingServiceHelper.GetHTMLUserAvatar(userID);
			c.IsEditPermissions = BookmarkingPermissionsCheck.PermissionCheckEditComment(comment);
			c.IsResponsePermissions = BookmarkingPermissionsCheck.PermissionCheckCreateComment();

			c.UserPost = BookmarkingServiceHelper.GetUserInfo(userID).Title;

			var commentsList = new List<CommentInfo>();

			var childComments = GetChildComments(comment, commentList);
			if (childComments != null)
			{
				foreach (var item in childComments)
				{
					commentsList.Add(ConvertComment(item, commentList));
				}
			}
			c.CommentList = commentsList;
			return c;
		}
Example #2
0
 public static string GetOneCommentHtmlWithContainer(
     CommentsList control,
     CommentInfo comment,
     bool isFirstLevel,
     RenderInnerComments renderFunction,
     ref int commentIndex)
 {
     return(GetOneCommentHtmlWithContainer(
                comment,
                isFirstLevel,
                control.RealUserProfileLinkResolver,
                control.Simple,
                control.BehaviorID,
                control.EditCommentLink,
                control.ResponseCommentLink,
                control.RemoveCommentLink,
                control.InactiveMessage,
                control.ConfirmRemoveCommentMessage,
                control.JavaScriptRemoveCommentFunctionName,
                control.PID,
                renderFunction,
                ref commentIndex
                ));
 }
Example #3
0
        private CommentInfo GetCommentInfo(FeedComment comment)
        {
            var info = new CommentInfo
                           {
                               CommentID = comment.Id.ToString(CultureInfo.CurrentCulture),
                               UserID = new Guid(comment.Creator),
                               TimeStamp = comment.Date,
                               TimeStampStr = comment.Date.Ago(),
                               IsRead = true,
                               Inactive = comment.Inactive,
                               CommentBody = comment.Comment,
                               UserFullName = DisplayUserSettings.GetFullUserName(new Guid(comment.Creator)),
                               UserAvatar = GetHtmlImgUserAvatar(new Guid(comment.Creator)),
                               IsEditPermissions = CommunitySecurity.CheckPermissions(NewsConst.Action_Edit),
                               IsResponsePermissions = CommunitySecurity.CheckPermissions(NewsConst.Action_Comment),
                               UserPost = CoreContext.UserManager.GetUsers((new Guid(comment.Creator))).Title
                           };

            return info;
        }
        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;
        }
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
                           {
                               CommentID = comment.Id.ToString(),
                               UserID = new Guid(comment.UserID),
                               TimeStamp = comment.Timestamp,
                               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
                           };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment);
            }

            var defComment = new CommentsList();
            ConfigureCommentsList(defComment, null);

            return Web.Controls.CommentInfoHelper.CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, comment.ParentId <= 0, false);
        }
        private void AppendChildsComments(ref List<CommentInfo> commentsInfo, IList<Comment> comments)
        {
            foreach (var comment in comments)
            {
                var info = new CommentInfo
                               {
                                   CommentID = comment.Id.ToString(),
                                   UserID = new Guid(comment.UserID),
                                   TimeStampStr = comment.Timestamp.Ago(),
                                   IsRead = SecurityContext.DemoMode || comment.IsRead,
                                   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 tempComments = new List<CommentInfo>();

                AppendChildsComments(ref tempComments, comment.Comments);

                info.CommentList = tempComments;

                commentsInfo.Add(info);
            }
        }
Example #7
0
        public CommentInfo GetCommentInfo(Comment comment)
        {
            var info = new CommentInfo
                           {
                               CommentID = comment.Id.ToString(),
                               UserID = comment.UserId,
                               TimeStamp = comment.Date,
                               TimeStampStr = comment.Date.Ago(),
                               IsRead = true,
                               Inactive = comment.Inactive,
                               CommentBody = comment.Body,
                               UserFullName = DisplayUserSettings.GetFullUserName(comment.UserId),
                               UserAvatar = GetHtmlImgUserAvatar(comment.UserId),
                               IsEditPermissions = CommunitySecurity.CheckPermissions(new WikiObjectsSecurityObject(comment), Common.Constants.Action_EditRemoveComment),
                               IsResponsePermissions = true,
                               UserPost = CoreContext.UserManager.GetUsers(comment.UserId).Title
                           };

            return info;
        }
Example #8
0
        public static string GetOneCommentHtml(
            CommentInfo comment,
            bool odd,
            Func <string, string> userProfileLink,
            bool simple,
            string jsObjName,
            string EditCommentLink,
            string ResponseCommentLink,
            string RemoveCommentLink,
            string InactiveMessage,
            string confirmRemoveCommentMessage,
            string javaScriptRemoveCommentFunctionName,
            string PID
            )
        {
            var sb = new StringBuilder();

            sb.Append("<div class='" + (odd ? OddClass : EvenClass) + "' id=\"comment_" + comment.CommentID + "\" style='" + (odd ? OddStyle : EvenStyle) + " padding: 10px 5px 8px 15px;'><a name=\"" + comment.CommentID + "\"></a>");
            if (comment.Inactive)
            {
                sb.AppendFormat("<div  style=\"padding:10px;\">{0}</div>", InactiveMessage);
            }
            else
            {
                sb.Append("<table width='100%' cellpadding=\"0\" style='table-layout:fixed;' cellspacing=\"0\" border=\"0\" >");
                sb.Append("<tr><td valign=\"top\" width='40'>");
                sb.Append(comment.UserAvatar);
                sb.Append("</td><td valign=\"top\"><div>");
                sb.Append("<a style=\"margin-left:10px;\" class=\"linkHeader\" href=\"" + userProfileLink(comment.UserID.ToString()) + "\">" + comment.UserFullName + "</a>");
                sb.Append("&nbsp;&nbsp;");
                sb.Append("<span class=\"textSmallDescribe\" style='padding-left:5px;'>" + (String.IsNullOrEmpty(comment.TimeStampStr) ? comment.TimeStamp.ToLongDateString() : comment.TimeStampStr) + "</span>");

                sb.Append("</div>");

                //if (!comment.IsRead)
                //{
                //    sb.Append("<td valign=\"top\" style=\"padding-top:2px;\" align=\"right\">&nbsp;&nbsp;&nbsp;<img src=\"" + newImageFile + "\" /></td>");
                //}
                if (!string.IsNullOrEmpty(comment.UserPost))
                {
                    sb.AppendFormat("<div style=\"padding-top:2px;padding-left:10px;\" class='textBigDescribe'>{0}</div>", comment.UserPost.HtmlEncode());
                }

                sb.AppendFormat("<div id='content_{0}' style='padding-top:8px;padding-left:10px;' class='longWordsBreak'>", comment.CommentID);
                sb.Append(comment.CommentBody);
                sb.Append("</div>");

                if (comment.Attachments != null && comment.Attachments.Count > 0)
                {
                    sb.Append("<div id='attacments_" + comment.CommentID + "' style=\"padding-top:10px;padding-left:15px;\">");
                    var k = 0;
                    foreach (var attach in comment.Attachments)
                    {
                        if (k != 0)
                        {
                            sb.Append(", ");
                        }

                        sb.Append("<a class=\"linkDescribe\" href=\"" + attach.FilePath + "\">" + attach.FileName.HtmlEncode() + "</a>");
                        sb.Append("<input name='attacment_name_" + comment.CommentID + "' type='hidden' value='" + attach.FileName + "' />");
                        sb.Append("<input name='attacment_path_" + comment.CommentID + "' type='hidden' value='" + attach.FilePath + "' />");
                        k++;
                    }
                    sb.Append("</div>");
                }

                sb.Append("<div clas='clearFix' style=\"margin: 10px 0px 0px 10px;\" >");

                var drowSplitter = false;

                if (comment.IsResponsePermissions)
                {
                    sb.AppendFormat("<div style='float:left;'><a class=\"linkDescribe promoAction\" id=\"response_{0}\" href=\"javascript:void(0);\" onclick=\"javascript:CommentsManagerObj.ResponseToComment(this, '{0}');return false;\" >{1}</a></div>",
                                    comment.CommentID, ResponseCommentLink);
                }

                sb.Append("<div style='float:right;'>");

                if (comment.IsEditPermissions)
                {
                    sb.AppendFormat("<div style='float:right;'><a class=\"linkDescribe promoAction\" id=\"edit_{0}\" href=\"javascript:void(0);\" onclick=\"javascript:CommentsManagerObj.EditComment(this, '{0}');return false;\" >{1}</a>",
                                    comment.CommentID, EditCommentLink);
                    drowSplitter = true;
                }

                if (comment.IsEditPermissions)
                {
                    if (drowSplitter)
                    {
                        sb.Append("<span class=\"textMediumDescribe  splitter\">|</span>");
                    }

                    sb.AppendFormat("<a class=\"linkDescribe promoAction\" id=\"remove_{0}\" href=\"javascript:void(0);\" onclick=\"javascript:if(window.confirm('{2}')){{AjaxPro.onLoading = function(b){{}}; {3}('{0}'," + (String.IsNullOrEmpty(PID) ? "" : "'" + PID + "' ,") + "CommentsManagerObj.callbackRemove);}}return false;\" >{1}</a>",
                                    comment.CommentID, RemoveCommentLink, confirmRemoveCommentMessage, javaScriptRemoveCommentFunctionName);
                }
                sb.Append("</div>");

                sb.Append("</div>");
                sb.Append("</td></tr></table>");
            }
            sb.Append("</div>");

            return(sb.ToString());
        }
Example #9
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            CommentInfo info = new CommentInfo();

            info.CommentID = comment.ID.ToString();
            info.UserID = comment.UserID;
            info.TimeStamp = comment.Datetime;
            info.TimeStampStr = comment.Datetime.Ago();

            info.IsRead = true;
            info.Inactive = comment.Inactive;
            info.CommentBody = comment.Content;
            info.UserFullName = DisplayUserSettings.GetFullUserName(comment.UserID);
            info.UserAvatar = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID);
            info.UserPost = CoreContext.UserManager.GetUsers(comment.UserID).Title;

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

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

            return Web.Controls.CommentInfoHelper.CommentsHelper.GetOneCommentHtmlWithContainer(
                    defComment,
                    info,
                    comment.IsRoot(),
                    false);
        }
Example #10
0
        List<CommentInfo> BuildCommentsList(Post post, List<Comment> loaded, Guid parentId)
        {
            var result = new List<CommentInfo>();
            foreach (var comment in Comment.SelectChildLevel(parentId, loaded))
            {
                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,
                                   IsEditPermissions = CommunitySecurity.CheckPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment),
                                   IsResponsePermissions = CommunitySecurity.CheckPermissions(post, ASC.Blogs.Core.Constants.Action_AddComment),
                                   CommentList = BuildCommentsList(post, loaded, comment.ID)
                               };

                result.Add(info);
            }
            return result;
        }
        private string GetHTMLComment(Comment comment, bool isPreview)
        {

            var info = 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,
                               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)
            {
                var when = Global.EngineFactory.GetParticipantEngine().WhenReaded(Page.Participant.ID, Task.UniqID);
                info.IsRead = when.HasValue && when.Value > comment.CreateOn;
                info.IsEditPermissions = ProjectSecurity.CanEditComment(Task.Project, comment);
                info.IsResponsePermissions = ProjectSecurity.CanCreateComment();
            }

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

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

                                   };

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

            }

            return CommentsHelper.GetOneCommentHtmlWithContainer(
                commentList,
                oCommentInfo,
                comment.Parent == Guid.Empty,
                false);

        }
        private CommentInfo GetCommentInfo(IEnumerable<Comment> allComments, Comment parent)
        {
            var when = Global.EngineFactory.GetParticipantEngine().WhenReaded(Page.Participant.ID, Task.UniqID);
            var commentInfo = new CommentInfo
                                  {
                                      TimeStampStr = parent.CreateOn.Ago(),
                                      Inactive = parent.Inactive,
                                      IsRead = when.HasValue && parent.CreateOn < when.Value,
                                      IsResponsePermissions = ProjectSecurity.CanCreateComment(),
                                      IsEditPermissions = ProjectSecurity.CanEditComment(Task.Project, parent),
                                      CommentID = parent.ID.ToString(),
                                      CommentBody = parent.Content,
                                      UserID = parent.CreateBy,
                                      UserFullName = Global.EngineFactory.GetParticipantEngine().GetByID(parent.CreateBy).UserInfo.DisplayUserName(),
                                      UserPost = Global.EngineFactory.GetParticipantEngine().GetByID(parent.CreateBy).UserInfo.Title,
                                      UserAvatar = Global.GetHTMLUserAvatar(parent.CreateBy),
                                      CommentList = new List<CommentInfo>(),
                                  };

            if (allComments != null)
                foreach (var comment in allComments.Where(comment => comment.Parent == parent.ID))
                {
                    commentInfo.CommentList.Add(GetCommentInfo(allComments, comment));
                }

            return commentInfo;
        }