private void ConfigureComments(CommentsList commentList)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            // add comments permission check		
            commentList.IsShowAddCommentBtn = BookmarkingPermissionsCheck.PermissionCheckCreateComment();
            commentList.CommentsCountTitle = BookmarkComments.Count.ToString();
            commentList.Simple = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName = "CommentsUserControl.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "CommentsUserControl.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName = "CommentsUserControl.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "CommentsUserControl.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "CommentsUserControl.UpdateComment";
            commentList.FckDomainName = "bookmarking_comments";
            commentList.TotalCount = BookmarkComments.Count;
            commentList.ShowCaption = false;
            commentList.ObjectID = BookmarkID.ToString();
        }
 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
         );
 }
 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
                ));
 }
 public static string GetOneCommentHtmlWithContainer(
     CommentsList control,
     CommentInfo comment,
     bool isFirstLevel,
     RenderInnerComments renderFunction,
     ref int commentIndex)
 {
     return(GetOneCommentHtmlWithContainer(
                comment,
                isFirstLevel,
                control.RealUserProfileLinkResolver,
                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
                       ));
        }
        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 = HtmlUtility.GetFull(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);
        }
        private static void ConfigureComments(CommentsList commentList, Message messageToUpdate)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            var countMessageToUpdate = messageToUpdate != null ? Global.EngineFactory.GetCommentEngine().Count(messageToUpdate) : 0;

            commentList.IsShowAddCommentBtn = ProjectSecurity.CanCreateComment();
            commentList.CommentsCountTitle = countMessageToUpdate != 0 ? countMessageToUpdate.ToString(CultureInfo.InvariantCulture) : "0";
            commentList.ObjectID = messageToUpdate != null
                                       ? messageToUpdate.ID.ToString(CultureInfo.InvariantCulture) : "";

            commentList.Simple = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName = "AjaxPro.DiscussionDetails.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "AjaxPro.DiscussionDetails.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName = "AjaxPro.DiscussionDetails.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "AjaxPro.DiscussionDetails.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "AjaxPro.DiscussionDetails.UpdateComment";
            commentList.OnRemovedCommentJS = "ASC.Projects.DiscussionDetails.removeComment";
            commentList.FckDomainName = "projects_comments";
            commentList.TotalCount = countMessageToUpdate;
        }
        private static void ConfigureComments(CommentsList commentList, FeedNS.Feed feed)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);
            commentList.Simple = false;
            commentList.BehaviorID = "_commentsObj";
            commentList.FckDomainName = "news_comments";

            commentList.JavaScriptAddCommentFunctionName = "Default.AddComment";
            commentList.JavaScriptPreviewCommentFunctionName = "Default.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "Default.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "Default.UpdateComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "Default.LoadCommentText";

            commentList.ObjectID = feed != null ? feed.Id.ToString(CultureInfo.CurrentCulture) : "";
        }
        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 = HtmlUtility.GetFull(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;
        }
 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 AjaxResponse AddComment(string parentCommentId, string pageName, string text, string pid)
        {
            CommunitySecurity.DemandPermissions(Common.Constants.Action_AddComment);

            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;
        }
        private static void ConfigureComments(CommentsList commentList, int totalCount, Post postToUpdate)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.IsShowAddCommentBtn = CommunitySecurity.CheckPermissions(postToUpdate, Constants.Action_AddComment);
            commentList.CommentsCountTitle = totalCount > 0 ? totalCount.ToString() : "";
            commentList.FckDomainName = commentList.ObjectID = postToUpdate != null ? postToUpdate.ID.ToString() : "";
            commentList.Simple = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName = "ViewBlog.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "ViewBlog.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName = "ViewBlog.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "ViewBlog.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "ViewBlog.UpdateComment";
            commentList.FckDomainName = "blogs_comments";

            commentList.TotalCount = totalCount;
        }
        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);
        }
        private static void ConfigureComments(CommentsList commentList, string pageName)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.Simple = false;
            commentList.BehaviorID = "_commentsWikiObj";

            commentList.IsShowAddCommentBtn = CommunitySecurity.CheckPermissions(Common.Constants.Action_AddComment);

            commentList.JavaScriptAddCommentFunctionName = "_Default.AddComment";
            commentList.JavaScriptPreviewCommentFunctionName = "_Default.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "_Default.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "_Default.UpdateComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "_Default.LoadCommentText";
            commentList.FckDomainName = "wiki_comments";

            commentList.ObjectID = pageName.HtmlEncode();
        }
        public static void CommentsConfigure(CommentsList commentList)
        {
            commentList.PID = CommonLinkUtility.GetProductID().ToString();
            commentList.InactiveMessage = Resources.Resource.CommentRemovedMessage;
            commentList.UserProfileUrlResolver = user => CommonLinkUtility.GetUserProfile(user);
            commentList.AddCommentLink = Resources.Resource.AddNewCommentButton;
            commentList.CancelCommentLink = Resources.Resource.CancelCommentButton;

            commentList.SaveButton = Resources.Resource.PublishButton;
            commentList.BehaviorID = "_commentObj";

            commentList.PreviewButton = Resources.Resource.PreviewButton;
            commentList.HidePrevuewButton = Resources.Resource.CloseButton;
            commentList.CancelButton = Resources.Resource.CancelButton;
            commentList.InactiveMessage = Resources.Resource.CommentWasRemoved;

            commentList.RemoveCommentLink = Resources.Resource.DeleteButton;
            commentList.ResponseCommentLink = Resources.Resource.AnswerButton;
            commentList.EditCommentLink = Resources.Resource.EditButton;

            commentList.CommentsTitle = Resources.Resource.Comments;

            commentList.ConfirmRemoveCommentMessage = Resources.Resource.ConfirmRemoveCommentMessage;

            commentList.AdditionalSubmitText = "<span class=\"text-medium-describe\" style=\"margin-left:5px;\">" + Resources.Resource.OrPress + "</span> <span class=\"text-base\">" + Resources.Resource.CtrlEnterKeys + "</span>";

            commentList.OnEditedCommentJS = "FCKCommentsController.EditCommentHandler";
            commentList.OnCanceledCommentJS = "FCKCommentsController.CancelCommentHandler";
            commentList.OnRemovedCommentJS = "FCKCommentsController.RemoveCommentHandler";

            try
            {
                AjaxPro.Utility.RegisterTypeForAjax(typeof(CommonControlsConfigurer));
            }
            catch
            {
            }
        }
 public void InitComments()
 {
     ConfigureComments(CommentList);
     CommentList.Items = BookmarkingConverter.ConvertCommentList(BookmarkComments);
     Comments = CommentList;
 }
        private string GetHTMLComment(string text, string commentID)
        {
            var comment = new Comment
                {
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    UserID = SecurityContext.CurrentAccount.ID
                };

            if (!String.IsNullOrEmpty(commentID))
            {
                comment = _serviceHelper.GetCommentById(commentID);

                comment.Parent = string.Empty;
            }
            comment.Content = HtmlUtility.GetFull(text);

            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);
        }
 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
         );
 }
        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);
        }
        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 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);
        }
        private static void ConfigureComments(CommentsList commentList, Task taskToUpdate)
        {
            var commentsCount = Global.EngineFactory.GetCommentEngine().Count(taskToUpdate);

            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.IsShowAddCommentBtn = ProjectSecurity.CanCreateComment();

            commentList.CommentsCountTitle = commentsCount != 0 ? commentsCount.ToString() : "";

            commentList.ObjectID = taskToUpdate != null ? taskToUpdate.ID.ToString() : "";
            commentList.Simple = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName = "AjaxPro.TaskDescriptionView.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "AjaxPro.TaskDescriptionView.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName = "AjaxPro.TaskDescriptionView.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "AjaxPro.TaskDescriptionView.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "AjaxPro.TaskDescriptionView.UpdateComment";
            commentList.FckDomainName = "projects_comments";

            commentList.TotalCount = commentsCount;
        }