Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_group\visibility Class Reference

Group visibility methods. More...

Static Public Member Functions

static can_view_all_groups (int $courseid)
 Can the current user view all the groups on the course?
 
static course_has_hidden_groups (int $courseid)
 Return whether a course currently had hidden groups.
 
static sql_group_visibility_where (int $userid, string $groupsalias='g', string $groupsmembersalias='gm')
 Return SQL conditions for determining whether a user can see a group and its memberships.
 
static sql_member_visibility_where (string $groupsalias='g', string $groupsmembersalias='gm', string $useralias='u', string $paramprefix='',)
 Return SQL conditions for determining whether a user can see a group's members.
 
static update_hiddengroups_cache (int $courseid, ?\cache $cache=null)
 Store the number groups with visibility other than ALL on the course.
 

Static Protected Member Functions

static sql_members_visibility_condition (string $groupsalias='g', string $groupsmembersalias='gm', string $paramprefix='',)
 Return a condition to check if a user can view a group because it has MEMBERS visibility and they are a member.
 

Detailed Description

Group visibility methods.

Member Function Documentation

◆ can_view_all_groups()

static core_group\visibility::can_view_all_groups ( int $courseid)
static

Can the current user view all the groups on the course?

Returns true if there are no groups on the course with visibility != ALL, or if the user has viewhiddengroups.

This is useful for deciding whether we need to perform additional visibility checkes such as the sql_* methods of this class.

Parameters
int$courseid
Return values
bool

◆ course_has_hidden_groups()

static core_group\visibility::course_has_hidden_groups ( int $courseid)
static

Return whether a course currently had hidden groups.

This can be used as a shortcut to decide whether visibility restrictions need to be applied. If this returns false, we may be able to use cached data, or do a much simpler query.

Parameters
int$courseid
Return values
bool
Exceptions
coding_exception
dml_exception

◆ sql_group_visibility_where()

static core_group\visibility::sql_group_visibility_where ( int $userid,
string $groupsalias = 'g',
string $groupsmembersalias = 'gm' )
static

Return SQL conditions for determining whether a user can see a group and its memberships.

Parameters
int$userid
string$groupsaliasThe SQL alias being used for the groups table.
string$groupsmembersaliasThe SQL alias being used for the groups_members table.
Return values
array[$where, $params]

◆ sql_member_visibility_where()

static core_group\visibility::sql_member_visibility_where ( string $groupsalias = 'g',
string $groupsmembersalias = 'gm',
string $useralias = 'u',
string $paramprefix = '' )
static

Return SQL conditions for determining whether a user can see a group's members.

Parameters
string$groupsaliasThe SQL alias being used for the groups table.
string$groupsmembersaliasThe SQL alias being used for the groups_members table.
string$useraliasThe SQL alias being used for the user table.
string$paramprefixPrefix for the parameter names.
Return values
array[$where, $params]

◆ sql_members_visibility_condition()

static core_group\visibility::sql_members_visibility_condition ( string $groupsalias = 'g',
string $groupsmembersalias = 'gm',
string $paramprefix = '' )
staticprotected

Return a condition to check if a user can view a group because it has MEMBERS visibility and they are a member.

Parameters
string$groupsaliasThe SQL alias being used for the groups table.
string$groupsmembersaliasThe SQL alias being used for the groups_members table.
string$paramprefixPrefix for the parameter names.
Return values
array[$sql, $params]

◆ update_hiddengroups_cache()

static core_group\visibility::update_hiddengroups_cache ( int $courseid,
?\cache $cache = null )
static

Store the number groups with visibility other than ALL on the course.

Parameters
int$courseidCourse ID to update the cache for.
cache | null$cacheExisting cache instance. If null, once will be created.
Return values
void
Exceptions
dml_exception

The documentation for this class was generated from the following file: