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

            CommentInfo c = new CommentInfo
                {
                    CommentID = comment.ID.ToString(),
                    UserID = userID,
                    TimeStamp = comment.Datetime,
                    TimeStampStr = comment.Datetime.Ago(),
                    Inactive = comment.Inactive,
                    CommentBody = comment.Content,
                    UserFullName = DisplayUserSettings.GetFullUserName(userID),
                    UserAvatar = BookmarkingServiceHelper.GetHTMLUserAvatar(userID),
                    IsEditPermissions = BookmarkingPermissionsCheck.PermissionCheckEditComment(comment),
                    IsResponsePermissions = BookmarkingPermissionsCheck.PermissionCheckCreateComment(),
                    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;
        }
 public static string GetOneCommentHtml(
     CommentsList control,
     CommentInfo comment,
     bool odd)
 {
     return GetOneCommentHtml(
         comment,
         odd,
         control.RealUserProfileLinkResolver,
         control.Simple,
         control.BehaviorID,
         control.EditCommentLink,
         control.ResponseCommentLink,
         control.RemoveCommentLink,
         control.InactiveMessage,
         control.ConfirmRemoveCommentMessage,
         control.JavaScriptRemoveCommentFunctionName,
         control.PID
         );
 }
Example #3
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
                ));
 }
        public static string GetOneCommentHtmlWithContainer(
            CommentsList control,
            CommentInfo comment,
            bool isFirstLevel,
            bool odd)
        {
            var cntr = odd ? 1 : 2;

            return(GetOneCommentHtmlWithContainer(
                       comment,
                       isFirstLevel,
                       control.RealUserProfileLinkResolver,
                       control.BehaviorID,
                       control.EditCommentLink,
                       control.ResponseCommentLink,
                       control.RemoveCommentLink,
                       control.InactiveMessage,
                       control.ConfirmRemoveCommentMessage,
                       control.JavaScriptRemoveCommentFunctionName,
                       control.PID,
                       null,
                       ref cntr
                       ));
        }
Example #5
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='blockComments " + (odd ? OddClass : EvenClass) + "' id=\"comment_" + comment.CommentID + "\" style='" + (odd ? OddStyle : EvenStyle) + " padding: 8px 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='90'>");
                sb.Append(comment.UserAvatar);
                sb.Append("</td><td valign=\"top\"><div style=\"min-height:55px;\"><div>");
                sb.Append("<a style=\"margin-left:10px;\" class=\"link bold\" href=\"" + userProfileLink(comment.UserID.ToString()) + "\">" + comment.UserFullName + "</a>");
                sb.Append("&nbsp;&nbsp;");
                sb.Append("<span class=\"text-medium-describe\" 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='describe-text'>{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>");
                sb.Append("<div clas='clearFix' style=\"margin: 10px 0px 0px 10px; height:19px;\" >");

                var drowSplitter = false;

                if (comment.IsResponsePermissions)
                {
                    sb.AppendFormat("<div style='float:left;'><a class=\"link dotline gray\" 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=\"link dotline gray\" 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=\"text-medium-describe  splitter\"> </span>");
                    }

                    sb.AppendFormat("<a class=\"link dotline gray\" 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());
        }
        private static 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(comment, NewsConst.Action_Edit),
                    IsResponsePermissions = CommunitySecurity.CheckPermissions(NewsConst.Action_Comment),
                    UserPost = CoreContext.UserManager.GetUsers((new Guid(comment.Creator))).Title
                };

            return info;
        }
        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='blockComments " + (odd ? OddClass : EvenClass) + "' id=\"comment_" + comment.CommentID + "\" style='" + (odd ? OddStyle : EvenStyle) + " padding: 8px 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='90'>");
                sb.Append(comment.UserAvatar);
                sb.Append("</td><td valign=\"top\"><div style=\"min-height:55px;\"><div>");
                sb.Append("<a style=\"margin-left:10px;\" class=\"link bold\" href=\"" + userProfileLink(comment.UserID.ToString()) + "\">" + comment.UserFullName + "</a>");
                sb.Append("&nbsp;&nbsp;");
                sb.Append("<span class=\"text-medium-describe\" 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='describe-text'>{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>");
                sb.Append("<div clas='clearFix' style=\"margin: 10px 0px 0px 10px; height:19px;\" >");

                var drowSplitter = false;

                if (comment.IsResponsePermissions)
                {
                    sb.AppendFormat("<div style='float:left;'><a class=\"link dotline gray\" 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=\"link dotline gray\" 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=\"text-medium-describe  splitter\"> </span>");

                    sb.AppendFormat("<a class=\"link dotline gray\" 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 #8
0
 public static string GetOneCommentHtmlWithContainer(
     CommentsList control,
     CommentInfo comment,
     bool isFirstLevel,
     bool odd)
 {
     var cntr = odd ? 1 : 2;
     return GetOneCommentHtmlWithContainer(
         comment,
         isFirstLevel,
         control.RealUserProfileLinkResolver,
         control.BehaviorID,
         control.EditCommentLink,
         control.ResponseCommentLink,
         control.RemoveCommentLink,
         control.InactiveMessage,
         control.ConfirmRemoveCommentMessage,
         control.JavaScriptRemoveCommentFunctionName,
         control.PID,
         null,
         ref cntr
         );
 }
        public static string GetOneCommentHtmlWithContainer(
            CommentInfo comment,
            bool isFirstLevel,
            Func<string, string> userProfileLink,
            bool simple,
            string jsObjName,
            string editCommentLink,
            string responseCommentLink,
            string removeCommentLink,
            string inactiveMessage,
            string confirmRemoveCommentMessage,
            string javaScriptRemoveCommentFunctionName,
            string PID,
            RenderInnerComments renderFunction,
            ref int commentIndex
            )
        {
            if (comment.Inactive && IsEmptyComments(comment.CommentList))
                return String.Empty;

            var sb = new StringBuilder();

            sb.AppendFormat("<div style=\"{1}\" id=\"container_{0}\">",
                            comment.CommentID, (!isFirstLevel ? "margin-left: 35px;" : String.Empty));

            sb.Append(
                GetOneCommentHtml(
                    comment,
                    commentIndex%2 == 1,
                    userProfileLink,
                    simple,
                    jsObjName,
                    editCommentLink,
                    responseCommentLink,
                    removeCommentLink,
                    inactiveMessage,
                    confirmRemoveCommentMessage,
                    javaScriptRemoveCommentFunctionName,
                    PID
                    )
                );

            commentIndex++;

            if (renderFunction != null && comment.CommentList != null && comment.CommentList.Count > 0)
                sb.Append(renderFunction(comment.CommentList));

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

            return sb.ToString();
        }
 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
         );
 }
 public static string GetOneCommentHtmlWithContainer(
     CommentInfo comment,
     bool isFirstLevel,
     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 cntr = odd ? 1 : 2;
     return GetOneCommentHtmlWithContainer(
         comment,
         isFirstLevel,
         userProfileLink,
         simple,
         jsObjName,
         editCommentLink,
         responseCommentLink,
         removeCommentLink,
         inactiveMessage,
         confirmRemoveCommentMessage,
         javaScriptRemoveCommentFunctionName,
         PID,
         null,
         ref cntr
         );
 }
        private CommentInfo GetCommentInfo(IEnumerable<Comment> allComments, Comment parent)
        {
            var creator = Global.EngineFactory.GetParticipantEngine().GetByID(parent.CreateBy).UserInfo;
            var commentInfo = new CommentInfo
                {
                    TimeStampStr = parent.CreateOn.Ago(),
                    IsRead = true,
                    Inactive = parent.Inactive,
                    IsResponsePermissions = ProjectSecurity.CanCreateComment(),
                    IsEditPermissions = ProjectSecurity.CanEditComment(Discussion.Project, parent),
                    CommentID = parent.ID.ToString(),
                    CommentBody = parent.Content,
                    UserID = parent.CreateBy,
                    UserFullName = creator.DisplayUserName(),
                    UserPost = creator.Title,
                    UserAvatar = Global.GetHTMLUserAvatar(creator),
                    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;
        }
        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)
            {
                commentInfo.IsEditPermissions = ProjectSecurity.CanEditComment(Discussion.Project, comment);
                commentInfo.IsResponsePermissions = ProjectSecurity.CanCreateComment();
                commentInfo.IsRead = true;
            }

            return CommentsHelper.GetOneCommentHtmlWithContainer(
                defComment,
                commentInfo,
                comment.Parent == Guid.Empty,
                false);
        }
        private string GetHTMLComment(Comment comment)
        {
            var creator = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy);
            var commentInfo = new CommentInfo
                {
                    TimeStamp = comment.CreateOn,
                    TimeStampStr = comment.CreateOn.Ago(),
                    CommentBody = comment.Content,
                    CommentID = comment.ID.ToString(),
                    UserID = comment.CreateBy,
                    UserFullName = creator.UserInfo.DisplayUserName(),
                    Inactive = comment.Inactive,
                    IsEditPermissions = ProjectSecurity.CanEditComment(Discussion != null ? Discussion.Project : null, comment),
                    IsResponsePermissions = ProjectSecurity.CanCreateComment(),
                    IsRead = true,
                    UserAvatar = Global.GetHTMLUserAvatar(creator.UserInfo),
                    UserPost = creator.UserInfo.Title
                };

            if (discussionComments == null)
            {
                discussionComments = new CommentsList();
                ConfigureComments(discussionComments, null);
            }

            return CommentsHelper.GetOneCommentHtmlWithContainer(
                discussionComments,
                commentInfo,
                comment.Parent == Guid.Empty,
                false);
        }
Example #15
0
        private static 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, Constants.Action_EditRemoveComment),
                        IsResponsePermissions = CommunitySecurity.CheckPermissions(post, Constants.Action_AddComment),
                        CommentList = BuildCommentsList(post, loaded, comment.ID)
                    };

                result.Add(info);
            }
            return result;
        }
Example #16
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);
        }
Example #17
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 = CommunitySecurity.CheckPermissions(Common.Constants.Action_AddComment),
                    UserPost = CoreContext.UserManager.GetUsers(comment.UserId).Title
                };

            return info;
        }