This project is not covered by Drupal’s security advisory policy.
NOTE: the current code is compatible only with Group version 1. An update to Group 3 is planned in August/September 2023.
Group membership records are a way of tracking and providing access within the Group module, while retaining historical information about who had what role when, and providing fieldable record types that allow tracking more information about that person's role.
What it does
Groups currently allow users to be assigned roles within the group. But what if roles are held by different people over time, and you want to keep track of the full history of who has had what roles within the group?
Or someone can have a single role in terms of group permissions, e.g. "Committee member", but be in that role in various different ways (e.g. different kinds of committee members), and you'd want to keep track of each of those ways separately without having a role for each.
This module allows you to track as many 'instances' of a user having a role as you like, and assign fields to those instances to collect any data that you like. So, group roles become not just controlling current access to the group via permissions, but also a record of any other information you might want, and a history of all previous variations of how a user has had that role.
It also out of the box allows for two key management tools (both optional), which automatically control whether the user has the specified role in the group right now.
- an instance can be 'current', based on a date range, which allows restricting group access based on whether today's date falls within that date range. This means e.g. you could assign someone a role instance for a specific period, and they'd only get the permissions of that role for as long as the instance is current.
- an instance can be 'enabled', based on either manually checking or unchecking a boolean field, OR via providing a plugin in a custom module defining what it means for an instance to be current.
Use cases
For an academic setting, this might be:
- Class president - has certain access to the group only for a specified amount of time, but we want to keep a record of them having been president (or that they will be Presiden)
- Volunteer group representative - has specific access as above, and we record their role based on dates - but they need to complete training to have access to the group, so we have a custom EnabledDeterminer plugin to only enable the group membership record once that training is complete
For Students' Union UCL, the developers, this has been used for:
- Clubs and Societies - standard members and committee officers
- Volunteering organisations - leaders and volunteers
- Volunteering opportunities - expression of interest and placement
- Elected representatives (each constituency is a Group)
- Committees
How to use
The module expects you have existing group types and roles within those groups.
1. Create "group membership record types" - these are the different sets of fields you might want to associate with given group roles.
- Name it and provide some fields. admin/group/membership_record/type
- Often you'll have a group membership record type for each group role, e.g. if you have a 'Committee member' role, you would create a 'Committee member' role instance type and assign it to it.
- However, you could e.g. have President, Treasurer and Secretary roles in the group, but want to track the same information for all of them. So, you create a more generic 'Society committee officer' group membership record type, and assign that same type to each of the three roles.
2. After creating the instance type, edit the group role and link the role to the "group membership record type" you created. There are some other options available when editing the group role that are explained in the form, e.g. to restrict access based on enabled or current fields.
3. Group membership records are then created in a few ways:
- Through the "Group membership records" entity list and default form - not recommended as it can be complex
- Custom modules provide custom forms extending the GroupMembershipRecordForm form class - e.g. create a custom "Add Club President" form. This class allows for: setting the form to default to or limit to, roles, group types, groups etc, including e.g. limiting available roles to a specified group type; autocompleting values on the form by query string; customising the language so your users never need to know about the notion of "group membership records".
- Custom modules can create instances as needed, based on whatever triggers they need (e.g. role being granted, purchase being made, etc).
- If you selected 'create by default' on the group role form, an instance will automatically be made for the user in that role whenever the role is assigned.
4. Views can then be made showing group info, role, and each instance.
- Views access can be limited by the normal Group access option - Group Membership Record intercepts the normal Group permissions if a role has been limited by being enabled and/or date controlled.
- For Group views, you can get a count of current and/or enabled records using "Group membership record count" field (MembershipRecordsForGroupCount)
Project information
- Project categories: Integrations, Access control
- Ecosystem: Group
- Created by maxwellkeeble on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
