ISearchableContentType and Group Members

Former Member
Former Member

Hi

I created my custom searchable content type and implemented GetViewSecurityRoles method:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public int[] GetViewSecurityRoles(Guid contentId)
{
try
{
var content = _roadTestItemService.Get(contentId);
RoadTestItemApplication app = (RoadTestItemApplication)content.Application;
IRoles roles = Apis.Get<IRoles>();
List<int?> list = new List<int?>();
foreach (var role in roles.List(content.ApplicationId, RoadTestConstants.PermissionItemView))
list.Add(role.Id);
int?[] array = list.Intersect(roles.List(content.Application.Container.ContainerId, (Guid)GroupPermission.ReadGroup)
.Select(groupRole => groupRole.Id).ToArray()).ToArray();
return array.Select(roleId => Convert.ToInt32(roleId)).ToArray();
}
catch (Exception e)
{
ExceptionHelper.Handle(e);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

As you can see it returns roleIds from security roles list.

But group members also may have an access to content ant this approach does not work in this case.

How can I implement group members support?

  • Former Member
    0 Former Member

    Both of the roles.List calls should include the Group level Roles that have access to the content.  That should cover your group members.

  • Former Member
    0 Former Member in reply to Former Member

    What do you mean?
    On first roles.List I get all roles that have View permissions on parent app.
    On second - all roles that have Read permission on parent group.

    I saw something similar in Ideas content type.

  • Former Member
    0 Former Member in reply to Former Member

    When you are added as the member of a group, you are added to the Members role for that group.  When you list which roles have view permissions for the application or read permission in that group, the group's Members role will be included in that list.  So that code above should already account for group members.