Hi,
You can use the roles and users in mojoPortal within your own modules fairly easily. The documentation is lacking on this and we'll probably use this post as a base for new docs.
There are several helper methods you can use to determine if a user is in a particular role or if they are in a role which has been assigned a system permission. These methods are in the mojoPortal.Business.WebHelpers.WebUser class.
- bool IsInRole(string role)
- Example:
WebUser.IsInRole("Foo");
- bool IsInRoles(string roles)
- Example:
WebUser.IsInRoles("Foo;Bar;");
- bool IsInRoles(IList roles)
- bool IsAdmin
- bool IsContentAdmin
- bool IsContentPublisher
- bool IsContentAuthor
- bool IsRoleAdmin
- bool IsNewsletterAdmin
- bool IsAdminOrContentAdmin
- bool IsAdminOrContentAdminOrContentAuthor
- bool IsAdminOrContentAdminOrContentPublisher
- bool IsAdminOrContentAdminOrContentPublisherOrContentAuthor
- bool IsAdminOrContentAdminOrRoleAdmin
- bool IsAdminOrRoleAdmin
- bool IsAdminOrContentAdminOrRoleAdminOrNewsletterAdmin
- bool IsAdminOrNewsletterAdmin
- bool HasEditPermissions(int siteId, int moduleId, int pageId)
Any page which inherits from mojoBasePage should also be able to use the following methods:
- UserCanViewPage()
- UserCanViewPage(int moduleId)
- UserCanViewPage(int moduleId, Guid featureGuid)
- UserCanEditModule()
Finally, SiteSettings has several site permission strings available that can be used with the WebUser methods to determine if a user has a particular Site Permission. These are just strings of roles (separated by semi-colon) so you can use WebUser.IsInRoles(siteSettings.RolesThatCanCreateUsers)
to determine if the user is in a role defined by a particular permission.
- SiteRootEditRoles
- SiteRootDraftEditRoles
- SiteRootDraftApprovalRoles
- CommerceReportViewRoles
- RolesThatCanCreateRootPages
- RolesThatCanViewMemberList
- RolesThatCanCreateUsers
- RolesThatCanManageUsers
- RolesThatCanViewMyPage
- RolesThatCanLookupUsers
- RolesNotAllowedToEditModuleSettings
- RolesThatCanEditContentTemplates
- GeneralBrowseAndUploadRoles
- UserFilesBrowseAndUploadRoles
- RolesThatCanDeleteFilesInEditor
- RolesThatCanAssignSkinsToPages
- RolesThatCanManageSkins
- DefaultRootPageViewRoles
- DefaultRootPageEditRoles
- DefaultRootPageCreateChildPageRoles
I hope this helps. If you have questions, please ask.
Thanks,
Joe