class capability_support

internal  
 

Utility functions for Moodle capabilities and permissions.

Methods

static bool|null
has(string $capability, context $context, null|int|stdClass $user = null, bool $doanything = true)

Checks if a user has a specific capability in a given context.

static string
get_string(string $capability)

Retrieves the human-readable name of a capability.

Details

at line 42
static bool|null has(string $capability, context $context, null|int|stdClass $user = null, bool $doanything = true)

Checks if a user has a specific capability in a given context.

Parameters

string $capability

Capability name

context $context

Context object

null|int|stdClass $user

User object or ID (null for current user)

bool $doanything

Whether to check for the 'doanything' capability

Return Value

bool|null

True if user has capability, false if not, or null on error

at line 60
static string get_string(string $capability)

Retrieves the human-readable name of a capability.

Parameters

string $capability

Capability name

Return Value

string

the localized capability name