/// <summary> /// Read Current Page sub-tabs /// </summary> /// <param name="pageId"> /// The page ID. /// </param> /// <returns> /// A Pages Box /// </returns> public static Collection <PageStripDetails> GetPageSettingsPagesBox(int pageId) { // Create Instance of Connection and Command Object using (var connection = Config.SqlConnectionString) using (var command = new SqlCommand("rb_GetTabSettings", connection)) { // Mark the Command as a SPROC command.CommandType = CommandType.StoredProcedure; // PageID passed type FIXED by Bill Anderson (reedtek) // see: http://sourceforge.net/tracker/index.php?func=detail&aid=813789&group_id=66837&atid=515929 // Add Parameters to SPROC var parameterPageId = new SqlParameter("@PageID", SqlDbType.Int) { Value = pageId }; command.Parameters.Add(parameterPageId); // The new parameter "PortalLanguage" has been added to sp rb_GetPageSettings // Onur Esnaf var parameterPortalLanguage = new SqlParameter("@PortalLanguage", SqlDbType.NVarChar, 12) { Value = Thread.CurrentThread.CurrentUICulture.Name }; command.Parameters.Add(parameterPortalLanguage); // Open the database connection and execute the command connection.Open(); using (var result = command.ExecuteReader(CommandBehavior.CloseConnection)) { var tabs = new Collection <PageStripDetails>(); try { while (result.Read()) { var tabDetails = new PageStripDetails { PageID = (int)result["PageID"] }; var cts = new PageSettings().GetPageCustomSettings(tabDetails.PageID); tabDetails.PageImage = cts["CustomMenuImage"].ToString(); tabDetails.ParentPageID = Int32.Parse("0" + result["ParentPageID"]); tabDetails.PageName = (string)result["PageName"]; tabDetails.PageOrder = (int)result["PageOrder"]; tabDetails.AuthorizedRoles = (string)result["AuthorizedRoles"]; tabs.Add(tabDetails); } } finally { // by Manu, fixed bug 807858 result.Close(); } return(tabs); } } }
/// <summary> /// Add a Menu Tree Node if user in in the list of Authorized roles. /// Thanks to abain for fixing authorization bug. /// </summary> /// <param name="tabIndex"> /// Index of the tab /// </param> /// <param name="mytab"> /// Tab to add to the MenuTreeNodes collection /// </param> protected override void AddMenuTreeNode(int tabIndex, PageStripDetails mytab) { if (!PortalSecurity.IsInRoles(mytab.AuthorizedRoles)) { return; } // get index and id from this page and transmit them // Obtain PortalSettings from Current Context var PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; var tabIdItemsRoot = PortalSettings.ActivePage.PageID; var mn = new MenuTreeNode(mytab.PageName) { // change the link to stay on the same page and call a category product Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIdItemsRoot, "ItemID=" + mytab.PageID), Width = this.Width }; // fixed by manu mn = this.RecourseMenu(tabIdItemsRoot, mytab.Pages, mn); this.Childs.Add(mn); }
/// <summary> /// Gets the pages in page. /// </summary> /// <param name="portalId"> /// The portal ID. /// </param> /// <param name="pageId"> /// The page ID. /// </param> /// <returns> /// A System.Collections.ArrayList value... /// </returns> public List<PageStripDetails> GetPagesinPage(int portalId, int pageId) { var desktopPages = new List<PageStripDetails>(); // Create Instance of Connection and Command Object using (var connection = Config.SqlConnectionString) using (var sqlCommand = new SqlCommand("rb_GetTabsinTab", connection)) { // Mark the Command as a SPROC sqlCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC var parameterPortalId = new SqlParameter(StrPortalId, SqlDbType.Int, 4) { Value = portalId }; sqlCommand.Parameters.Add(parameterPortalId); var parameterPageId = new SqlParameter(StrPageId, SqlDbType.Int, 4) { Value = pageId }; sqlCommand.Parameters.Add(parameterPageId); // Execute the command connection.Open(); var result = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection); // Read the result set try { while (result.Read()) { var tabDetails = new PageStripDetails { PageID = (int)result["PageID"], ParentPageID = Int32.Parse("0" + result["ParentPageID"]), PageName = (string)result["PageName"], PageOrder = (int)result["PageOrder"], AuthorizedRoles = (string)result["AuthorizedRoles"] }; // Update the AuthorizedRoles Variable desktopPages.Add(tabDetails); } } finally { result.Close(); // by Manu, fixed bug 807858 } } return desktopPages; }
/// <summary> /// Recurses the portal pages XML. /// </summary> /// <param name="page"> /// My page details. /// </param> /// <param name="writer"> /// The writer. /// </param> /// <remarks> /// </remarks> private void RecursePortalPagesXml(PageStripDetails page, XmlWriter writer) { var children = page.Pages; var groupElementWritten = false; foreach (var mysubPage in children.Where(mysubPage => mysubPage.ParentPageID == page.PageID)) { // if ( mySubPage.ParentPageID == page.PageID && PortalSecurity.IsInRoles(page.AuthorizedRoles) ) if (!groupElementWritten) { writer.WriteStartElement("MenuGroup"); // start MenuGroup element groupElementWritten = true; } writer.WriteStartElement("MenuItem"); // start MenuItem element writer.WriteAttributeString("ParentPageId", mysubPage.ParentPageID.ToString()); // writer.WriteAttributeString("Label",mySubPage.PageName); writer.WriteAttributeString( "UrlPageName", HttpUrlBuilder.UrlPageName(mysubPage.PageID) == HttpUrlBuilder.DefaultPage ? mysubPage.PageName : HttpUrlBuilder.UrlPageName(mysubPage.PageID).Replace(".aspx", string.Empty)); writer.WriteAttributeString("PageName", mysubPage.PageName); writer.WriteAttributeString("PageOrder", mysubPage.PageOrder.ToString()); writer.WriteAttributeString("PageIndex", mysubPage.PageIndex.ToString()); writer.WriteAttributeString("PageLayout", mysubPage.PageLayout); writer.WriteAttributeString("AuthRoles", mysubPage.AuthorizedRoles); writer.WriteAttributeString("ID", mysubPage.PageID.ToString()); // writer.WriteAttributeString("URL",HttpUrlBuilder.BuildUrl(string.Concat("~/",mySubPage.PageName,".aspx"), mySubPage.PageID,0,null,string.Empty,this.PortalAlias,"hello/goodbye")); this.RecursePortalPagesXml(mysubPage, writer); writer.WriteEndElement(); // end MenuItem element } if (groupElementWritten) { writer.WriteEndElement(); // end MenuGroup element } }
/// <summary> /// Initializes a new instance of the <see cref="PortalSettings"/> class. /// The PortalSettings Constructor encapsulates all of the logic /// necessary to obtain configuration settings necessary to render /// a Portal Page view for a given request.<br/> /// These Portal Settings are stored within a SQL database, and are /// fetched below by calling the "GetPortalSettings" stored procedure.<br/> /// This stored procedure returns values as SPROC output parameters, /// and using three result sets. /// </summary> /// <param name="pageId"> /// The page id. /// </param> /// <param name="portalAlias"> /// The portal alias. /// </param> /// <remarks> /// </remarks> private PortalSettings(int pageId, string portalAlias) { this.ActivePage = new PageSettings(); this.DesktopPages = new List<PageStripDetails>(); this.ShowPages = true; this.MobilePages = new ArrayList(); // Create Instance of Connection and Command Object using (var connection = Config.SqlConnectionString) using (var command = new SqlCommand("rb_GetPortalSettings", connection)) { // Mark the Command as a SPROC command.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC var parameterPortalAlias = new SqlParameter("@PortalAlias", SqlDbType.NVarChar, 128) { Value = portalAlias // Specify the Portal Alias Dynamically }; command.Parameters.Add(parameterPortalAlias); var parameterPageId = new SqlParameter(StringsAtPageId, SqlDbType.Int, 4) { Value = pageId }; command.Parameters.Add(parameterPageId); var parameterPortalLanguage = new SqlParameter("@PortalLanguage", SqlDbType.NVarChar, 12) { Value = this.PortalContentLanguage.Name }; command.Parameters.Add(parameterPortalLanguage); // Add out parameters to Sproc var parameterPortalId = new SqlParameter(StringsAtPortalId, SqlDbType.Int, 4) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterPortalId); var parameterPortalName = new SqlParameter("@PortalName", SqlDbType.NVarChar, 128) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterPortalName); var parameterPortalPath = new SqlParameter("@PortalPath", SqlDbType.NVarChar, 128) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterPortalPath); var parameterEditButton = new SqlParameter("@AlwaysShowEditButton", SqlDbType.Bit, 1) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterEditButton); var parameterPageName = new SqlParameter("@PageName", SqlDbType.NVarChar, 50) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterPageName); var parameterPageOrder = new SqlParameter("@PageOrder", SqlDbType.Int, 4) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterPageOrder); var parameterParentPageId = new SqlParameter("@ParentPageID", SqlDbType.Int, 4) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterParentPageId); var parameterMobilePageName = new SqlParameter("@MobilePageName", SqlDbType.NVarChar, 50) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterMobilePageName); var parameterAuthRoles = new SqlParameter("@AuthRoles", SqlDbType.NVarChar, 512) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterAuthRoles); var parameterShowMobile = new SqlParameter("@ShowMobile", SqlDbType.Bit, 1) { Direction = ParameterDirection.Output }; command.Parameters.Add(parameterShowMobile); SqlDataReader result; try { // Open the database connection and execute the command // try // jes1111 // { connection.Open(); result = command.ExecuteReader(CommandBehavior.CloseConnection); this.CurrentLayout = "Default"; // Read the first resultset -- Desktop Page Information while (result.Read()) { var tabDetails = new PageStripDetails { PageID = (int)result["PageID"], ParentPageID = Int32.Parse("0" + result["ParentPageID"]), PageName = (string)result["PageName"], PageOrder = (int)result["PageOrder"], PageLayout = this.CurrentLayout, AuthorizedRoles = (string)result["AuthorizedRoles"] }; this.PortalAlias = portalAlias; // Update the AuthorizedRoles Variable this.DesktopPages.Add(tabDetails); } if (this.DesktopPages.Count == 0) { return; // Abort load // throw new Exception("The portal you requested has no Pages. PortalAlias: '" + portalAlias + "'", new HttpException(404, "Portal not found")); } // Read the second result -- Mobile Page Information result.NextResult(); while (result.Read()) { var tabDetails = new PageStripDetails { PageID = (int)result["PageID"], PageName = (string)result["MobilePageName"], PageLayout = this.CurrentLayout, AuthorizedRoles = (string)result["AuthorizedRoles"] }; this.MobilePages.Add(tabDetails); } // Read the third result -- Module Page Information result.NextResult(); while (result.Read()) { var m = new ModuleSettings { ModuleID = (int)result["ModuleID"], ModuleDefID = (int)result["ModuleDefID"], GuidID = (Guid)result["GeneralModDefID"], PageID = (int)result["TabID"], PaneName = (string)result["PaneName"], ModuleTitle = (string)result["ModuleTitle"] }; var value = result["AuthorizedEditRoles"]; m.AuthorizedEditRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["AuthorizedViewRoles"]; m.AuthorizedViewRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["AuthorizedAddRoles"]; m.AuthorizedAddRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["AuthorizedDeleteRoles"]; m.AuthorizedDeleteRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["AuthorizedPropertiesRoles"]; m.AuthorizedPropertiesRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; // [email protected] (19/08/2004) Add support for move & delete module roles value = result["AuthorizedMoveModuleRoles"]; m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["AuthorizedDeleteModuleRoles"]; m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; // Change by [email protected] // Date: 6/2/2003 value = result["AuthorizedPublishingRoles"]; m.AuthorizedPublishingRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["SupportWorkflow"]; m.SupportWorkflow = !Convert.IsDBNull(value) ? (bool)value : false; // Date: 27/2/2003 value = result["AuthorizedApproveRoles"]; m.AuthorizedApproveRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty; value = result["WorkflowState"]; m.WorkflowStatus = !Convert.IsDBNull(value) ? (WorkflowState)(0 + (byte)value) : WorkflowState.Original; // End Change [email protected] // Start Change [email protected] try { value = result["SupportCollapsable"]; } catch { value = DBNull.Value; } m.SupportCollapsable = DBNull.Value != value ? (bool)value : false; // End Change [email protected] // Start Change [email protected] try { value = result["ShowEveryWhere"]; } catch { value = DBNull.Value; } m.ShowEveryWhere = DBNull.Value != value ? (bool)value : false; // End Change [email protected] m.CacheTime = int.Parse(result["CacheTime"].ToString()); m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString()); value = result["ShowMobile"]; m.ShowMobile = !Convert.IsDBNull(value) ? (bool)value : false; m.DesktopSrc = result["DesktopSrc"].ToString(); m.MobileSrc = result["MobileSrc"].ToString(); m.Admin = bool.Parse(result["Admin"].ToString()); this.ActivePage.Modules.Add(m); } // Now read Portal out params result.NextResult(); this.PortalID = (int)parameterPortalId.Value; this.PortalName = (string)parameterPortalName.Value; // jes1111 - this.PortalTitle = ConfigurationSettings.AppSettings["PortalTitlePrefix"] + this.PortalName; this.PortalTitle = String.Concat(Config.PortalTitlePrefix, this.PortalName); // jes1111 - this.PortalPath = Settings.Path.WebPathCombine(ConfigurationSettings.AppSettings["PortalsDirectory"], (string) parameterPortalPath.Value); this.PortalPath = Path.WebPathCombine(Config.PortalsDirectory, (string)parameterPortalPath.Value); // jes1111 - this.PortalSecurePath = ConfigurationSettings.AppSettings["PortalSecureDirectory"]; // added Thierry (tiptopweb) 12 Apr 2003 this.PortalSecurePath = Config.PortalSecureDirectory; this.ActivePage.PageID = pageId; this.ActivePage.PageLayout = this.CurrentLayout; this.ActivePage.ParentPageID = Int32.Parse("0" + parameterParentPageId.Value); this.ActivePage.PageOrder = (int)parameterPageOrder.Value; this.ActivePage.MobilePageName = (string)parameterMobilePageName.Value; this.ActivePage.AuthorizedRoles = (string)parameterAuthRoles.Value; this.ActivePage.PageName = (string)parameterPageName.Value; this.ActivePage.ShowMobile = (bool)parameterShowMobile.Value; this.ActivePage.PortalPath = this.PortalPath; // [email protected] for page custom layout result.Close(); // by Manu, fixed bug 807858 // } // catch (Exception ex) // { // HttpContext.Current.Response.Write("Failed rb_GetPortalSettings for " + pageID.ToString() + ", " + portalAlias + ":<br/>"+ex.Message); // HttpContext.Current.Response.End(); // //Response.Redirect("~/app_support/ErrorNoPortal.aspx",true); // } } catch (SqlException sqex) { var requestUri = HttpContext.Current.Request.Url; throw new DatabaseUnreachableException("This may be a new db", sqex); return; } finally { // by Manu fix close bug #2 if (connection.State == ConnectionState.Open) { connection.Close(); } } } // Provide a valid tab id if it is missing // 11-10-2011 // Changed to go to the first page that the user logged has permission to see //if (this.ActivePage.PageID == 0) //{ // this.ActivePage.PageID = ((PageStripDetails)this.DesktopPages[0]).PageID; //} // Go to get custom settings if (!Directory.Exists(Path.ApplicationPhysicalPath + this.PortalFullPath)) { var portals = new PortalsDB(); portals.CreatePortalPath(this.PortalAlias); } this.CustomSettings = GetPortalCustomSettings(this.PortalID, GetPortalBaseSettings(this.PortalPath)); // Initialize Theme var themeManager = new ThemeManager(this.PortalPath); // Default themeManager.Load(this.CustomSettings["SITESETTINGS_THEME"].ToString()); this.CurrentThemeDefault = themeManager.CurrentTheme; // Alternate if (this.CustomSettings["SITESETTINGS_ALT_THEME"].ToString() == this.CurrentThemeDefault.Name) { this.CurrentThemeAlt = this.CurrentThemeDefault; } else { themeManager.Load(this.CustomSettings["SITESETTINGS_ALT_THEME"].ToString()); this.CurrentThemeAlt = themeManager.CurrentTheme; } // themeManager.Save(this.CustomSettings["SITESETTINGS_THEME"].ToString()); // Set layout this.CurrentLayout = this.CustomSettings["SITESETTINGS_PAGE_LAYOUT"].ToString(); // Jes1111 // Generate DesktopPagesXml // jes1111 - if (bool.Parse(ConfigurationSettings.AppSettings["PortalSettingDesktopPagesXml"])) // if (Config.PortalSettingDesktopPagesXml) // this.DesktopPagesXml = GetDesktopPagesXml(); }
/// <summary> /// Read Current Page sub-tabs /// </summary> /// <param name="pageId"> /// The page ID. /// </param> /// <returns> /// A Pages Box /// </returns> public static Collection<PageStripDetails> GetPageSettingsPagesBox(int pageId) { // Create Instance of Connection and Command Object using (var connection = Config.SqlConnectionString) using (var command = new SqlCommand("rb_GetTabSettings", connection)) { // Mark the Command as a SPROC command.CommandType = CommandType.StoredProcedure; // PageID passed type FIXED by Bill Anderson (reedtek) // see: http://sourceforge.net/tracker/index.php?func=detail&aid=813789&group_id=66837&atid=515929 // Add Parameters to SPROC var parameterPageId = new SqlParameter("@PageID", SqlDbType.Int) { Value = pageId }; command.Parameters.Add(parameterPageId); // The new parameter "PortalLanguage" has been added to sp rb_GetPageSettings // Onur Esnaf var parameterPortalLanguage = new SqlParameter("@PortalLanguage", SqlDbType.NVarChar, 12) { Value = Thread.CurrentThread.CurrentUICulture.Name }; command.Parameters.Add(parameterPortalLanguage); // Open the database connection and execute the command connection.Open(); using (var result = command.ExecuteReader(CommandBehavior.CloseConnection)) { var tabs = new Collection<PageStripDetails>(); try { while (result.Read()) { var tabDetails = new PageStripDetails { PageID = (int)result["PageID"] }; var cts = new PageSettings().GetPageCustomSettings(tabDetails.PageID); tabDetails.PageImage = cts["CustomMenuImage"].ToString(); tabDetails.ParentPageID = Int32.Parse("0" + result["ParentPageID"]); tabDetails.PageName = (string)result["PageName"]; tabDetails.PageOrder = (int)result["PageOrder"]; tabDetails.AuthorizedRoles = (string)result["AuthorizedRoles"]; tabs.Add(tabDetails); } } finally { // by Manu, fixed bug 807858 result.Close(); } return tabs; } } }
/// <summary> /// Determines whether [is active tab in] [the specified active page ID]. /// </summary> /// <param name="activePageId"> /// The active page ID. /// </param> /// <param name="pageStripDetails"> /// The page strip details. /// </param> /// <returns> /// <c>true</c> if [is active tab in] [the specified active page ID]; otherwise, <c>false</c>. /// </returns> private bool IsActiveTabIn(int activePageId, PageStripDetails pageStripDetails) { if (pageStripDetails.PageID == activePageId) { return true; } var childTabs = pageStripDetails.Pages; if (childTabs.Count > 0) { if ( childTabs.Where(mySubTab => PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)).Any( mySubTab => this.IsActiveTabIn(activePageId, mySubTab))) { return true; } childTabs = null; } return false; }
/// <summary> /// Shops the menu. /// </summary> /// <param name="pageStripDetails"> /// The page strip details. /// </param> /// <param name="activePageId"> /// The active page ID. /// </param> protected virtual void ShopMenu(PageStripDetails pageStripDetails, int activePageId) { Collection<PageStripDetails> childTabs = pageStripDetails.Pages; if (childTabs.Count > 0) { foreach (var mySubTab in childTabs.Where(mySubTab => PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))) { this.AddGraphMenuItem( pageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(), mySubTab.PageName, mySubTab.PageImage, HttpUrlBuilder.BuildUrl( "~/" + HttpUrlBuilder.DefaultPage, activePageId, "ItemID=" + mySubTab.PageID), false); this.ShopMenu(mySubTab, activePageId); } childTabs = null; } }
/// <summary> /// Recourses the menu. /// </summary> /// <param name="PageStripDetails"> /// The page strip details. /// </param> /// <param name="activePageID"> /// The active page ID. /// </param> protected virtual void RecourseMenu(PageStripDetails PageStripDetails, int activePageID) { var childTabs = PageStripDetails.Pages; if (childTabs.Count > 0) { foreach (var mySubTab in childTabs.Where(mySubTab => PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))) { if (mySubTab.PageImage == null) { mySubTab.PageImage = new PageSettings().GetPageCustomSettings(mySubTab.PageID)["CustomMenuImage"].ToString(); } if (this.products(mySubTab.PageID)) { this.AddGraphMenuItem( PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(), mySubTab.PageName, mySubTab.PageImage, this.giveMeUrl(mySubTab.PageName, mySubTab.PageID), false); if (activePageID == mySubTab.PageID) { this.ShopMenu(mySubTab, activePageID); } } else { this.AddGraphMenuItem( PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(), mySubTab.PageName, mySubTab.PageImage, this.giveMeUrl(mySubTab.PageName, mySubTab.PageID), false); this.RecourseMenu(mySubTab, activePageID); } } childTabs = null; } }