private void Page_Load(object sender, System.EventArgs e) { // If the user doesn't have any access rights to management stuff, the user should // be redirected to the default of the global system. if (!SessionAdapter.HasSystemActionRights()) { // doesn't have system rights. redirect. Response.Redirect("../Default.aspx", true); } // Check if the user has the right systemright if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement)) { // no, redirect to admin default page, since the user HAS access to the admin menu. Response.Redirect("Default.aspx", true); } if (!Page.IsPostBack) { // Read all the current existing forums and their section names. ForumsWithSectionNameTypedList forumsWithSectionNames = ForumGuiHelper.GetAllForumsWithSectionNames(); rpForums.DataSource = forumsWithSectionNames; rpForums.DataBind(); } }
/// <summary> /// Gets all forum data with section name in a typedlist. Sorted on Section.OrderNo, Section.SectionName, Forum.OrderNo, Forum.ForumName. /// </summary> /// <returns>Filled typedlist with all forum names / forumIDs and their containing section's name, sorted on Sectionname, and then forumname</returns> public static ForumsWithSectionNameTypedList GetAllForumsWithSectionNames() { ForumsWithSectionNameTypedList toReturn = new ForumsWithSectionNameTypedList(); SortExpression sorter = new SortExpression(SectionFields.OrderNo.Ascending()); sorter.Add(SectionFields.SectionName.Ascending()); sorter.Add(ForumFields.OrderNo.Ascending()); sorter.Add(ForumFields.ForumName.Ascending()); toReturn.Fill(0, sorter); return(toReturn); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, System.EventArgs e) { // this is necessary so the 'clever' IE will also understand what to do: the enter key will then submit the form. this.ClientScript.RegisterHiddenField("__EVENTTARGET", "btnSearch"); if (!Page.IsPostBack) { // clear tmp results in session SessionAdapter.AddSearchTermsAndResults(string.Empty, null); // Read all the current existing forums and their section names. ForumsWithSectionNameTypedList forumsWithSectionName = ForumGuiHelper.GetAllForumsWithSectionNames(); // Get a list of Forum IDs to which the user has access right. List <int> accessableForums = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum); foreach (ForumsWithSectionNameRow currentRow in forumsWithSectionName) { // filter out forums the user doesn't have access rights for. if (accessableForums.Contains(currentRow.ForumID)) { // forum is accessable to the user ListItem newItem = new ListItem(String.Format("{0} - {1}", currentRow.SectionName, currentRow.ForumName), currentRow.ForumID.ToString()); newItem.Selected = true; lbxForums.Items.Add(newItem); } } // make listbox as high as # of forums, with a maximum of 15 and a minimum of 8 if (lbxForums.Items.Count <= 15) { if (lbxForums.Items.Count > 8) { lbxForums.Rows = lbxForums.Items.Count; } else { lbxForums.Rows = 8; } } else { lbxForums.Rows = 15; } lblNumberOfPosts.Text = MessageGuiHelper.GetTotalNumberOfMessages().ToString(); } }
/// <summary> /// Gets all forum data with section name in a typedlist. Sorted on Section.OrderNo, Section.SectionName, Forum.OrderNo, Forum.ForumName. /// </summary> /// <returns>Filled typedlist with all forum names / forumIDs and their containing section's name, sorted on Sectionname, and then forumname</returns> public static ForumsWithSectionNameTypedList GetAllForumsWithSectionNames() { ForumsWithSectionNameTypedList toReturn = new ForumsWithSectionNameTypedList(); SortExpression sorter = new SortExpression(SectionFields.OrderNo.Ascending()); sorter.Add(SectionFields.SectionName.Ascending()); sorter.Add(ForumFields.OrderNo.Ascending()); sorter.Add(ForumFields.ForumName.Ascending()); toReturn.Fill(0, sorter); return toReturn; }