Security: Can I control which buttons show in the Edit toolbar?

Topics: Developer Forum, Project Management Forum, User Forum
Nov 10, 2008 at 4:34 PM

Is there an easy way to specify which toolbar buttons to show on the /Edit page for specific security roles? For example, I want to hide the "Change page permissions" from users that are not in the Administrators role.

Nov 10, 2008 at 8:28 PM
Not so easy. If you're willing to abuse the lack of encapsulation you should be able to do like this:

            foreach (var plugin in N2.Context.Current.Resolve<N2.Plugin.IPluginFinder>().GetPlugins<N2.Edit.ToolbarPluginAttribute>())
                if(plugin.Name == "security")
                    plugin.AuthorizedRoles = new[] { "Administrators"};