Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tool_dataprivacy\expired_contexts_manager Class Reference

Expired contexts manager. More...

Public Member Functions

 __construct (\progress_trace $trace=null)
 Constructor for the expired_contexts_manager. More...
 
 flag_expired_contexts ()
 Flag expired contexts as expired. More...
 
 process_approved_deletions ()
 Deletes the expired contexts. More...
 
 set_progress (\progress_trace $trace)
 Set a specific tracer for the task. More...
 

Static Public Member Functions

static is_context_expired (\context $context)
 Determine whether the supplied context has expired. More...
 
static is_context_expired_or_unprotected_for_user (\context $context, stdClass $user)
 Determine whether the supplied context has expired or unprotected for the specified user. More...
 

Public Attributes

const DELETE_LIMIT = 200
 Number of deleted contexts for each scheduled task run.
 

Protected Member Functions

 check_requirements ()
 Check that the requirements to start deleting contexts are satisified. More...
 
 delete_expired_context (expired_context $expiredctx)
 Deletes user data from the provided context. More...
 
 delete_expired_user_context (expired_context $expiredctx)
 Deletes user data from the provided user context. More...
 
 get_delete_limit ()
 Fetch the limit for the maximum number of contexts to delete in one session. More...
 
 get_privacy_manager ()
 Create a new instance of the privacy manager. More...
 
 get_progress ()
 Get the progress tracer. More...
 
 get_role_users_for_expired_context (expired_context $expiredctx, context $context)
 Get the list of actual users for the combination of expired, and unexpired roles. More...
 
 update_expired_context (expired_context $expiredctx)
 Update the expired context record. More...
 
 update_from_expiry_info (\stdClass $expiryrecord)
 Update or delete the expired_context from the expiry_info object. More...
 

Static Protected Member Functions

static are_user_context_dependencies_expired (\context_user $context)
 Determine whether the supplied user context's dependencies have expired. More...
 
static clear_old_records ()
 Clear old and stale records.
 
static get_expiry_info (purpose $purpose, int $comparisondate=0)
 Get the expiry info object for the specified purpose and comparison date. More...
 
static get_nested_expiry_info ($contextpath='')
 Get the full nested set of expiry data relating to all contexts. More...
 
static get_nested_expiry_info_for_courses ($contextpath='')
 Get the full nested set of expiry data relating to course-related contexts. More...
 
static get_nested_expiry_info_for_user ($contextpath='')
 Get the full nested set of expiry data. More...
 
static get_nested_expiry_info_from_sql (string $sql, array $params)
 Get the full nested set of expiry data given appropriate SQL. More...
 
static has_expired (string $period, int $comparisondate)
 Check whether a date is beyond the specified period. More...
 
static is_course_context_expired (\context $context)
 Determine whether the supplied course-related context has expired. More...
 
static is_course_context_expired_or_unprotected_for_user (\context $context, stdClass $user)
 Determine whether the supplied course-related context has expired, or is unprotected. More...
 
static is_course_expired (\stdClass $course)
 Check whether the course has expired. More...
 
static is_eligible_for_deletion (array &$pathstoskip, context $context)
 Check whether the supplied context would be elible for deletion. More...
 
static require_all_end_dates_for_user_deletion ()
 Whether end dates are required on all courses in order for a user to be expired from them. More...
 

Protected Attributes

manager $manager = null
 The privacy manager.
 
progress_trace $progresstracer = null
 The log progress tracer.
 
progress_trace $trace = null
 Trace tool for logging.
 

Detailed Description

Expired contexts manager.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_dataprivacy\expired_contexts_manager::__construct ( \progress_trace  $trace = null)

Constructor for the expired_contexts_manager.

Parameters
progress_trace$trace

Member Function Documentation

◆ are_user_context_dependencies_expired()

static tool_dataprivacy\expired_contexts_manager::are_user_context_dependencies_expired ( \context_user  $context)
staticprotected

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.

Parameters
context_user$context
Return values
bool

◆ check_requirements()

tool_dataprivacy\expired_contexts_manager::check_requirements ( )
protected

Check that the requirements to start deleting contexts are satisified.

Return values
bool

◆ delete_expired_context()

tool_dataprivacy\expired_contexts_manager::delete_expired_context ( expired_context  $expiredctx)
protected

Deletes user data from the provided context.

Parameters
expired_context$expiredctx
Return values
context|false

◆ delete_expired_user_context()

tool_dataprivacy\expired_contexts_manager::delete_expired_user_context ( expired_context  $expiredctx)
protected

Deletes user data from the provided user context.

Parameters
expired_context$expiredctx

◆ flag_expired_contexts()

tool_dataprivacy\expired_contexts_manager::flag_expired_contexts ( )

Flag expired contexts as expired.

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

◆ get_delete_limit()

tool_dataprivacy\expired_contexts_manager::get_delete_limit ( )
protected

Fetch the limit for the maximum number of contexts to delete in one session.

Return values
int

◆ get_expiry_info()

static tool_dataprivacy\expired_contexts_manager::get_expiry_info ( purpose  $purpose,
int  $comparisondate = 0 
)
staticprotected

Get the expiry info object for the specified purpose and comparison date.

Parameters
purpose$purposeThe purpose of this context
int$comparisondateThe date for comparison
Return values
expiry_info

◆ get_nested_expiry_info()

static tool_dataprivacy\expired_contexts_manager::get_nested_expiry_info (   $contextpath = '')
staticprotected

Get the full nested set of expiry data relating to all contexts.

Parameters
string$contextpathA contexpath to restrict results to
Return values
stdClass[]

◆ get_nested_expiry_info_for_courses()

static tool_dataprivacy\expired_contexts_manager::get_nested_expiry_info_for_courses (   $contextpath = '')
staticprotected

Get the full nested set of expiry data relating to course-related contexts.

Parameters
string$contextpathA contexpath to restrict results to
Return values
stdClass[]

◆ get_nested_expiry_info_for_user()

static tool_dataprivacy\expired_contexts_manager::get_nested_expiry_info_for_user (   $contextpath = '')
staticprotected

Get the full nested set of expiry data.

Parameters
string$contextpathA contexpath to restrict results to
Return values
stdClass[]

◆ get_nested_expiry_info_from_sql()

static tool_dataprivacy\expired_contexts_manager::get_nested_expiry_info_from_sql ( string  $sql,
array  $params 
)
staticprotected

Get the full nested set of expiry data given appropriate SQL.

Only contexts which have expired will be included.

Parameters
string$sqlThe SQL used to select the nested information.
array$paramsThe params required by the SQL.
Return values
stdClass[]

◆ get_privacy_manager()

tool_dataprivacy\expired_contexts_manager::get_privacy_manager ( )
protected

Create a new instance of the privacy manager.

Return values
manager

◆ get_progress()

tool_dataprivacy\expired_contexts_manager::get_progress ( )
protected

Get the progress tracer.

Return values
progress_trace

◆ get_role_users_for_expired_context()

tool_dataprivacy\expired_contexts_manager::get_role_users_for_expired_context ( expired_context  $expiredctx,
context  $context 
)
protected

Get the list of actual users for the combination of expired, and unexpired roles.

Parameters
expired_context$expiredctx
context$context
Return values
stdClass

◆ has_expired()

static tool_dataprivacy\expired_contexts_manager::has_expired ( string  $period,
int  $comparisondate 
)
staticprotected

Check whether a date is beyond the specified period.

Parameters
string$periodThe Expiry Period
int$comparisondateThe date for comparison
Return values
bool

◆ is_context_expired()

static tool_dataprivacy\expired_contexts_manager::is_context_expired ( \context  $context)
static

Determine whether the supplied context has expired.

Parameters
context$context
Return values
bool

◆ is_context_expired_or_unprotected_for_user()

static tool_dataprivacy\expired_contexts_manager::is_context_expired_or_unprotected_for_user ( \context  $context,
stdClass  $user 
)
static

Determine whether the supplied context has expired or unprotected for the specified user.

Parameters
context$context
stdClass$user
Return values
bool

◆ is_course_context_expired()

static tool_dataprivacy\expired_contexts_manager::is_course_context_expired ( \context  $context)
staticprotected

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.

Parameters
context$context
Return values
bool

◆ is_course_context_expired_or_unprotected_for_user()

static tool_dataprivacy\expired_contexts_manager::is_course_context_expired_or_unprotected_for_user ( \context  $context,
stdClass  $user 
)
staticprotected

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.

Parameters
context$context
stdClass$user
Return values
bool

◆ is_course_expired()

static tool_dataprivacy\expired_contexts_manager::is_course_expired ( \stdClass  $course)
staticprotected

Check whether the course has expired.

Parameters
stdClass$course
Return values
bool

◆ is_eligible_for_deletion()

static tool_dataprivacy\expired_contexts_manager::is_eligible_for_deletion ( array &  $pathstoskip,
context  $context 
)
staticprotected

Check whether the supplied context would be elible for deletion.

Parameters
array$pathstoskipA set of paths which should be skipped
context$context
Return values
bool

◆ process_approved_deletions()

tool_dataprivacy\expired_contexts_manager::process_approved_deletions ( )

Deletes the expired contexts.

Return values
int[]The number of deleted contexts.

◆ require_all_end_dates_for_user_deletion()

static tool_dataprivacy\expired_contexts_manager::require_all_end_dates_for_user_deletion ( )
staticprotected

Whether end dates are required on all courses in order for a user to be expired from them.

Return values
bool

◆ set_progress()

tool_dataprivacy\expired_contexts_manager::set_progress ( \progress_trace  $trace)

Set a specific tracer for the task.

Parameters
progress_trace$trace
Return values
$this

◆ update_expired_context()

tool_dataprivacy\expired_contexts_manager::update_expired_context ( expired_context  $expiredctx)
protected

Update the expired context record.

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

Parameters
expired_context$expiredctxThe record to update
Return values
expired_context|null

◆ update_from_expiry_info()

tool_dataprivacy\expired_contexts_manager::update_from_expiry_info ( \stdClass  $expiryrecord)
protected

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.

Parameters
stdClass$expiryrecord
Return values
expired_context|null

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