/// <summary> /// Users the has allowed user role. /// </summary> /// <param name="configuration">The configuration.</param> /// <returns></returns> private bool UserHasAllowedUserRole(TreeConfiguration configuration) { var plugin = GetPluginInformation(configuration); return(plugin.UserRoles.All.Any(p => p.Name.Contains(CurrentUser.UserType.Alias))); }
/// <summary> /// Gets the plugin information. /// </summary> /// <param name="configuration">The configuration.</param> /// <returns></returns> private Plugin GetPluginInformation(TreeConfiguration configuration) { return(this.ConfigurationProvider.UmbracoCustomSettings.Plugins.All .SingleOrDefault(p => p.Controller == configuration.ControllerName)); }
/// <summary> /// Gets the tree nodes. /// </summary> /// <param name="id">The identifier.</param> /// <param name="queryStrings">The query strings.</param> /// <param name="configuration">The configuration.</param> /// <returns>The tree node collection</returns> protected TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings, TreeConfiguration configuration) { // check if we're rendering the root node's children if (id == Constants.System.Root.ToString()) { // instantiate a node tree node collection var nodes = new TreeNodeCollection(); if (UserHasAllowedUserRole(configuration)) { // create a new tree node item var item = this.CreateTreeNode(configuration.UrlName, id, queryStrings, configuration.NodeCaption, configuration.NodeIcon, false); // add to the collection nodes.Add(item); } // return return(nodes); } // this tree doesn't support rendering more than 1 level throw new NotSupportedException(); }