private void Page_Init(object sender, EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); //********************************************************************* // // Page_Init Event Handler // // The Page_Init event handler executes at the very beginning of each page // request (immediately before Page_Load). // // The Page_Init event handler below determines the tab index of the currently // requested portal view, and then calls the PopulatePortalSection utility // method to dynamically populate the left, center and right hand sections // of the portal tab. // //********************************************************************* // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; // Ensure that the visiting user has access to the current page if (PortalSecurity.IsInRoles(portalSettings.ActiveTab.AuthorizedRoles) == false) { Response.Redirect("~/Admin/AccessDenied.aspx"); } // Dynamically inject a signin login module into the top left-hand corner // of the home page if the client is not yet authenticated if ((Request.IsAuthenticated == false) && (portalSettings.ActiveTab.TabIndex == 0)) { LeftPane.Controls.Add(Page.LoadControl("~/DesktopModules/SignIn.ascx")); LeftPane.Visible = true; } // Dynamically Populate the Left, Center and Right pane sections of the portal page if (portalSettings.ActiveTab.Modules.Count > 0) { // Loop through each entry in the configuration system for this tab foreach (ModuleSettings _moduleSettings in portalSettings.ActiveTab.Modules) { Control parent = Page.FindControl(_moduleSettings.PaneName); // If no caching is specified, create the user control instance and dynamically // inject it into the page. Otherwise, create a cached module instance that // may or may not optionally inject the module into the tree if ((_moduleSettings.CacheTime) == 0) { PortalModuleControl portalModule = (PortalModuleControl)Page.LoadControl(_moduleSettings.DesktopSrc); portalModule.PortalId = portalSettings.PortalId; portalModule.ModuleConfiguration = _moduleSettings; parent.Controls.Add(portalModule); } else { CachedPortalModuleControl portalModule = new CachedPortalModuleControl(); portalModule.PortalId = portalSettings.PortalId; portalModule.ModuleConfiguration = _moduleSettings; parent.Controls.Add(portalModule); } // Dynamically inject separator break between portal modules parent.Controls.Add(new LiteralControl("<" + "br" + ">")); parent.Visible = true; } } }
//******************************************************* // // The ApplyChanges_Click server event handler on this page is used // to save the module settings into the portal configuration system // //******************************************************* private void ApplyChanges_Click(Object Sender, EventArgs e) { // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; object value = GetModule(); if (value != null) { ModuleSettings m = (ModuleSettings)value; // Construct Authorized User Roles String String editRoles = ""; foreach (ListItem item in authEditRoles.Items) { if (item.Selected == true) { editRoles = editRoles + item.Text + ";"; } } // update module AdminDB admin = new AdminDB(); admin.UpdateModule(moduleId, m.ModuleOrder, m.PaneName, moduleTitle.Text, Int32.Parse(cacheTime.Text), editRoles, showMobile.Checked); // Update Textbox Settings moduleTitle.Text = m.ModuleTitle; cacheTime.Text = m.CacheTime.ToString(); // Populate checkbox list with all security roles for this portal // and "check" the ones already configured for this module IDataReader roles = admin.GetPortalRoles(portalSettings.PortalId); // Clear existing items in checkboxlist authEditRoles.Items.Clear(); ListItem allItem = new ListItem(); allItem.Text = "All Users"; if (m.AuthorizedEditRoles.LastIndexOf("All Users") > -1) { allItem.Selected = true; } authEditRoles.Items.Add(allItem); while (roles.Read()) { ListItem item = new ListItem(); item.Text = (String)roles["rolename"]; item.Value = roles["roleid"].ToString(); if ((m.AuthorizedEditRoles.LastIndexOf(item.Text)) > -1) { item.Selected = true; } authEditRoles.Items.Add(item); } } // Navigate back to admin page Response.Redirect("TabLayout.aspx?tabid=" + tabId); }