MDL-63401 tool_dataprivacy: Rewrite expired deletion handling
This change rewrites the way in which expiry is calculated and addresses a number of closely related issues: Users can customise, and add blocks with data to, their dashboard. When a user had done so, the user could be flagged for deletion, but the blocks in their Dashboard were subject to the default block retention policy. In addition there is no way to override the retention policy for user blocks. This change modifies the structure of the expiry mechanism: - to consider any subcontext of the user context to be a part of the user context during calculation. User child contexts are not the property of the system, and should not be treated separately. - the way in which the context expiry mechanism worked was to select use a multiple different managers based solely on the context level. Because of the use of user blocks, this proved to be unreliable as blocks has been attributed purely to courses. This has been changed to a single manager which is aware of hierarchy and deletions as a whole. - to prepare for upcoming work relating to more detailed expiry mechanisms, a new expiry_info class is introduced and used to merge the expiry of child contexts into a working in-memory view. This changeset includes extensive unit tests.
This commit is contained in:
@@ -929,7 +929,7 @@ class api {
|
||||
* @param int $forcedvalue Use this purposeid value as if this was this context instance purpose.
|
||||
* @return purpose|false
|
||||
*/
|
||||
public static function get_effective_context_purpose(\context $context, $forcedvalue=false) {
|
||||
public static function get_effective_context_purpose(\context $context, $forcedvalue = false) {
|
||||
if (!data_registry::defaults_set()) {
|
||||
return false;
|
||||
}
|
||||
@@ -967,34 +967,6 @@ class api {
|
||||
return data_registry::get_effective_contextlevel_value($contextlevel, 'purpose', $forcedvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an expired context record for the provided context id.
|
||||
*
|
||||
* @param int $contextid
|
||||
* @return \tool_dataprivacy\expired_context
|
||||
*/
|
||||
public static function create_expired_context($contextid) {
|
||||
$record = (object)[
|
||||
'contextid' => $contextid,
|
||||
'status' => expired_context::STATUS_EXPIRED,
|
||||
];
|
||||
$expiredctx = new expired_context(0, $record);
|
||||
$expiredctx->save();
|
||||
|
||||
return $expiredctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an expired context record.
|
||||
*
|
||||
* @param int $id The tool_dataprivacy_ctxexpire id.
|
||||
* @return bool True on success.
|
||||
*/
|
||||
public static function delete_expired_context($id) {
|
||||
$expiredcontext = new expired_context($id);
|
||||
return $expiredcontext->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the status of an expired context.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user