public AjaxResponse DoCreateThread(int categoryId, string name, string description) { AjaxResponse resp = new AjaxResponse(); resp.rs2 = categoryId.ToString(); var threads = new List <Thread>(); var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, categoryId, out threads); if (category == null || !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { resp.rs1 = "0"; resp.rs3 = "<div>" + Resources.ForumResource.ErrorAccessDenied + "</div>"; return(resp); } if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(name.Trim())) { resp.rs1 = "0"; resp.rs3 = "<div>" + Resources.ForumResource.ErrorEmptyName + "</div>"; return(resp); } var thread = new Thread() { Title = name.Trim(), Description = description ?? "", SortOrder = 100, CategoryID = category.ID }; try { thread.ID = ForumDataProvider.CreateThread(TenantProvider.CurrentTenantID, thread.CategoryID, thread.Title, thread.Description, thread.SortOrder); threads.Add(thread); resp.rs1 = "1"; resp.rs3 = RenderForumCategory(category, threads); ForumActivityPublisher.NewThread(thread); } catch { resp.rs1 = "0"; resp.rs3 = "<div>" + Resources.ForumResource.ErrorEditThreadCategory + "</div>"; } return(resp); }
public AjaxResponse DoDeleteThread(int threadID, int categoryID) { AjaxResponse resp = new AjaxResponse(); resp.rs2 = threadID.ToString(); resp.rs3 = categoryID.ToString(); var thread = ForumDataProvider.GetThreadByID(TenantProvider.CurrentTenantID, threadID); if (thread == null || !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { resp.rs1 = "0"; resp.rs4 = Resources.ForumResource.ErrorAccessDenied; return(resp); } try { var removedPostIDs = new List <int>(); ForumDataProvider.RemoveThread(TenantProvider.CurrentTenantID, thread.ID, out removedPostIDs); ForumActivityPublisher.DeleteThread(thread); ForumManager.Instance.RemoveAttachments(thread); removedPostIDs.ForEach(idPost => CommonControlsConfigurer.FCKUploadsRemoveForItem(ForumManager.Settings.FileStoreModuleID, idPost.ToString())); resp.rs1 = "1"; } catch (Exception ex) { resp.rs1 = "0"; resp.rs4 = ex.Message.HtmlEncode(); } return(resp); }
public AjaxResponse SaveThreadCategory(int categoryID, string categoryName, string threadName, string threadDescription, bool isRenderCategory) { AjaxResponse resp = new AjaxResponse(); if (!ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorAccessDenied + "</div>"; return(resp); } if (String.IsNullOrEmpty(threadName) || String.IsNullOrEmpty(threadName.Trim())) { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorThreadEmptyName + "</div>"; return(resp); } try { var thread = new Thread() { Title = threadName.Trim(), Description = threadDescription ?? "", SortOrder = 100, CategoryID = categoryID }; if (thread.CategoryID == -1) { if (String.IsNullOrEmpty(categoryName) || String.IsNullOrEmpty(categoryName.Trim())) { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorCategoryEmptyName + "</div>"; return(resp); } thread.CategoryID = ForumDataProvider.CreateThreadCategory(TenantProvider.CurrentTenantID, categoryName.Trim(), "", 100); } thread.ID = ForumDataProvider.CreateThread(TenantProvider.CurrentTenantID, thread.CategoryID, thread.Title, thread.Description, thread.SortOrder); resp.rs1 = "1"; resp.rs2 = thread.CategoryID.ToString(); if (isRenderCategory) { var threads = new List <Thread>(); var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, thread.CategoryID, out threads); resp.rs3 = ForumEditor.RenderForumCategory(category, threads); } resp.rs4 = (categoryID == -1) ? "0" : "1"; ForumActivityPublisher.NewThread(thread); } catch (Exception ex) { resp.rs1 = "0"; resp.rs2 = "<div>" + ex.Message.HtmlEncode() + "</div>"; } return(resp); }