//********************************************************************* // // PortalSecurity.HasEditPermissions() Method // // The HasEditPermissions method enables developers to easily check // whether the current browser client has access to edit the settings // of a specified portal module // //********************************************************************* public static bool HasEditPermissions(int moduleId) { // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; // Create Instance of Connection and Command Object NpgsqlConnection myConnection = new NpgsqlConnection(ConfigurationSettings.AppSettings["NpgsqlConnectionString"]); NpgsqlCommand myCommand = new NpgsqlCommand("GetAuthRoles(:PortalID, :ModuleID)", myConnection); // Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC NpgsqlParameter parameterModuleID = new NpgsqlParameter("ModuleID", DbType.Int32); parameterModuleID.Value = moduleId; myCommand.Parameters.Add(parameterModuleID); NpgsqlParameter parameterPortalID = new NpgsqlParameter("PortalID", DbType.Int32); parameterPortalID.Value = portalSettings.PortalId; myCommand.Parameters.Add(parameterPortalID); // Open the database connection and execute the command myConnection.Open(); NpgsqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); bool retVal = false; if (result.Read()) { if ((PortalSecurity.IsInRoles((String)result["accessroles"]) == false) || (PortalSecurity.IsInRoles((String)result["editroles"]) == false)) { retVal = false; } else { retVal = true; } } result.Close(); return(retVal); }
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; } } }