private void ShowPost(BlogsEngine engine) { //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao()); //ctrlViewBlogView.AttachPresenter(presenter); ctrlViewBlogView.UpdateCompleted += HandleUpdateCompleted; ctrlViewBlogView.UpdateCancelled += HandleUpdateCancelled; if (IsPostBack) { return; } Post post; try { post = engine.GetPostById(new Guid(BlogId)); } catch (Exception) { post = null; } if (post != null) { ctrlViewBlogView.post = post; var subscriber = new Subscriber(); var postId = String.IsNullOrEmpty(BlogId) ? new Guid() : new Guid(BlogId); var isBlogSubscribe = subscriber.IsCommentsSubscribe(postId); var subscribeTopicLink = subscriber.RenderCommentsSubscriptionLink(!isBlogSubscribe, postId); SubscribeLinkBlock.Text = subscribeTopicLink; BlogTitle = post.Title; var loadedComments = engine.GetPostComments(post.ID); commentList.Items = BuildCommentsList(post, loadedComments); ConfigureComments(commentList, loadedComments.Count, post); engine.SavePostReview(post, SecurityContext.CurrentAccount.ID); } else { ctrlViewBlogView.Visible = false; lblMessage.Visible = true; mainContainer.CurrentPageCaption = BlogsResource.AddonName; commentList.Visible = false; ConfigureComments(commentList, 0, null); } }
private void ShowPost(BlogsEngine engine) { //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao()); //ctrlViewBlogView.AttachPresenter(presenter); ctrlViewBlogView.UpdateCompleted += new EventHandler(HandleUpdateCompleted); ctrlViewBlogView.UpdateCancelled += new EventHandler(HandleUpdateCancelled); if (!IsPostBack) { Post post = null; try { post = engine.GetPostById(new Guid(BlogId)); base.InitSubscribers(actions, post.UserID); } catch (Exception) { post = null; } if (post != null) { ctrlViewBlogView.post = post; mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath ) }); mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = DisplayUserSettings.GetFullUserName(post.UserID, false), NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID }); mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = post.Title }); var loadedComments = engine.GetPostComments(post.ID); commentList.Items = BuildCommentsList(post, loadedComments); ConfigureComments(commentList, loadedComments.Count, post); if (!SecurityContext.DemoMode) engine.SavePostReview(post,SecurityContext.CurrentAccount.ID); } else { ctrlViewBlogView.Visible = false; lblMessage.Visible = true; mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) }); commentList.Visible = false; ConfigureComments(commentList, 0, null); } } }
private void ShowForEdit(BlogsEngine engine) { if (!IsPostBack) { var post = engine.GetPostById(new Guid(BlogId)); InitPreviewTemplate(post); if (post != null && CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost)) { hdnUserID.Value = post.UserID.ToString(); if (Request.QueryString["action"] == "delete") { foreach (var comment in engine.GetPostComments(post.ID)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs_comments", comment.ID.ToString()); } engine.DeletePost(post); CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs", post.ID.ToString()); Response.Redirect(Constants.DefaultPageUrl); return; } else { txtTitle.Text = Server.HtmlDecode(post.Title); if (_mobileVer) { _text = post.Content; } else { FCKeditor.Value = post.Content; } hidBlogID.Value = post.ID.ToString(); LoadTags(post.TagList); } } else { Response.Redirect(Constants.DefaultPageUrl); return; } } }
private void ShowPost(BlogsEngine engine) { //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao()); //ctrlViewBlogView.AttachPresenter(presenter); ctrlViewBlogView.UpdateCompleted += HandleUpdateCompleted; ctrlViewBlogView.UpdateCancelled += HandleUpdateCancelled; if (IsPostBack) return; Post post; try { post = engine.GetPostById(new Guid(BlogId)); } catch (Exception) { post = null; } if (post != null) { ctrlViewBlogView.post = post; var subscriber = new Subscriber(); var postId = String.IsNullOrEmpty(BlogId) ? new Guid() : new Guid(BlogId); var isBlogSubscribe = subscriber.IsCommentsSubscribe(postId); var subscribeTopicLink = subscriber.RenderCommentsSubscriptionLink(!isBlogSubscribe, postId); SubscribeLinkBlock.Text = subscribeTopicLink; BlogTitle = post.Title; var loadedComments = engine.GetPostComments(post.ID); commentList.Items = BuildCommentsList(post, loadedComments); ConfigureComments(commentList, loadedComments.Count, post); engine.SavePostReview(post, SecurityContext.CurrentAccount.ID); } else { ctrlViewBlogView.Visible = false; lblMessage.Visible = true; mainContainer.CurrentPageCaption = BlogsResource.AddonName; commentList.Visible = false; ConfigureComments(commentList, 0, null); } }
public AjaxResponse UpdateComment(string commentID, string text, string pid) { AjaxResponse resp = new AjaxResponse(); resp.rs1 = commentID; Guid?id = null; try { if (!String.IsNullOrEmpty(commentID)) { id = new Guid(commentID); } } catch { return(new AjaxResponse()); } BlogsEngine engine = BasePage.GetEngine(); var comment = engine.GetCommentById(id.Value); if (comment == null) { throw new ApplicationException("Comment not found"); } CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment); comment.Content = text; var post = engine.GetPostById(comment.PostId); engine.UpdateComment(comment, post); resp.rs2 = text + Web.Controls.CodeHighlighter.GetJavaScriptLiveHighlight(true); return(resp); }
public string RemoveComment(string commentID, string pid) { AjaxResponse resp = new AjaxResponse(); resp.rs1 = commentID; Guid?id = null; try { if (!String.IsNullOrEmpty(commentID)) { id = new Guid(commentID); } } catch { return(commentID); } BlogsEngine engine = BasePage.GetEngine(); var comment = engine.GetCommentById(id.Value); if (comment == null) { throw new ApplicationException("Comment not found"); } CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment); comment.Inactive = true; var post = engine.GetPostById(comment.PostId); engine.RemoveComment(comment, post); return(commentID); }
private void ShowForEdit(BlogsEngine engine) { if (!IsPostBack) { var post = engine.GetPostById(new Guid(BlogId)); InitPreviewTemplate(post); if (post != null && CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost)) { hdnUserID.Value = post.UserID.ToString(); if (Request.QueryString["action"] == "delete") { foreach (var comment in engine.GetPostComments(post.ID)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs_comments", comment.ID.ToString()); } engine.DeletePost(post); CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs", post.ID.ToString()); Response.Redirect(Constants.DefaultPageUrl); return; } else { txtTitle.Text = Server.HtmlDecode(post.Title); _text = post.Content; hidBlogID.Value = post.ID.ToString(); LoadTags(post.TagList); } } else { Response.Redirect(Constants.DefaultPageUrl); return; } } }
private void ShowPost(BlogsEngine engine) { //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao()); //ctrlViewBlogView.AttachPresenter(presenter); ctrlViewBlogView.UpdateCompleted += new EventHandler(HandleUpdateCompleted); ctrlViewBlogView.UpdateCancelled += new EventHandler(HandleUpdateCancelled); if (!IsPostBack) { Post post = null; try { post = engine.GetPostById(new Guid(BlogId)); base.InitSubscribers(actions, post.UserID); } catch (Exception) { post = null; } if (post != null) { ctrlViewBlogView.post = post; mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) }); mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = DisplayUserSettings.GetFullUserName(post.UserID, false), NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID }); mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = post.Title }); var loadedComments = engine.GetPostComments(post.ID); commentList.Items = BuildCommentsList(post, loadedComments); ConfigureComments(commentList, loadedComments.Count, post); if (!SecurityContext.DemoMode) { engine.SavePostReview(post, SecurityContext.CurrentAccount.ID); } } else { ctrlViewBlogView.Visible = false; lblMessage.Visible = true; mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) }); commentList.Visible = false; ConfigureComments(commentList, 0, null); } } }