/// <summary> /// Reloads the data of the forum control. /// </summary> public override void ReloadData() { base.ReloadData(); this.UniPager1.Enabled = this.EnableThreadPaging; this.UniPager1.PageSize = this.ThreadPageSize; // Hide selected area if forum is AdHoc if (this.IsAdHocForum) { plcHeader.Visible = false; if (ForumContext.CurrentForum.ForumID == 0) { plcContent.Visible = false; } } // Get thread and subscribe link url bool newThread = base.IsAvailable(null, ForumActionType.NewThread); bool newSubscription = base.IsAvailable(null, ForumActionType.SubscribeToForum); bool newFavorites = base.IsAvailable(null, ForumActionType.AddForumToFavorites); bool newBreadCrumbs = (ForumBreadcrumbs1.GenerateBreadcrumbs() != ""); // Hide separators according to the link visibility // Each separator is hidden if the item preceeding the separator is invisible or // no item is behind the separator. if (!newThread || (!newSubscription && !newFavorites && !newBreadCrumbs)) { plcActionSeparator.Visible = false; } if (!newSubscription || (!newFavorites && !newBreadCrumbs)) { plcAddToFavoritesSeparator.Visible = false; } if (!newFavorites || !newBreadCrumbs) { plcBreadcrumbsSeparator.Visible = false; } if ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID > 0)) { string orderBy = "PostStickOrder Desc, PostThreadLastPostTime DESC"; if (ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID)) { orderBy = "PostStickOrder Desc, PostThreadLastPostTimeAbsolute DESC"; } // Retrieve data just for the current page int currentOffset = EnablePostsPaging ? ThreadPageSize * (UniPager1.CurrentPage - 1) : 0; int maxRecords = EnablePostsPaging ? ThreadPageSize : 0; int totalRecords = 0; listForums.DataSource = ForumPostInfoProvider.SelectForumPosts(this.ForumID, "/%", null, orderBy, 0, !ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID), -1, null, currentOffset, maxRecords, ref totalRecords); // Set the total number of records to the pager UniPager1.PagedControl.PagerForceNumberOfResults = totalRecords; listForums.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { CopyValues(postTreeElem); // Hide selected area if forum is AdHoc if (IsAdHocForum) { plcHeader.Visible = false; } // Handle the Move topic mode if (ForumContext.CurrentMode != ForumMode.TopicMove) { plcMoveThread.Visible = false; } else { plcMoveThread.Visible = true; threadMove.TopicMoved += new EventHandler(TopicMoved); } if ((hdnSelected.Value == String.Empty) && (QueryHelper.Contains("moveto"))) { hdnSelected.Value = QueryHelper.GetString("moveto", ""); mSelectedPost = ValidationHelper.GetInteger(hdnSelected.Value, 0); } bool newThread = base.IsAvailable(null, ForumActionType.NewThread); bool newSubscription = base.IsAvailable(null, ForumActionType.SubscribeToForum); bool newFavorites = base.IsAvailable(null, ForumActionType.AddForumToFavorites); bool newBreadCrumbs = (ForumBreadcrumbs1.GenerateBreadcrumbs() != ""); // Hide separators according to the link visibility // Each separator is hidden if the item preceeding the separator is invisible or // no item is behind the separator. if (!newThread || (!newSubscription && !newFavorites && !newBreadCrumbs)) { plcActionSeparator.Visible = false; } if (!newSubscription || (!newFavorites && !newBreadCrumbs)) { plcAddToFavoritesSeparator.Visible = false; } if (!newFavorites || !newBreadCrumbs) { plcBreadcrumbsSeparator.Visible = false; } // postTreeElem.ForumID = ForumContext.CurrentForum.ForumID; //postTreeElem.ShowMode = ShowModeEnum.TreeMode; // Unapproved posts are shown only if onsite mangement is enabled and user is moderator ForumInfo fi = ForumContext.CurrentForum; postTreeElem.SelectOnlyApproved = !((fi != null) && EnableOnSiteManagement && fi.ForumModerated && ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, CommunityGroupID)); if (postTreeElem.ShowMode == ShowModeEnum.DynamicDetailMode) { // Set javascript for selected mode ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumTreeDynamic", ScriptHelper.GetScript("function SelectForumNode(nodeElem, selElem) { if (document.getElementById(nodeElem) != null) { document.getElementById(nodeElem).style.display = 'block';} " + "if (document.getElementById(selElem) != null) {document.getElementById(selElem).style.display = 'none';} return false;}\n ")); } else { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumTreeNormal", ScriptHelper.GetScript("function SelectForumNode(nodeElem) { return false; }\n ")); } // Show post javascript string showScript = "function ShowPost(id){ document.getElementById('" + hdnSelected.ClientID + "').value = id; " + ControlsHelper.GetPostBackEventReference(this, "") + " }"; //Register show post javascript code ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowForumPost", ScriptHelper.GetScript(showScript)); // Don't use redirection after action UseRedirectAfterAction = false; int selected = ValidationHelper.GetInteger(hdnSelected.Value, ValidationHelper.GetInteger(Request[hdnSelected.UniqueID], 0)); if (selected > 0) { ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(selected); if (fpi != null) { ucAbuse.ReportObjectID = fpi.PostId; ucAbuse.ReportTitle = ResHelper.GetString("Forums_WebInterface_ForumPost.AbuseReport", CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName)) + fpi.PostText; ucAbuse.CMSPanel.CommunityGroupID = CommunityGroupID; ucAbuse.CMSPanel.SecurityAccess = AbuseReportAccess; ucAbuse.CMSPanel.Roles = AbuseReportRoles; } } }