Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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.

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

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

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

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

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

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.

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

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

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

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.

return: \context|false
param: expired_context $expiredctx

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.

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

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

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

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.

return: expired_context|null
param: \stdClass   $expiryrecord

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.

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

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.

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

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

return: bool
param: \context    $context

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

return: bool
param: \stdClass   $course

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.

return: bool
param: \context        $context

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.

return: bool
param: \context_user   $context

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.

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

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.

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

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.

return: $this
param: \progress_trace $trace