Пример #1
0
        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);
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        public AjaxResponse DoApprovedPost(int idPost, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idPost.ToString()
            };

            var post = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, idPost);

            if (post == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.ApprovePost, post))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            try
            {
                ForumDataProvider.ApprovePost(TenantProvider.CurrentTenantID, post.ID);
                resp.rs1 = "1";
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }
            return(resp);
        }
Пример #4
0
        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());
        }
Пример #5
0
        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());
        }
Пример #6
0
        public AjaxResponse DoDeleteThread(int threadID, int categoryID)
        {
            var resp = new AjaxResponse
            {
                rs2 = threadID.ToString(),
                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
            {
                RemoveDataHelper.RemoveThread(thread);
                resp.rs1 = "1";
            }
            catch (Exception ex)
            {
                resp.rs1 = "0";
                resp.rs4 = ex.Message.HtmlEncode();
            }
            return(resp);
        }
Пример #7
0
        public IEnumerable <ForumTopicWrapper> SearchTopics(string query)
        {
            int count;
            var topics = ForumDataProvider.SearchTopicsByText(TenantId, query, 0, -1, out count);

            return(topics.Select(x => new ForumTopicWrapper(x)).ToSmartList());
        }
Пример #8
0
        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);
        }
Пример #9
0
        public IEnumerable <ForumTopicWrapper> GetLastTopics()
        {
            var result = ForumDataProvider.GetLastUpdateTopics(TenantId, (int)_context.StartIndex, (int)_context.Count);

            _context.SetDataPaginated();
            return(result.Select(x => new ForumTopicWrapper(x)).ToSmartList());
        }
Пример #10
0
        public ForumTopicPostWrapper AddTopicPosts(int topicid, int parentPostId, string subject, string content)
        {
            var id = ForumDataProvider.CreatePost(TenantId, topicid, parentPostId, subject, content, true,
                                                  PostTextFormatter.BBCode);

            return(new ForumTopicPostWrapper(ForumDataProvider.GetPostByID(TenantId, id)));
        }
Пример #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _forumManager = ForumManager.Settings.ForumManager;

            ForumManager.Instance.SetCurrentPage(ForumPage.PostList);

            var idTopic = 0;

            if (!String.IsNullOrEmpty(Request["t"]))
            {
                try
                {
                    idTopic = Convert.ToInt32(Request["t"]);
                }
                catch
                {
                    idTopic = 0;
                }
            }
            if (idTopic == 0)
            {
                Response.Redirect("default.aspx");
            }


            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic);

            if (topic == null)
            {
                Response.Redirect("default.aspx");
            }

            Topic = topic;

            var postListControl = LoadControl(ForumManager.Settings.UserControlsVirtualPath + "/PostListControl.ascx") as PostListControl;

            postListControl.SettingsID = ForumManager.Settings.ID;
            postListControl.Topic      = topic;
            postListHolder.Controls.Add(postListControl);
            Utility.RegisterTypeForAjax(typeof(TopicControl), Page);
            Utility.RegisterTypeForAjax(typeof(Subscriber));
            var subscriber = new Subscriber();

            var isTopicSubscribe   = subscriber.IsTopicSubscribe(topic.ID);
            var SubscribeTopicLink = subscriber.RenderTopicSubscription(!isTopicSubscribe, topic.ID);

            //master.ActionsPlaceHolder.Controls.Add(new HtmlMenuItem(subscriber.RenderThreadSubscription(!isThreadSubscribe, topic.ThreadID)));
            //master.ActionsPlaceHolder.Controls.Add(new HtmlMenuItem(subscriber.RenderTopicSubscription(!isTopicSubscribe, topic.ID)));

            ForumPageParentTitle = topic.ThreadTitle;
            ForumPageParentIn    = CommunityResource.InForParentPage;
            ForumPageParentURL   = "topics.aspx?f=" + topic.ThreadID.ToString();
            ForumPageTitle       = topic.Title;
            Title           = HeaderStringHelper.GetPageTitle((Master as ForumMasterPage).CurrentPageCaption ?? Resources.ForumResource.AddonName);
            SubscribeStatus = isTopicSubscribe ? "subscribed" : "unsubscribed";

            RenderModeratorFunctionsHeader();

            SubscribeLinkBlock.Text = SubscribeTopicLink;
        }
        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 ||
                !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumResource.ErrorAccessDenied;
            }

            try
            {
                List <int> removedPostIDs;
                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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ForumManager.Instance.SetCurrentPage(ForumPage.TopicList);

            int idThread;

            if (!int.TryParse(Request["f"], out idThread))
            {
                Response.Redirect("default.aspx");
            }

            var thread = ForumDataProvider.GetThreadByID(TenantProvider.CurrentTenantID, idThread);

            if (thread == null)
            {
                Response.Redirect("default.aspx");
            }

            if (thread.TopicCount > 0)
            {
                var topicsControl = LoadControl(ForumManager.Settings.UserControlsVirtualPath + "/TopicListControl.ascx") as UserControls.Forum.TopicListControl;
                topicsControl.SettingsID = ForumManager.Settings.ID;
                topicsControl.ThreadID   = thread.ID;
                topicsHolder.Controls.Add(topicsControl);
            }
            else
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("forums_icon.png", ForumManager.Settings.ModuleID),
                    Header     = Resources.ForumResource.EmptyScreenTopicCaption,
                    Describe   = Resources.ForumResource.EmptyScreenTopicText,
                    ButtonHTML = ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.TopicCreate, thread) ? String.Format("<a class='linkAddMediumText' href='newpost.aspx?f=" + thread.ID + "&m=0'>{0}</a>", Resources.ForumResource.EmptyScreenTopicLink) : String.Empty
                };

                topicsHolder.Controls.Add(emptyScreenControl);
            }

            Utility.RegisterTypeForAjax(typeof(Subscriber));
            var subscriber = new Subscriber();

            var isThreadSubscribe = subscriber.IsThreadSubscribe(thread.ID);

            var master = Master as ForumMasterPage;

            master.ActionsPlaceHolder.Controls.Add(new HtmlMenuItem(subscriber.RenderThreadSubscription(!isThreadSubscribe, thread.ID)));

            //bread crumbs
            var breadCrumbs = (Master as ForumMasterPage).BreadCrumbs;

            breadCrumbs.Add(new BreadCrumb {
                Caption = Resources.ForumResource.ForumsBreadCrumbs, NavigationUrl = "default.aspx"
            });
            breadCrumbs.Add(new BreadCrumb {
                Caption = thread.Title
            });

            Title = HeaderStringHelper.GetPageTitle(Resources.ForumResource.AddonName, breadCrumbs);
        }
Пример #15
0
        public ForumTopicWrapperFull AddTopic(int threadid, string subject, string content, TopicType topicType)
        {
            var id = ForumDataProvider.CreateTopic(TenantId, threadid, subject, topicType);

            ForumDataProvider.CreatePost(TenantId, id, 0, subject, content, true,
                                         PostTextFormatter.BBCode);
            return(GetTopicPosts(id));
        }
Пример #16
0
        public override FileUploadHandler.FileUploadResult ProcessUpload(HttpContext context)
        {
            var result = new FileUploadResult()
            {
                Success = false
            };

            try
            {
                if (ProgressFileUploader.HasFilesToUpload(context))
                {
                    var settingsID = new Guid(context.Request["SettingsID"]);
                    var settings   = ForumManager.GetSettings(settingsID);
                    var thread     = ForumDataProvider.GetThreadByID(TenantProvider.CurrentTenantID, Convert.ToInt32(context.Request["ThreadID"]));
                    if (thread == null)
                    {
                        return(result);
                    }

                    var forumManager       = settings.ForumManager;
                    var offsetPhysicalPath = string.Empty;
                    forumManager.GetAttachmentVirtualDirPath(thread, settingsID, new Guid(context.Request["UserID"]), out offsetPhysicalPath);

                    var file = new ProgressFileUploader.FileToUpload(context);

                    var newFileName  = GetFileName(file.FileName);
                    var origFileName = newFileName;

                    var i     = 1;
                    var store = forumManager.GetStore();
                    while (store.IsFile(offsetPhysicalPath + "\\" + newFileName))
                    {
                        var ind = origFileName.LastIndexOf(".");
                        newFileName = ind != -1 ? origFileName.Insert(ind, "_" + i.ToString()) : origFileName + "_" + i.ToString();
                        i++;
                    }

                    result.FileName = newFileName;
                    result.FileURL  = store.Save(offsetPhysicalPath + "\\" + newFileName, file.InputStream).ToString();
                    result.Data     = new
                    {
                        OffsetPhysicalPath = offsetPhysicalPath + "\\" + newFileName,
                        FileName           = newFileName,
                        Size        = file.ContentLength,
                        ContentType = file.FileContentType,
                        SettingsID  = settingsID
                    };
                    result.Success = true;
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }

            return(result);
        }
Пример #17
0
 public StatisticItem GetMainStatistic(Guid userID)
 {
     return(new StatisticItem
     {
         Count = ForumDataProvider.GetUserPostCount(TenantProvider.CurrentTenantID, userID),
         URL = VirtualPathUtility.ToAbsolute(ForumManager.BaseVirtualPath + "/usertopics.aspx") + "?uid=" + userID.ToString(),
         Name = Resources.ForumResource.PostCountStatistic
     });
 }
Пример #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ForumContainer.Options.InfoType = InfoType.Alert;

            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=\"javascript\"  type=\"text/javascript\"> ForumMakerProvider.All='" + Resources.ForumResource.All + "'; ");
            sb.Append(" ForumMakerProvider.ConfirmMessage='" + Resources.ForumResource.ConfirmMessage + "'; ");
            sb.Append(" ForumMakerProvider.SaveButton='" + Resources.ForumResource.SaveButton + "'; ");
            sb.Append(" ForumMakerProvider.CancelButton='" + Resources.ForumResource.CancelButton + "'; ");
            sb.Append(" ForumMakerProvider.NameEmptyString='" + Resources.ForumResource.NameEmptyString + "'; ");
            sb.Append(" ForumContainer_PanelInfoID = '" + ForumContainer.GetInfoPanelClientID() + "'; ");

            sb.Append("</script>");

            this.Page.ClientScript.RegisterClientScriptInclude(typeof(string), "forummaker_script", WebPath.GetPath(ForumManager.BaseVirtualPath.Substring(2) + "/js/forummaker.js"));
            this.Page.ClientScript.RegisterClientScriptBlock(typeof(string), "forummaker_script_init", sb.ToString(), false);

            SearchText = "";

            if (!String.IsNullOrEmpty(Request["search"]))
            {
                SearchText = Request["search"];
            }

            var tags = ForumDataProvider.GetTagCloud(TenantProvider.CurrentTenantID, 40);

            TabCloudContainer.Title          = Resources.ForumResource.TagCloud;
            TabCloudContainer.HeaderCSSClass = "studioSideBoxTagCloudHeader";
            TabCloudContainer.ImageURL       = WebImageSupplier.GetAbsoluteWebPath("tagcloud.png");

            foreach (RankTag tag in tags)
            {
                TagCloudItem item = new TagCloudItem();
                item.TagName = tag.Name;
                item.TagID   = tag.ID.ToString();
                item.Rank    = tag.Rank;
                item.URL     = "search.aspx?tag=" + tag.ID;
                tagCloud.Items.Add(item);
            }
            if (tags.Count == 0)
            {
                TabCloudContainer.Visible = false;
            }

            sideRecentActivity.TenantId  = TenantProvider.CurrentTenantID;
            sideRecentActivity.ProductId = Product.CommunityProduct.ID;
            sideRecentActivity.ModuleId  = Forum.ForumManager.ModuleID;


            string script = "<link href=\"" + WebSkin.GetUserSkin().GetAbsoluteWebPath(ForumManager.BaseVirtualPath.Substring(2) + "/app_themes/<theme_folder>/style.css") + "\" rel=\"stylesheet\" type=\"text/css\" />";

            this.Page.ClientScript.RegisterClientScriptBlock(typeof(string), Guid.NewGuid().ToString(), script);

            SetNavigation();
        }
Пример #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var settings = ForumManager.GetSettings(SettingsID);

            Topics = new List <Topic>();

            if (ThreadID == 0)
            {
                Response.Redirect(settings.StartPageAbsolutePath);
            }

            int currentPageNumber = 0;

            if (!String.IsNullOrEmpty(Request["p"]))
            {
                try
                {
                    currentPageNumber = Convert.ToInt32(Request["p"]);
                }
                catch { currentPageNumber = 0; }
            }
            if (currentPageNumber <= 0)
            {
                currentPageNumber = 1;
            }

            int topicCountInThread = 0;

            Topics = ForumDataProvider.GetTopics(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, ThreadID, currentPageNumber, settings.TopicCountOnPage, out topicCountInThread);

            ForumDataProvider.SetThreadVisit(TenantProvider.CurrentTenantID, ThreadID);

            int i = 0;

            foreach (Topic topic in Topics)
            {
                TopicControl topicControl = (TopicControl)LoadControl(settings.UserControlsVirtualPath + "/TopicControl.ascx");
                topicControl.Topic      = topic;
                topicControl.SettingsID = SettingsID;
                topicControl.IsEven     = (i % 2 == 0);
                this.topicListHolder.Controls.Add(topicControl);
                i++;
            }

            PageNavigator pageNavigator = new PageNavigator()
            {
                PageUrl           = settings.LinkProvider.TopicList(ThreadID),
                CurrentPageNumber = currentPageNumber,
                EntryCountOnPage  = settings.TopicCountOnPage,
                VisiblePageCount  = 5,
                EntryCount        = topicCountInThread
            };

            bottomPageNavigatorHolder.Controls.Add(pageNavigator);
        }
Пример #20
0
        public ForumThreadWrapperFull GetThreadTopics(int threadid)
        {
            var topicsIds = ForumDataProvider.GetTopicIDs(TenantId, threadid).Skip((int)_context.StartIndex);

            if (_context.Count > 0)
            {
                topicsIds = topicsIds.Take((int)_context.Count);
            }
            _context.SetDataPaginated();
            return(new ForumThreadWrapperFull(ForumDataProvider.GetThreadByID(TenantId, threadid).NotFoundIfNull(), ForumDataProvider.GetTopicsByIDs(TenantId, topicsIds.ToList(), true)));
        }
Пример #21
0
        public AjaxResponse DoDeletePost(int idPost, Guid settingsID)
        {
            _forumManager = Community.Forum.ForumManager.Settings.ForumManager;
            var resp = new AjaxResponse {
                rs2 = idPost.ToString()
            };

            var post = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, idPost);

            if (post == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.PostDelete, post))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            try
            {
                var result = ForumDataProvider.RemovePost(TenantProvider.CurrentTenantID, post.ID);
                if (result == DeletePostResult.Successfully)
                {
                    resp.rs1 = "1";
                    resp.rs3 = Resources.ForumUCResource.SuccessfullyDeletePostMessage;
                    _forumManager.RemoveAttachments(post);

                    CommonControlsConfigurer.FCKUploadsRemoveForItem(_forumManager.Settings.FileStoreModuleID, idPost.ToString());
                }
                else if (result == DeletePostResult.ReferencesBlock)
                {
                    resp.rs1 = "0";
                    resp.rs3 = Resources.ForumUCResource.ExistsReferencesChildPosts;
                }
                else
                {
                    resp.rs1 = "0";
                    resp.rs3 = Resources.ForumUCResource.ErrorDeletePost;
                }
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }

            return(resp);
        }
        public CheckEmptyContentResult IsEmpty()
        {
            ForumLastUpdatesWidgetSettings widgetSettings = SettingsManager.Instance.LoadSettingsFor <ForumLastUpdatesWidgetSettings>(SecurityContext.CurrentAccount.ID);
            var topicList = ForumDataProvider.GetLastUpdateTopics(TenantProvider.CurrentTenantID, widgetSettings.MaxTopicCount);

            if (topicList.Count > 0)
            {
                return(CheckEmptyContentResult.NotEmpty);
            }

            return(CheckEmptyContentResult.Empty);
        }
Пример #23
0
        public AjaxResponse DoDeleteTopic(int idTopic, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idTopic.ToString()
            };

            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic);

            if (topic == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.TopicDelete, topic))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            var topicName  = HttpUtility.HtmlEncode(topic.Title);
            var threadID   = topic.ThreadID;
            var threadName = topic.ThreadTitle;

            try
            {
                List <int> removedPostIDs;
                var        attachmantOffsetPhysicalPaths = ForumDataProvider.RemoveTopic(TenantProvider.CurrentTenantID, topic.ID, out removedPostIDs);

                resp.rs1 = "1";
                resp.rs3 = Resources.ForumUCResource.SuccessfullyDeleteTopicMessage;
                _forumManager.RemoveAttachments(attachmantOffsetPhysicalPaths.ToArray());

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

                var settings = ForumManager.GetSettings(settingsID);
                if (settings != null && settings.ActivityPublisher != null)
                {
                    settings.ActivityPublisher.DeleteTopic(threadID, topicName, threadName);
                }
            }
            catch (Exception ex)
            {
                resp.rs1 = "0";
                resp.rs3 = ex.Message.HtmlEncode();
            }

            return(resp);
        }
        public override SearchResultItem[] Search(string text)
        {
            int topicCount;
            var findTopicList = ForumDataProvider.SearchTopicsByText(TenantProvider.CurrentTenantID, text, 1, -1, out topicCount);

            return(findTopicList.Select(topic => new SearchResultItem
            {
                Name = topic.Title,
                Description = String.Format(Resources.ForumResource.FindTopicDescription, topic.ThreadTitle),
                URL = VirtualPathUtility.ToAbsolute(ForumManager.BaseVirtualPath + "/posts.aspx") + "?t=" + topic.ID,
                Date = topic.CreateDate
            }).ToArray());
        }
Пример #25
0
        public ForumThreadWrapper DeleteThread(int threadid)
        {
            var thread = ForumDataProvider.GetThreadByID(TenantProvider.CurrentTenantID, threadid);

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

            RemoveDataHelper.RemoveThread(thread);

            return(new ForumThreadWrapper(thread));
        }
Пример #26
0
        public ForumTopicWrapper DeleteTopic(int topicid)
        {
            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, topicid);

            if (topic == null || !ForumManager.Settings.ForumManager.ValidateAccessSecurityAction(ForumAction.TopicDelete, topic))
            {
                throw new SecurityException(ForumResource.ErrorAccessDenied);
            }

            RemoveDataHelper.RemoveTopic(topic);

            return(new ForumTopicWrapper(topic));
        }
Пример #27
0
        public ForumTopicWrapperFull GetTopicPosts(int topicid)
        {
            //TODO: Deal with polls
            var postIds = ForumDataProvider.GetPostIDs(TenantId, topicid).Skip((int)_context.StartIndex);

            if (_context.Count > 0)
            {
                postIds = postIds.Take((int)_context.Count);
            }
            _context.SetDataPaginated();
            return(new ForumTopicWrapperFull(ForumDataProvider.GetTopicByID(TenantId, topicid).NotFoundIfNull(),
                                             ForumDataProvider.GetPostsByIDs(TenantId, postIds.ToList())));
        }
Пример #28
0
        protected string ControlButtons()
        {
            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, Post.TopicID);

            if (topic.Closed)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            if (_forumManager.ValidateAccessSecurityAction(ForumAction.PostCreate, new Topic {
                ID = Post.TopicID
            }))
            {
                sb.Append("<a class=\"link gray\" style=\"float:left;\" href=\"" + _settings.LinkProvider.NewPost(Post.TopicID, PostAction.Quote, Post.ID) + "\">" + Resources.ForumUCResource.Quote + "</a>");
                sb.Append("<a class=\"link gray\" style=\"float:left;  margin-left:8px;\" href=\"" + _settings.LinkProvider.NewPost(Post.TopicID, PostAction.Reply, Post.ID) + "\">" + Resources.ForumUCResource.Reply + "</a>");
                sb.Append("<a class=\"link gray\" style=\"float:left; margin-left:8px;\" href=\"" + _settings.LinkProvider.NewPost(Post.TopicID) + "\">" + Resources.ForumUCResource.NewPostButton + "</a>");
            }

            var isFirst = true;

            if (_forumManager.ValidateAccessSecurityAction(ForumAction.PostDelete, Post) && ShowDeletePostLink())
            {
                sb.AppendFormat("<a class=\"link\" style=\"float:right;\" id='PostDeleteLink{0}' href=\"javascript:ForumManager.DeletePost('" + Post.ID + "')\">" + Resources.ForumUCResource.DeleteButton + "</a>", Post.ID);
                isFirst = false;
            }

            if (_forumManager.ValidateAccessSecurityAction(ForumAction.PostEdit, Post))
            {
                if (!isFirst && ShowDeletePostLink())
                {
                    sb.AppendFormat("<span class='splitter' id='PostDeleteSplitter{0}' style='float:right;'>|</span>", Post.ID);
                }

                sb.Append("<a class=\"link\" style=\"float:right;\" href=\"" + _settings.LinkProvider.NewPost(Post.TopicID, PostAction.Edit, Post.ID) + "\">" + Resources.ForumUCResource.EditButton + "</a>");
                isFirst = false;
            }

            if (!Post.IsApproved && _forumManager.ValidateAccessSecurityAction(ForumAction.ApprovePost, Post))
            {
                if (!isFirst)
                {
                    sb.Append("<span class='splitter' style='float:right;'>|</span>");
                }

                sb.Append("<a id=\"forum_btap_" + Post.ID + "\" class=\"link\" style=\"margin-left:5px; float:right;\" href=\"javascript:ForumManager.ApprovePost('" + Post.ID + "')\">" + Resources.ForumUCResource.ApproveButton + "</a>");
            }

            return(sb.ToString());
        }
Пример #29
0
        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;
                }
            }
        }
Пример #30
0
        public AjaxResponse DoStickyTopic(int idTopic, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse();

            resp.rs2 = idTopic.ToString();

            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic);

            if (topic == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.TopicSticky, topic))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            topic.Sticky = !topic.Sticky;
            try
            {
                ForumDataProvider.UpdateTopic(TenantProvider.CurrentTenantID, topic.ID, topic.Title, topic.Sticky, topic.Closed);

                resp.rs1 = "1";
                if (topic.Sticky)
                {
                    resp.rs3 = Resources.ForumUCResource.SuccessfullyStickyTopicMessage;
                }
                else
                {
                    resp.rs3 = Resources.ForumUCResource.SuccessfullyClearStickyTopicMessage;
                }

                var settings = ForumManager.GetSettings(settingsID);
                if (settings != null && settings.ActivityPublisher != null)
                {
                    settings.ActivityPublisher.TopicSticky(topic);
                }
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }
            return(resp);
        }