MDL-62560 tool_dataprivacy: Fetch user purpose once

This commit is contained in:
Andrew Nicols 2018-10-18 14:16:31 +08:00 committed by David Monllao
parent a1d51ad8c6
commit b519dab3bd

View File

@ -269,6 +269,8 @@ class expired_contexts_manager {
$datalist = [];
$expiredcontents = [];
$pathstoskip = [];
$userpurpose = data_registry::get_effective_contextlevel_value(CONTEXT_USER, 'purpose');
foreach ($fulllist as $record) {
\context_helper::preload_from_record($record);
$context = \context::instance_by_id($record->id, false);
@ -291,8 +293,12 @@ class expired_contexts_manager {
continue;
}
$purposevalue = $record->purposeid !== null ? $record->purposeid : context_instance::NOTSET;
$purpose = api::get_effective_context_purpose($context, $purposevalue);
if ($context instanceof \context_user) {
$purpose = $userpurpose;
} else {
$purposevalue = $record->purposeid !== null ? $record->purposeid : context_instance::NOTSET;
$purpose = api::get_effective_context_purpose($context, $purposevalue);
}
if ($context instanceof \context_user && !empty($record->userdeleted)) {
$expiryinfo = static::get_expiry_info($purpose, $record->userdeleted);