authorizer_interface
interface authorizer_interface
Authorizer Interface.
Defines the contract for validating user permissions and login requirements, isolating Moodle's capability system from the business logic.
Constants
| CONTEXT_SYSTEM |
Context level constant for SYSTEM. |
| CONTEXT_COURSECAT |
Context level constant for COURSE CATEGORY. |
| CONTEXT_COURSE |
Context level constant for COURSE. |
| CONTEXT_MODULE |
Context level constant for MODULE. |
| CONTEXT_BLOCK |
Context level constant for BLOCK. |
| CONTEXT_USER |
Context level constant for USER. |
Methods
Checks if a user has a specific capability.
Requires a specific capability, throwing an exception if not met.
Requires the user to be logged in to the system or a specific course.
Details
at line 72
bool
can(string $capability, int $contextlevel = self::CONTEXT_SYSTEM, int $instanceid = 0, int|null $userid = null)
Checks if a user has a specific capability.
at line 84
void
authorize(string $capability, int $contextlevel = self::CONTEXT_SYSTEM, int $instanceid = 0, int|null $userid = null)
Requires a specific capability, throwing an exception if not met.
at line 94
void
require_login(int|null $courseid = null, bool $autologinguest = true)
Requires the user to be logged in to the system or a specific course.