Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Class: expired_contexts_manager  - X-Ref

Expired contexts manager.

__construct(\progress_trace $trace = null)   X-Ref
Constructor for the expired_contexts_manager.

param: \progress_trace $trace

flag_expired_contexts()   X-Ref
Flag expired contexts as expired.

return: int[]   The number of contexts flagged as expired for courses, and users.

clear_old_records()   X-Ref
Clear old and stale records.


get_nested_expiry_info($contextpath = '')   X-Ref
Get the full nested set of expiry data relating to all contexts.

param: string      $contextpath A contexpath to restrict results to
return: \stdClass[]

get_nested_expiry_info_for_courses($contextpath = '')   X-Ref
Get the full nested set of expiry data relating to course-related contexts.

param: string      $contextpath A contexpath to restrict results to
return: \stdClass[]

get_nested_expiry_info_for_user($contextpath = '')   X-Ref
Get the full nested set of expiry data.

param: string      $contextpath A contexpath to restrict results to
return: \stdClass[]

get_nested_expiry_info_from_sql(string $sql, array $params)   X-Ref
Get the full nested set of expiry data given appropriate SQL.
Only contexts which have expired will be included.

param: string      $sql The SQL used to select the nested information.
param: array       $params The params required by the SQL.
return: \stdClass[]

is_eligible_for_deletion(array &$pathstoskip, \context $context)   X-Ref
Check whether the supplied context would be elible for deletion.

param: array       $pathstoskip A set of paths which should be skipped
param: \context    $context
return: bool

process_approved_deletions()   X-Ref
Deletes the expired contexts.

return: int[]       The number of deleted contexts.

delete_expired_context(expired_context $expiredctx)   X-Ref
Deletes user data from the provided context.

param: expired_context $expiredctx
return: \context|false

delete_expired_user_context(expired_context $expiredctx)   X-Ref
Deletes user data from the provided user context.

param: expired_context $expiredctx

require_all_end_dates_for_user_deletion()   X-Ref
Whether end dates are required on all courses in order for a user to be expired from them.

return: bool

check_requirements()   X-Ref
Check that the requirements to start deleting contexts are satisified.

return: bool

has_expired(string $period, int $comparisondate)   X-Ref
Check whether a date is beyond the specified period.

param: string      $period The Expiry Period
param: int         $comparisondate The date for comparison
return: bool

get_expiry_info(purpose $purpose, int $comparisondate = 0)   X-Ref
Get the expiry info object for the specified purpose and comparison date.

param: purpose     $purpose The purpose of this context
param: int         $comparisondate The date for comparison
return: expiry_info

update_from_expiry_info(\stdClass $expiryrecord)   X-Ref
Update or delete the expired_context from the expiry_info object.
This function depends upon the data structure returned from get_nested_expiry_info.

If the context is expired in any way, then an expired_context will be returned, otherwise null will be returned.

param: \stdClass   $expiryrecord
return: expired_context|null

update_expired_context(expired_context $expiredctx)   X-Ref
Update the expired context record.

Note: You should use the return value as the provided value will be used to fetch data only.

param: expired_context $expiredctx The record to update
return: expired_context|null

get_role_users_for_expired_context(expired_context $expiredctx, \context $context)   X-Ref
Get the list of actual users for the combination of expired, and unexpired roles.

param: expired_context $expiredctx
param: \context        $context
return: \stdClass

is_context_expired(\context $context)   X-Ref
Determine whether the supplied context has expired.

param: \context    $context
return: bool

is_course_expired(\stdClass $course)   X-Ref
Check whether the course has expired.

param: \stdClass   $course
return: bool

is_course_context_expired(\context $context)   X-Ref
Determine whether the supplied course-related context has expired.
Note: This is not necessarily a _course_ context, but a context which is _within_ a course.

param: \context        $context
return: bool

are_user_context_dependencies_expired(\context_user $context)   X-Ref
Determine whether the supplied user context's dependencies have expired.

This checks whether courses have expired, and some other check, but does not check whether the user themself has expired.

Although this seems unusual at first, each location calling this actually checks whether the user is elgible for
deletion, irrespective if they have actually expired.

For example, a request to delete the user only cares about course dependencies and the user's lack of expiry
should not block their own request to be deleted; whilst the expiry eligibility check has already tested for the
user being expired.

param: \context_user   $context
return: bool

is_context_expired_or_unprotected_for_user(\context $context, \stdClass $user)   X-Ref
Determine whether the supplied context has expired or unprotected for the specified user.

param: \context    $context
param: \stdClass   $user
return: bool

is_course_context_expired_or_unprotected_for_user(\context $context, \stdClass $user)   X-Ref
Determine whether the supplied course-related context has expired, or is unprotected.
Note: This is not necessarily a _course_ context, but a context which is _within_ a course.

param: \context        $context
param: \stdClass       $user
return: bool

get_privacy_manager()   X-Ref
Create a new instance of the privacy manager.

return: manager

get_delete_limit()   X-Ref
Fetch the limit for the maximum number of contexts to delete in one session.

return: int

get_progress()   X-Ref
Get the progress tracer.

return: \progress_trace

set_progress(\progress_trace $trace)   X-Ref
Set a specific tracer for the task.

param: \progress_trace $trace
return: $this