Custom Module Permissions
Hi,
I'm new to Sitefinity...
I'm trying to develop a simple Sitefinity 4.0 module. One of the first
things I noticed while using the administrative portion of the built-in
modules is that they all have a list of actions that can be performed
and who can perform them. For example, the events module has: "View
event", "Create event", and so on. These restrictions can usually be
defined by navigating to Settings > Permissions. My questions are:
-When and how should a module register the "actions" that it supports as
well as the roles that are allowed by default?
-How should a module display these settings? (When the user clicks
Settings > Permissions).
Thanks
Hello Nelson,
In 4.0 you have views which are defined by module definitions. The definition is created by definition elements which are similar to controls. Inside the definition you need to have methods which use DialogElement class and DefinitionsHelper.CreateDialogElement method. You can take a look at this post.
Basically you can add the permissions by creating an instance of CommandWidgetElement
CommandWidgetElement modulePermissions = new CommandWidgetElement(settings.Items)
Name = "ModulePermissions",
CommandName = DefinitionsHelper.PermissionsCommandName,
ButtonType = CommandButtonType.SimpleLinkButton,
Text = "PermissionsForMyModule",
ResourceClassId = typeof(ModuleResources).Name,
WidgetType = typeof(CommandWidget),
IsSeparator = false
;
settings.Items.Add(modulePermissions );