This project is read-only.

Hiding tabs

Mar 18, 2009 at 10:32 AM
I would like to reveal the "Advanced" tab to administrators only and hide it for all other members including content editors.
Hiding all the properties on the Tab is possible but then there is still an empty tab left.
Can somebody provide me with a solution?

Also it seems I can prevent users from creating items but not from deleting them.

Aren't these major flaws within the security model? Do you have any plans on updating it in the near future?

Further discussion of the security model

Thanks in advance
Mar 18, 2009 at 6:45 PM
About the advanced tab...

If you can change the templates code you can go into the N2.Templates.Items.AbstractPage and add AuthorizedRoles = new ["Administrators"] to the TabContainer attribute.

You might also be able to used the new aspect controller concept for this. Something like this:

    [Controls(typeof(ContentItem))]
    public class PreventAdvancedEditingAspectController : N2.Edit.EditableAspectController
    {
        public virtual IDictionary<string, Control> AddDefinedEditors(Type itemType, Control container, IPrincipal user)
        {
            IDictionary<string, Control> addedEditors = base.AddDefinedEditors(itemType,container,user);
            // do something tricky
            return addedEditors;
        }
    }

And probably a few other tricky hacks as well =)

Sorry, no plans to change this in the near future. I would like to but I don't have the time right now.

If you really need this you could use the events exposed by N2.Context.Current.Persister and write code to prevent it (throw an exception or something like that).