From 089a62ce720e4aaaaaaf5bd660cb5e1d31bbcd50 Mon Sep 17 00:00:00 2001 From: robvde Date: Mon, 30 Jul 2012 17:02:06 +0400 Subject: [PATCH] New attribute added to the 'ModulesData.config' 'selectedUserContext' through this attribute the left menu (UserAccountMenu) can be managed based on the selected user. The logged on user context (roles) finally determines if the menu item shows up or not. selectedUserContext attribute can contain "Administrator,Reseller,User" --- .../App_Data/ModulesData.config | 20 +++++++++--------- .../Code/PortalConfiguration.cs | 3 +++ .../WebsitePanel/UserAccountMenu.ascx.cs | 21 ++++++++++++++++++- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ModulesData.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ModulesData.config index 9afcf166..efd04273 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ModulesData.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ModulesData.config @@ -2,15 +2,15 @@ - - - - - - - - - + + + + + + + + + @@ -24,7 +24,7 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalConfiguration.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalConfiguration.cs index 4d95ee7e..5de61c70 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalConfiguration.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalConfiguration.cs @@ -290,6 +290,9 @@ namespace WebsitePanel.WebPortal else page.Roles.AddRange(xmlPage.Attributes["roles"].Value.Split(ROLES_DELIMITERS.ToCharArray())); + if (xmlPage.Attributes["selectedUserContext"] != null) + page.Roles.AddRange(xmlPage.Attributes["selectedUserContext"].Value.Split(ROLES_DELIMITERS.ToCharArray())); + page.Enabled = (xmlPage.Attributes["enabled"] != null) ? Boolean.Parse(xmlPage.Attributes["enabled"].Value) : true; page.Hidden = (xmlPage.Attributes["hidden"] != null) ? Boolean.Parse(xmlPage.Attributes["hidden"].Value) : false; page.SkinSrc = (xmlPage.Attributes["skin"] != null) ? xmlPage.Attributes["skin"].Value : null; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMenu.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMenu.ascx.cs index 032aa19d..7652383e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMenu.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountMenu.ascx.cs @@ -85,6 +85,10 @@ namespace WebsitePanel.Portal string roles = null; if (node.Attributes["roles"] != null) roles = node.Attributes["roles"].Value; + + string selectedUserContext = null; + if (node.Attributes["selectedUserContext"] != null) + selectedUserContext = node.Attributes["selectedUserContext"].Value; // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); @@ -97,7 +101,22 @@ namespace WebsitePanel.Portal bool display = true; // set user role visibility second - if (!String.IsNullOrEmpty(roles)) + if (!String.IsNullOrEmpty(selectedUserContext)) + { + display = false; + string[] arrRoles = selectedUserContext.Split(','); + string userRole = PanelSecurity.SelectedUser.Role.ToString(); + foreach (string role in arrRoles) + { + if (String.Compare(userRole, role, true) == 0) + { + display = true; + break; + } + } + } + + if ((!String.IsNullOrEmpty(roles)) & display) { display = false; string[] arrRoles = roles.Split(',');