Skip to main content

Module roles

Module roles 

Source
Expand description

Role hierarchy and expansion logic

This module defines the built-in role hierarchy and provides utilities for expanding hierarchical roles.

Constants§

LEADER_LEVEL
Hierarchy level of the “leader” role.
MODERATOR_LEVEL
Lowest hierarchy level permitted to manage (remove / re-role) other members.
ROLE_HIERARCHY
Role hierarchy for profile-level permissions Higher roles inherit all permissions from lower roles

Functions§

can_assign_role
Whether an actor at actor_level may assign role. Leaders may assign any known role; everyone else is capped strictly below their own level. Unknown roles are never assignable.
can_manage_member
Whether an actor at actor_level may manage (remove or re-role) a member at target_level. Rule: the actor must be moderator+ and strictly outrank the target — except leaders, who may also manage peer leaders.
can_manage_member_by_roles
Whether an actor with actor_roles may manage (remove / re-role) a member with target_roles. Convenience over can_manage_member + highest_role_level.
expand_roles
Expands hierarchical roles from highest role to all inherited roles
highest_role_level
Highest hierarchy level among the given roles; unknown roles are ignored. Empty / all-unknown ⇒ 0 (public).
role_level
Hierarchy index of a single role, or None if unknown.