Skip to content

[C2] Roles and permissions fine-grained management #5644

@ywarnier

Description

@ywarnier

Add the possibility to define fine-grained permissions and assign them to roles.

A definition of basic permissions is ongoing here: https://github.com/chamilo/chamilo-lms/wiki/Permissions

Create a Permission entity with id, title, slug and description.
Create a PermissionRelRole entity with id, permission_id, role_code, changeable, updated_at.
Create an assignment interface with roles in columns and permissions in rows, like so:

Permission ROLE_INVITEE ROLE_STUDENT ROLE_TEACHER ...
analytics:view [] [x] [x]
assignment:create [] [] [X]

allowing one to check the boxes for each role (except when changeable == 0). This is then sent to the PermissionRelRole entity/table.

Use the wiki table as source for the default definition of each set of permissions per role.

Define a global permission function to search for the existence of a permission based on the permission name and an array of roles. Something like api_get_permission('analytics:view', ['ROLE_STUDENT','ROLE_TEACHER']). This function/helper will then check, for the given permission, if one or more of the roles provided has the permission enabled and return true or false based on that.

Relates to #2540

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions