Follow-up of #2850417: Remove hook_group_user_roles_alter().

Group would be even more powerful if we could synchronize global roles to group roles. Examples:

  • "Anyone with the global Editor role automatically gets the permissions tied to the special group role Outsider (Editor) in all groups of type Newsdesk."
  • "Anyone who is a member of a Classroom group, but has the global role Teacher, automatically gets the special group role Member (Teacher)."

Comments

kristiaanvandeneynde created an issue. See original summary.

kristiaanvandeneynde’s picture

Introducing multiple outsider roles (one for each global role).

We want one for every global role. So the current "Outsider" role would map to "Authenticated user". We would need to refactor methods such as GroupTypeInterface::getOutsiderRole() to become GroupTypeInterface::getOutsiderRoles().

When retrieving someone's roles, when checking for access, etc... we would no longer be able to rely on GroupTypeInterface::getOutsiderRoleId() for that matter. We would need to implement a GroupRoleInterface::applies($account) that would check whether an outsider role applies.

Given the above, we would be able to sync all global roles to an outsider group role. Cache contexts would still work in this scenario, given some adjustments. We can retrieve multiple outsider roles because we can query group roles by group type ID and audience.

The challenge would be UX. I was thinking of keeping the current UI as is and add an extra one for the individual outsider roles. Or to add a fieldset at the top with checkboxes asking you what you want to show:

  • Catch-all roles (Anon, Outsider, Member)
  • Synchronized outsider roles
  • User-defined group roles

There are several options here so I don't want to decide on a UI just yet.

kristiaanvandeneynde’s picture

On the subject of synchronized member roles:

We could make sure that whenever a membership is saved, the roles get added to that membership. We would then need several hooks regarding user update, role update, etc. to make sure the memberships are adjusted accordingly.

Same challenge: To make this work and have a user friendly UI at the same time.

kristiaanvandeneynde’s picture

Status: Active » Closed (duplicate)
Related issues: +#2883238: Move the grolesync module to the main module for outsiders only.