public string GetCategoryList() { var categories = new List <ThreadCategory>(); var threads = new List <Thread>(); ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); StringBuilder sb = new StringBuilder(); sb.Append("<div class='headerPanelSmall-splitter'><b>" + Resources.ForumResource.ThreadCategory + ":</b></div>"); sb.Append("<select id='forum_fmCategoryID' onchange=\"ForumMakerProvider.SelectCategory();\" style='width:100%;' class='comboBox'>"); sb.Append("<option value='-1'>" + Resources.ForumResource.TypeCategoryName + "</option>"); foreach (var categ in categories) { sb.Append("<option value='" + categ.ID + "'>" + categ.Title.HtmlEncode() + "</option>"); } sb.Append("</select>"); //jq('#forum_fmCategoryList').html(result.value); //jq('#forum_fmMessage').html(''); //jq('#forum_fmMessage').hide(); //jq('#forum_fmCategoryName').val(''); //jq('#forum_fmForumName').val(''); //jq('#forum_fmForumDescription').val(''); return(sb.ToString()); }
protected void Page_Load(object sender, EventArgs e) { ForumManager.Instance.SetCurrentPage(ForumPage.Default); List <ThreadCategory> categories; List <Thread> threads; ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, true, out categories, out threads); if (0 < categories.Count) { var categoryListControl = LoadControl(ForumManager.Settings.UserControlsVirtualPath + "/ThreadCategoryListControl.ascx") as UserControls.Forum.ThreadCategoryListControl; categoryListControl.Categories = categories; categoryListControl.Threads = threads; categoryListControl.SettingsID = ForumManager.Settings.ID; forumListHolder.Controls.Add(categoryListControl); (Master as ForumMasterPage).CurrentPageCaption = ForumResource.ForumsBreadCrumbs; } else { _headerHolder.Visible = false; var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("forums_icon.png", ForumManager.Settings.ModuleID), Header = ForumResource.EmptyScreenForumCaption, Describe = ForumResource.EmptyScreenForumText, ButtonHTML = ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null) ? String.Format("<a class='link underline blue plus' href='NewForum.aspx'>{0}</a>", ForumResource.EmptyScreenForumLink) : String.Empty }; forumListHolder.Controls.Add(emptyScreenControl); } Title = HeaderStringHelper.GetPageTitle((Master as ForumMasterPage).CurrentPageCaption ?? ForumResource.AddonName); }
public AjaxResponse SaveMembers(int id, bool isCategory, string userIDs) { var resp = new AjaxResponse { rs2 = id.ToString(), rs4 = isCategory ? "1" : "0" }; try { if (!ForumManager.Instance.ValidateAccessSecurityAction(ASC.Forum.ForumAction.GetAccessForumEditor, null)) { throw new Exception(Resources.ForumResource.ErrorAccessDenied); } List <ThreadCategory> categories; List <Thread> threads; ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); resp.rs1 = "1"; } catch (Exception e) { resp.rs1 = "0"; resp.rs3 = "<div>" + e.Message.HtmlEncode() + "</div>"; } return(resp); }
protected string RenderForumCategories() { List <ThreadCategory> categories; List <Thread> threads; ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); var sb = new StringBuilder(); HasCategories = categories.Count > 0; if (HasCategories) { foreach (var category in categories) { sb.Append(RenderForumCategory(category, threads.FindAll(t => t.CategoryID == category.ID))); } } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("forums_icon.png", ForumManager.Settings.ModuleID), Header = Resources.ForumResource.EmptyScreenForumCaption, Describe = Resources.ForumResource.EmptyScreenForumText, ButtonHTML = String.Format("<a class='link underline blue plus' href='NewForum.aspx'>{0}</a>", Resources.ForumResource.EmptyScreenForumLink) }; EmptyContent.Controls.Add(emptyScreenControl); } return(sb.ToString()); }
public string UpdateCategorySortOrder(string sortOrders) { try { if (!ForumManager.Instance.ValidateAccessSecurityAction(ASC.Forum.ForumAction.GetAccessForumEditor, null)) { throw new Exception(Resources.ForumResource.ErrorAccessDenied); } List <ThreadCategory> categories; List <Thread> threads; ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); foreach (var so in sortOrders.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { var cid = Convert.ToInt32(so.Split(':')[0]); var order = Convert.ToInt32(so.Split(':')[1]); var category = categories.Find(c => c.ID == cid); if (category != null) { category.SortOrder = order; ForumDataProvider.UpdateThreadCategory(TenantProvider.CurrentTenantID, category.ID, category.Title, category.Description, category.SortOrder); } } return("ok"); } catch (Exception e) { return(e.Message.HtmlEncode()); } }
private void GetSubscriptionObjectsHandler(object sender, SubscriptionEventArgs e) { var recipient = (IDirectRecipient)ForumNotifySource.Instance.GetRecipientsProvider().GetRecipient(e.UserID.ToString()); if (recipient == null) { _view.SubscriptionObjects = new List <object>(0); return; } List <string> objIDs = new List <string>(ForumNotifySource.Instance.GetSubscriptionProvider().GetSubscriptions(e.NotifyAction, recipient, false)); if (objIDs == null || objIDs.Count == 0) { _view.SubscriptionObjects = new List <object>(0); return; } if (String.Equals(e.NotifyAction.ID, SubscriptionConstants.NewPostInTopic.ID, StringComparison.InvariantCultureIgnoreCase)) { _view.SubscriptionObjects = ForumDataProvider.GetTopicsByIDs(e.TenantID, objIDs.ConvertAll <int>(id => Convert.ToInt32(id)), false) .ConvertAll <object>(topic => (object)topic); } else if (String.Equals(e.NotifyAction.ID, SubscriptionConstants.NewPostInThread.ID, StringComparison.InvariantCultureIgnoreCase)) { List <ThreadCategory> categories = null; List <Thread> threads = null; ForumDataProvider.GetThreadCategories(e.TenantID, false, out categories, out threads); threads.RemoveAll(tid => (objIDs.Find(id => id == tid.ID.ToString()) == null)); _view.SubscriptionObjects = threads.ConvertAll <object>(thread => (object)thread); } else if (String.Equals(e.NotifyAction.ID, SubscriptionConstants.NewPostByTag.ID, StringComparison.InvariantCultureIgnoreCase)) { _view.SubscriptionObjects = ForumDataProvider.GetTagByIDs(e.TenantID, objIDs.ConvertAll <int>(id => Convert.ToInt32(id))) .ConvertAll <object>(tag => (object)tag); } else if (String.Equals(e.NotifyAction.ID, SubscriptionConstants.NewTopicInForum.ID, StringComparison.InvariantCultureIgnoreCase)) { if (objIDs != null && objIDs.Count == 1 && objIDs[0] == null) { var objList = new List <object>(); objList.Add(null); _view.SubscriptionObjects = objList; } } }
protected string RenderForumCategories() { var categories = new List <ThreadCategory>(); var threads = new List <Thread>(); ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); StringBuilder sb = new StringBuilder(); foreach (ThreadCategory category in categories) { sb.Append(RenderForumCategory(category, threads.FindAll(t => t.CategoryID == category.ID))); } return(sb.ToString()); }
protected string RenderForumSelector() { if (!_isSelectForum) { return(""); } if (_threads == null) { ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out _categories, out _threads); _threads.RemoveAll(t => !t.Visible); } StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"headerPanel\" style='margin-top:0px;'>"); sb.Append(Resources.ForumUCResource.Thread); sb.Append("</div>"); sb.Append("<div style=\"padding-top:3px; padding-bottom: 20px;\">"); sb.Append("<select name=\"forum_thread_id\" class=\"comboBox\" style='width:100%;'>"); foreach (var forum in _threads) { bool isAllow = false; if (PostType == NewPostType.Topic) { isAllow = _forumManager.ValidateAccessSecurityAction(ForumAction.TopicCreate, forum); } else if (PostType == NewPostType.Poll) { isAllow = _forumManager.ValidateAccessSecurityAction(ForumAction.PollCreate, forum); } if (isAllow) { sb.Append("<option value=\"" + forum.ID + "\">" + forum.Title.HtmlEncode() + "</option>"); } } sb.Append("</select>"); sb.Append("</div>"); return(sb.ToString()); }
public string UpdateThreadSortOrder(string sortOrders) { try { if (!ForumManager.Instance.ValidateAccessSecurityAction(ASC.Forum.ForumAction.GetAccessForumEditor, null)) { throw new Exception(Resources.ForumResource.ErrorAccessDenied); } List <ThreadCategory> categories; List <Thread> threads; ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); foreach (var categoryItem in sortOrders.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { var cid = Convert.ToInt32(categoryItem.Split('@')[0]); var threadStr = categoryItem.Split('@')[1]; var category = categories.Find(c => c.ID == cid); if (category != null) { foreach (var thrItem in threadStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { int tid = Convert.ToInt32(thrItem.Split(':')[0]); int order = Convert.ToInt32(thrItem.Split(':')[1]); var thread = threads.Find(t => t.ID == tid); if (thread != null) { thread.CategoryID = category.ID; thread.SortOrder = order; ForumDataProvider.UpdateThread(TenantProvider.CurrentTenantID, thread.ID, thread.CategoryID, thread.Title, thread.Description, thread.SortOrder); } } } } return("ok"); } catch (Exception e) { return(e.Message); } }
public string GetCategoryList() { var categories = new List <ThreadCategory>(); var threads = new List <Thread>(); ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); StringBuilder sb = new StringBuilder(); sb.Append("<div>" + Resources.ForumResource.ThreadCategory + ":</div>"); sb.Append("<select id='forum_fmCategoryID' onchange=\"ForumMakerProvider.SelectCategory();\" style='margin-top:3px; width:99%;' class='comboBox'>"); sb.Append("<option value='-1'>" + Resources.ForumResource.TypeCategoryName + "</option>"); foreach (var categ in categories) { sb.Append("<option value='" + categ.ID + "'>" + categ.Title.HtmlEncode() + "</option>"); } sb.Append("</select>"); return(sb.ToString()); }
public AjaxResponse SaveMembers(int id, bool isCategory, string userIDs) { AjaxResponse resp = new AjaxResponse(); resp.rs2 = id.ToString(); resp.rs4 = isCategory ? "1" : "0"; ISecurityObject securityObj = null; try { if (!ForumManager.Instance.ValidateAccessSecurityAction(ASC.Forum.ForumAction.GetAccessForumEditor, null)) { new Exception(Resources.ForumResource.ErrorAccessDenied); } var categories = new List <ThreadCategory>(); var threads = new List <Thread>(); ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads); if (isCategory) { securityObj = categories.Find(c => c.ID == id); } else { securityObj = threads.Find(t => t.ID == id); } resp.rs1 = "1"; } catch (Exception e) { resp.rs1 = "0"; resp.rs3 = "<div>" + e.Message.HtmlEncode() + "</div>"; } return(resp); }
protected void Page_Load(object sender, EventArgs e) { ForumManager.Instance.SetCurrentPage(ForumPage.Default); List <ThreadCategory> categories; List <Thread> threads; ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, true, out categories, out threads); if (0 < categories.Count) { var categoryListControl = LoadControl(ForumManager.Settings.UserControlsVirtualPath + "/ThreadCategoryListControl.ascx") as UserControls.Forum.ThreadCategoryListControl; categoryListControl.Categories = categories; categoryListControl.Threads = threads; categoryListControl.SettingsID = ForumManager.Settings.ID; forumListHolder.Controls.Add(categoryListControl); } else { _headerHolder.Visible = false; var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("forums_icon.png", ForumManager.Settings.ModuleID), Header = Resources.ForumResource.EmptyScreenForumCaption, Describe = Resources.ForumResource.EmptyScreenForumText, ButtonHTML = ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null) ? String.Format("<a class='linkAddMediumText' href='javascript:ForumMakerProvider.ShowForumMakerDialog(false,\"window.location.reload(true)\");'>{0}</a>", Resources.ForumResource.EmptyScreenForumLink) : String.Empty }; forumListHolder.Controls.Add(emptyScreenControl); } var breadCrumbs = (Master as ForumMasterPage).BreadCrumbs; breadCrumbs.Add(new BreadCrumb { Caption = Resources.ForumResource.ForumsBreadCrumbs, NavigationUrl = "default.aspx" }); Title = HeaderStringHelper.GetPageTitle(Resources.ForumResource.AddonName, breadCrumbs); }
protected void Page_Load(object sender, EventArgs e) { _mobileVer = ASC.Web.Core.Mobile.MobileDetector.IsRequestMatchesMobile(this.Context); _settings = ForumManager.GetSettings(SettingsID); _forumManager = _settings.ForumManager; _currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); Utility.RegisterTypeForAjax(typeof(TagSuggest)); Utility.RegisterTypeForAjax(this.GetType()); Utility.RegisterTypeForAjax(typeof(PostControl)); _uploadSwitchHolder.Controls.Add(new FileUploaderModeSwitcher()); FCKeditor.BasePath = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath); FCKeditor.ToolbarSet = "ForumToolbar"; FCKeditor.EditorAreaCSS = WebSkin.GetUserSkin().BaseCSSFileAbsoluteWebPath; FCKeditor.Visible = !_mobileVer; PostType = NewPostType.Topic; PostAction = PostAction.Normal; int idTopic = 0; int idThread = 0; if (!String.IsNullOrEmpty(Request[_settings.TopicParamName])) { try { idTopic = Convert.ToInt32(Request[_settings.TopicParamName]); } catch { idTopic = 0; } if (idTopic == 0) { Response.Redirect(_settings.StartPageAbsolutePath); return; } else { PostType = NewPostType.Post; } } else if (!String.IsNullOrEmpty(Request[_settings.ThreadParamName])) { try { idThread = Convert.ToInt32(Request[_settings.ThreadParamName]); } catch { idThread = 0; } if (idThread == 0) { Response.Redirect(_settings.StartPageAbsolutePath); return; } else { PostType = NewPostType.Topic; } int topicType = 0; try { topicType = Convert.ToInt32(Request[_settings.PostParamName]); } catch { topicType = 0; } if (topicType == 1) { PostType = NewPostType.Poll; } } else { int topicType = 0; try { topicType = Convert.ToInt32(Request[_settings.PostParamName]); } catch { topicType = 0; } if (topicType == 1) { PostType = NewPostType.Poll; } if (IsPostBack) { if (!String.IsNullOrEmpty(Request["forum_thread_id"])) { try { idThread = Convert.ToInt32(Request["forum_thread_id"]); } catch { idThread = 0; } } } else { ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out _categories, out _threads); foreach (var thread in _threads) { bool isAllow = false; if (PostType == NewPostType.Topic) { isAllow = _forumManager.ValidateAccessSecurityAction(ForumAction.TopicCreate, thread); } else if (PostType == NewPostType.Poll) { isAllow = _forumManager.ValidateAccessSecurityAction(ForumAction.PollCreate, thread); } if (isAllow) { idThread = thread.ID; Thread = thread; break; } } } if (idThread == 0) { Response.Redirect(_settings.StartPageAbsolutePath); return; } _isSelectForum = true; } if (PostType == NewPostType.Topic || PostType == NewPostType.Poll) { if (Thread == null) { Thread = ForumDataProvider.GetThreadByID(TenantProvider.CurrentTenantID, idThread); } if (Thread == null) { Response.Redirect(_settings.StartPageAbsolutePath); return; } if (Thread.Visible == false) { Response.Redirect(_settings.StartPageAbsolutePath); } _threadForAttachFiles = Thread.ID; if (PostType == NewPostType.Topic) { if (!_forumManager.ValidateAccessSecurityAction(ForumAction.TopicCreate, Thread)) { Response.Redirect(_settings.StartPageAbsolutePath); return; } this.Page.Title = this.NewTopicPageTitle; } else if (PostType == NewPostType.Poll) { if (!_forumManager.ValidateAccessSecurityAction(ForumAction.PollCreate, Thread)) { Response.Redirect(_settings.StartPageAbsolutePath); return; } this.Page.Title = this.NewPollPageTitle; } } else if (PostType == NewPostType.Post) { int parentPostId = 0; this.Page.Title = this.NewPostPageTitle; if (!String.IsNullOrEmpty(Request[_settings.ActionParamName]) && !String.IsNullOrEmpty(Request[_settings.PostParamName])) { try { PostAction = (PostAction)Convert.ToInt32(Request[_settings.ActionParamName]); } catch { PostAction = PostAction.Normal; } try { parentPostId = Convert.ToInt32(Request[_settings.PostParamName]); } catch { parentPostId = 0; PostAction = PostAction.Normal; } } Topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic); if (Topic == null) { Response.Redirect(_settings.StartPageAbsolutePath); return; } if (new Thread() { ID = Topic.ThreadID }.Visible == false) { Response.Redirect(_settings.StartPageAbsolutePath); return; } var recentPosts = ForumDataProvider.GetRecentTopicPosts(TenantProvider.CurrentTenantID, Topic.ID, 5, (PostAction == PostAction.Normal || PostAction == PostAction.Edit) ? 0 : parentPostId); if (recentPosts.Count > 0) { Label titleRecentPosts = new Label(); titleRecentPosts.Text = "<div class=\"headerPanel\" style='margin-top:20px;'>" + Resources.ForumUCResource.RecentPostFromTopic + "</div>"; _recentPostsHolder.Controls.Add(titleRecentPosts); int i = 0; foreach (Post post in recentPosts) { PostControl postControl = (PostControl)LoadControl(_settings.UserControlsVirtualPath + "/PostControl.ascx"); postControl.Post = post; postControl.SettingsID = SettingsID; postControl.IsEven = (i % 2 == 0); _recentPostsHolder.Controls.Add(postControl); i++; } } _threadForAttachFiles = Topic.ThreadID; if (PostAction == PostAction.Quote || PostAction == PostAction.Reply || PostAction == PostAction.Normal) { if (!_forumManager.ValidateAccessSecurityAction(ForumAction.PostCreate, Topic)) { Response.Redirect(_settings.StartPageAbsolutePath); return; } if (PostAction == PostAction.Quote || PostAction == PostAction.Reply) { ParentPost = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, parentPostId); if (ParentPost == null) { Response.Redirect(_settings.StartPageAbsolutePath); return; } } _subject = Topic.Title; if (PostAction == PostAction.Quote) { _text = String.Format(@"<div class=""mainQuote""> <div class=""quoteCaption""><span class=""bold"">{0}</span> {1}</div> <div id=""quote"" > <div class=""bord""><div class=""t""><div class=""r""> <div class=""b""><div class=""l""><div class=""c""> <div class=""reducer""> {2} </div> </div></div></div> </div></div></div> </div> </div><br/>", ParentPost.Poster.DisplayUserName(), Resources.ForumUCResource.QuoteCaptioon_Wrote + ":", ParentPost.Text); } if (PostAction == PostAction.Reply) { _text = "<span class=\"headerPanel\">To: " + ParentPost.Poster.DisplayUserName() + "</span><br/><br/>"; } } else if (PostAction == PostAction.Edit) { EditedPost = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, parentPostId); if (EditedPost == null) { Response.Redirect(_settings.StartPageAbsolutePath); return; } if (!_forumManager.ValidateAccessSecurityAction(ForumAction.PostEdit, EditedPost)) { Response.Redirect("default.aspx"); return; } Topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, EditedPost.TopicID); _text = EditedPost.Text; _subject = EditedPost.Subject; } } if (!IsPostBack && !_mobileVer) { FCKeditor.Value = _text; } if (PostType != NewPostType.Poll) { _pollMaster.Visible = false; } else { _pollMaster.QuestionFieldID = "forum_subject"; } if (IsPostBack) { _attachmentsString = Request["forum_attachments"] ?? ""; #region IsPostBack if (PostType == NewPostType.Topic) { _subject = string.IsNullOrEmpty(Request["forum_subject"]) ? string.Empty : Request["forum_subject"].Trim(); } else if (PostType == NewPostType.Poll) { _subject = string.IsNullOrEmpty(_pollMaster.Name) ? string.Empty : _pollMaster.Name.Trim(); } if (String.IsNullOrEmpty(_subject) && PostType != NewPostType.Post) { _subject = ""; _errorMessage = "<div class=\"errorBox\">" + Resources.ForumUCResource.ErrorSubjectEmpty + "</div>"; return; } if (!String.IsNullOrEmpty(Request["forum_tags"])) { Regex r = new Regex(@"\s*,\s*", RegexOptions.Compiled); _tagString = r.Replace(Request["forum_tags"].Trim(), ","); } if (!String.IsNullOrEmpty(Request["forum_search_tags"])) { _tagValues = Request["forum_search_tags"].Trim(); } _text = Request["forum_text"].Trim(); if (String.IsNullOrEmpty(_text)) { _text = ""; _errorMessage = "<script type='text/javascript'>jq(document).ready (function(){ForumManager.ShowInfoMessage('" + Resources.ForumUCResource.ErrorTextEmpty + "');});</script>"; return; } else { _text = _text.Replace("<br />", "<br />\r\n").TrimEnd('\r', '\n'); } if (String.IsNullOrEmpty(Request["forum_topSubscription"])) { _subscribeViewType = SubscriveViewType.Disable; } else { if (String.Equals(Request["forum_topSubscription"], "1", StringComparison.InvariantCultureIgnoreCase)) { _subscribeViewType = SubscriveViewType.Checked; } else { _subscribeViewType = SubscriveViewType.Unchecked; } } if (PostType == NewPostType.Post) { if (PostAction == PostAction.Edit) { EditedPost.Subject = _subject; EditedPost.Text = _text; EditedPost.Formatter = _formatter; try { ForumDataProvider.UpdatePost(TenantProvider.CurrentTenantID, EditedPost.ID, EditedPost.Subject, EditedPost.Text, EditedPost.Formatter); if (IsAllowCreateAttachment) { CreateAttachments(EditedPost); } CommonControlsConfigurer.FCKEditingComplete(_settings.FileStoreModuleID, EditedPost.ID.ToString(), EditedPost.Text, true); var redirectUrl = _settings.PostPageAbsolutePath + "&t=" + EditedPost.TopicID.ToString() + "&p=1#" + EditedPost.ID.ToString(); Response.Redirect(redirectUrl); return; } catch (Exception ex) { _errorMessage = "<div class=\"errorBox\">" + ex.Message.HtmlEncode() + "</div>"; return; } } else { var post = new Post(Topic.Title, _text); post.TopicID = Topic.ID; post.ParentPostID = ParentPost == null ? 0 : ParentPost.ID; post.Formatter = _formatter; post.IsApproved = _forumManager.ValidateAccessSecurityAction(ForumAction.ApprovePost, Topic); try { post.ID = ForumDataProvider.CreatePost(TenantProvider.CurrentTenantID, post.TopicID, post.ParentPostID, post.Subject, post.Text, post.IsApproved, post.Formatter); Topic.PostCount++; CommonControlsConfigurer.FCKEditingComplete(_settings.FileStoreModuleID, post.ID.ToString(), post.Text, false); if (IsAllowCreateAttachment) { CreateAttachments(post); } NotifyAboutNewPost(post); if (_subscribeViewType != SubscriveViewType.Disable) { _forumManager.PresenterFactory.GetPresenter <ISubscriberView>().SetView(this); if (this.GetSubscriptionState != null) { this.GetSubscriptionState(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInTopic, Topic.ID.ToString(), SecurityContext.CurrentAccount.ID)); } if (this.IsSubscribe && _subscribeViewType == SubscriveViewType.Unchecked) { if (this.UnSubscribe != null) { this.UnSubscribe(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInTopic, Topic.ID.ToString(), SecurityContext.CurrentAccount.ID)); } } else if (!this.IsSubscribe && _subscribeViewType == SubscriveViewType.Checked) { if (this.Subscribe != null) { this.Subscribe(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInTopic, Topic.ID.ToString(), SecurityContext.CurrentAccount.ID)); } } } int numb_page = Convert.ToInt32(Math.Ceiling(Topic.PostCount / (_settings.PostCountOnPage * 1.0))); var postURL = _settings.LinkProvider.Post(post.ID, Topic.ID, numb_page); if (_settings.ActivityPublisher != null) { _settings.ActivityPublisher.NewPost(post, Topic.Title, Topic.ThreadID, postURL); } Response.Redirect(postURL); return; } catch (Exception ex) { _errorMessage = "<div class=\"errorBox\">" + ex.Message.HtmlEncode() + "</div>"; return; } #endregion } } if (PostType == NewPostType.Topic || PostType == NewPostType.Poll) { if (PostType == NewPostType.Poll && _pollMaster.AnswerVariants.Count < 2) { _errorMessage = "<div class=\"errorBox\">" + Resources.ForumUCResource.ErrorPollVariantCount + "</div>"; return; } try { var topic = new Topic(_subject, TopicType.Informational); topic.ThreadID = Thread.ID; topic.Tags = CreateTags(Thread); topic.Type = (PostType == NewPostType.Poll ? TopicType.Poll : TopicType.Informational); topic.ID = ForumDataProvider.CreateTopic(TenantProvider.CurrentTenantID, topic.ThreadID, topic.Title, topic.Type); Topic = topic; foreach (var tag in topic.Tags) { if (tag.ID == 0) { ForumDataProvider.CreateTag(TenantProvider.CurrentTenantID, topic.ID, tag.Name, tag.IsApproved); } else { ForumDataProvider.AttachTagToTopic(TenantProvider.CurrentTenantID, tag.ID, topic.ID); } } var post = new Post(topic.Title, _text); post.TopicID = topic.ID; post.ParentPostID = 0; post.Formatter = _formatter; post.IsApproved = _forumManager.ValidateAccessSecurityAction(ForumAction.ApprovePost, Topic); post.ID = ForumDataProvider.CreatePost(TenantProvider.CurrentTenantID, post.TopicID, post.ParentPostID, post.Subject, post.Text, post.IsApproved, post.Formatter); CommonControlsConfigurer.FCKEditingComplete(_settings.FileStoreModuleID, post.ID.ToString(), post.Text, false); if (IsAllowCreateAttachment) { CreateAttachments(post); } if (PostType == NewPostType.Poll) { var answerVariants = new List <string>(); foreach (var answVariant in _pollMaster.AnswerVariants) { answerVariants.Add(answVariant.Name); } topic.QuestionID = ForumDataProvider.CreatePoll(TenantProvider.CurrentTenantID, topic.ID, _pollMaster.Singleton ? QuestionType.OneAnswer : QuestionType.SeveralAnswer, topic.Title, answerVariants); } NotifyAboutNewPost(post); if (_subscribeViewType == SubscriveViewType.Checked) { _forumManager.PresenterFactory.GetPresenter <ISubscriberView>().SetView(this); if (this.Subscribe != null) { this.Subscribe(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInTopic, topic.ID.ToString(), SecurityContext.CurrentAccount.ID)); } } if (_settings.ActivityPublisher != null) { _settings.ActivityPublisher.NewTopic(topic); } Response.Redirect(_settings.LinkProvider.Post(post.ID, topic.ID, 1)); return; } catch (Exception ex) { _errorMessage = "<div class=\"errorBox\">" + ex.Message.HtmlEncode() + "</div>"; return; } } } else { _forumManager.PresenterFactory.GetPresenter <ISubscriberView>().SetView(this); if (PostType == NewPostType.Poll || PostType == NewPostType.Topic) { if (this.GetSubscriptionState != null) { this.GetSubscriptionState(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInThread, Thread.ID.ToString(), SecurityContext.CurrentAccount.ID)); } if (this.IsSubscribe) { _subscribeViewType = SubscriveViewType.Disable; } else { _subscribeViewType = SubscriveViewType.Checked; } } else if (PostType == NewPostType.Post && PostAction != PostAction.Edit) { if (this.GetSubscriptionState != null) { this.GetSubscriptionState(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInThread, Topic.ThreadID.ToString(), SecurityContext.CurrentAccount.ID)); } if (this.IsSubscribe) { _subscribeViewType = SubscriveViewType.Disable; } else { if (SubscriptionConstants.SubscriptionProvider.IsUnsubscribe(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), SecurityContext.CurrentAccount.Name), SubscriptionConstants.NewPostInTopic, Topic.ID.ToString())) { _subscribeViewType = SubscriveViewType.Unchecked; } else { _subscribeViewType = SubscriveViewType.Checked; } } } else { _subscribeViewType = SubscriveViewType.Disable; } } }