protected void Page_Load(object sender, EventArgs e) { lnkBackup.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "backup"); lnkRestore.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "restore"); lnkImportResources.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "import"); lnkBackup.Visible = lnkRestore.Visible = PortalUtils.PageExists("Backup"); lnkImportResources.Visible = (PanelSecurity.PackageId >= 1 && PanelSecurity.LoggedUser.Role == UserRole.Administrator); if (PanelSecurity.SelectedUser.RoleId.Equals(1)) { lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible; } UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId); if (user != null) { PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx))) { lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { lnkBackup.NavigateUrl = EditUrl(PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), "backup"); lnkRestore.NavigateUrl = EditUrl(PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), "restore"); lnkBackup.Visible = lnkRestore.Visible = PortalUtils.PageExists("Backup"); if (PanelSecurity.SelectedUser.RoleId.Equals(1)) { lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible = false; } }
private void BindTools() { lnkTerminalSessions.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "edit_termservices"); lnkWindowsServices.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "edit_winservices"); lnkWindowsProcesses.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "edit_processes"); lnkEventViewer.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "edit_eventviewer"); lnkServerReboot.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "edit_reboot"); lnkBackup.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "backup"); lnkRestore.NavigateUrl = EditUrl("ServerID", PanelRequest.ServerId.ToString(), "restore"); lnkBackup.Visible = lnkRestore.Visible = PortalUtils.PageExists("Backup"); }
protected void Page_Load(object sender, EventArgs e) { lnkBackup.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "backup"); lnkRestore.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "restore"); lnkImportResources.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "import"); lnkBackup.Visible = lnkRestore.Visible = PortalUtils.PageExists("Backup"); lnkImportResources.Visible = (PanelSecurity.PackageId > 1 && PanelSecurity.LoggedUser.Role == UserRole.Administrator); if (PanelSecurity.SelectedUser.RoleId.Equals(1)) { lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible; } }
private MenuItem CreateMenuItem(PackageContext cntx, XmlNode xmlNode) { string pageId = GetXmlAttribute(xmlNode, "pageID"); if (!PortalUtils.PageExists(pageId)) { return(null); } string url = GetXmlAttribute(xmlNode, "url"); string title = GetXmlAttribute(xmlNode, "title"); string imageUrl = GetXmlAttribute(xmlNode, "imageUrl"); string target = GetXmlAttribute(xmlNode, "target"); string resourceGroup = GetXmlAttribute(xmlNode, "resourceGroup"); string quota = GetXmlAttribute(xmlNode, "quota"); bool disabled = Utils.ParseBool(GetXmlAttribute(xmlNode, "disabled"), false); // get custom page parameters XmlNodeList xmlParameters = xmlNode.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } // add menu item string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.SPACE_ID_PARAM, cntx.Package.PackageId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", disabled ? null : pageUrl); item.ImageUrl = PortalUtils.GetThemedIcon(imageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } item.Selectable = !disabled; // check groups/quotas bool display = true; if (cntx != null) { display = (String.IsNullOrEmpty(resourceGroup) || cntx.Groups.ContainsKey(resourceGroup)) && (String.IsNullOrEmpty(quota) || (cntx.Quotas.ContainsKey(quota) && cntx.Quotas[quota].QuotaAllocatedValue != 0)); } // process nested menu items XmlNodeList xmlMenuNodes = xmlNode.SelectNodes("MenuItems/MenuItem"); foreach (XmlNode xmlMenuNode in xmlMenuNodes) { MenuItem menuItem = CreateMenuItem(cntx, xmlMenuNode); if (menuItem != null) { item.ChildItems.Add(menuItem); } } if (display && !(disabled && item.ChildItems.Count == 0)) { return(item); } return(null); }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string resourceGroup = null; if (node.Attributes["resourceGroup"] != null) { resourceGroup = node.Attributes["resourceGroup"].Value; } string quota = null; if (node.Attributes["quota"] != null) { quota = node.Attributes["quota"].Value; } bool disabled = false; if (node.Attributes["disabled"] != null) { disabled = Utils.ParseBool(node.Attributes["disabled"].Value, false); } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } // add menu item string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", disabled ? null : pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } item.Selectable = !disabled; // check groups/quotas bool display = true; if (cntx != null) { display = (String.IsNullOrEmpty(resourceGroup) || cntx.Groups.ContainsKey(resourceGroup)) && (String.IsNullOrEmpty(quota) || (cntx.Quotas.ContainsKey(quota) && cntx.Quotas[quota].QuotaAllocatedValue != 0)); } if (display) { // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } if (display && !(disabled && item.ChildItems.Count == 0)) { items.Add(item); } } }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { bool ecUserEnabled = false; bool ecAdminEnabled = PanelSecurity.SelectedUser.EcommerceEnabled; // UserInfo parent = UsersHelper.GetUser(PanelSecurity.SelectedUser.OwnerId); // if (parent != null) { ecUserEnabled = parent.EcommerceEnabled; } foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string roles = null; if (node.Attributes["roles"] != null) { roles = node.Attributes["roles"].Value; } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } bool display = true; // set user role visibility second if (!String.IsNullOrEmpty(roles)) { display = false; string[] arrRoles = roles.Split(','); string userRole = PanelSecurity.SelectedUser.Role.ToString(); foreach (string role in arrRoles) { if (String.Compare(userRole, role, true) == 0) { display = true; break; } } } // set ecommerce user visibility first if (display && node.Attributes["ecuser"] != null) { display = ecUserEnabled; } // set ecommerce admin visibility third if (display && node.Attributes["ecadmin"] != null) { display = ecAdminEnabled; } //Audit Log functionality is disabled when user is in Demo mode if ((pageId == "AuditLog") && (PanelSecurity.SelectedUser.IsDemo)) { display = false; } // add menu item if (display) { string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } items.Add(item); // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } } }