Пример #1
0
        public AjaxResponse DoDeleteThreadCategory(int id)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs2 = id.ToString();

            var threads  = new List <Thread>();
            var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, id, out threads);

            if (category == null ||
                !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumResource.ErrorAccessDenied;
            }

            try
            {
                var removedPostIDs = new List <int>();
                ForumDataProvider.RemoveThreadCategory(TenantProvider.CurrentTenantID, category.ID, out removedPostIDs);

                ForumManager.Instance.RemoveAttachments(category);

                removedPostIDs.ForEach(idPost => CommonControlsConfigurer.FCKUploadsRemoveForItem(ForumManager.Settings.FileStoreModuleID, idPost.ToString()));

                resp.rs1 = "1";
            }
            catch (Exception ex)
            {
                resp.rs1 = "0";
                resp.rs3 = ex.Message.HtmlEncode();
            }
            return(resp);
        }
        public AjaxResponse DoDeleteThreadCategory(int id)
        {
            var resp = new AjaxResponse
            {
                rs2 = id.ToString()
            };

            List <Thread> threads;
            var           category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, id, out threads);

            if (category == null)
            {
                resp.rs1 = "1";
                return(resp);
            }
            if (!ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumResource.ErrorAccessDenied;
                return(resp);
            }

            try
            {
                RemoveDataHelper.RemoveThreadCategory(category);
                resp.rs1 = "1";
            }
            catch (Exception ex)
            {
                resp.rs1 = "0";
                resp.rs3 = ex.Message.HtmlEncode();
            }
            return(resp);
        }
Пример #3
0
        public ForumCategoryWrapper DeleteThreadCategory(int categoryid)
        {
            List <Thread> threads;

            var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, categoryid, out threads);

            if (category == null || !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null))
            {
                throw new SecurityException(ForumResource.ErrorAccessDenied);
            }

            RemoveDataHelper.RemoveThreadCategory(category);

            return(new ForumCategoryWrapper(category, threads));
        }
Пример #4
0
        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 SaveThread(int id, int categoryID, string name, string description)
        {
            var resp = new AjaxResponse
            {
                rs2 = categoryID.ToString()
            };

            if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(name.Trim()))
            {
                resp.rs1 = "0";
                resp.rs3 = "<div>" + Resources.ForumResource.ErrorEmptyName + "</div>";
                return(resp);
            }

            try
            {
                var thread = ForumDataProvider.GetThreadByID(TenantProvider.CurrentTenantID, id);

                if (thread == null || !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null))
                {
                    resp.rs1 = "0";
                    resp.rs3 = "<div>" + Resources.ForumResource.ErrorAccessDenied + "</div>";
                    return(resp);
                }

                thread.Title       = name.Trim();
                thread.Description = description ?? "";
                thread.CategoryID  = categoryID;

                ForumDataProvider.UpdateThread(TenantProvider.CurrentTenantID, thread.ID, thread.CategoryID,
                                               thread.Title, thread.Description, thread.SortOrder);

                List <Thread> threads;
                var           category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, thread.CategoryID, out threads);

                resp.rs1 = "1";
                resp.rs3 = RenderForumCategory(category, threads);
            }
            catch
            {
                resp.rs1 = "0";
                resp.rs3 = "<div>" + Resources.ForumResource.ErrorAccessDenied + "</div>";
            }
            return(resp);
        }
Пример #6
0
        public AjaxResponse SaveCategory(int id, string name, string description)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs2 = id.ToString();

            var threads  = new List <Thread>();
            var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, id, 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);
            }


            category.Title       = name.Trim();
            category.Description = description ?? "";

            try
            {
                ForumDataProvider.UpdateThreadCategory(TenantProvider.CurrentTenantID, category.ID, category.Title, category.Description, category.SortOrder);
                resp.rs1 = "1";
                resp.rs3 = RenderForumCategory(category, threads);
            }
            catch
            {
                resp.rs1 = "0";
                resp.rs3 = "<div>" + Resources.ForumResource.ErrorEditThreadCategory + "</div>";
            }
            return(resp);
        }
Пример #7
0
        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);
        }