Merge branch 'MDL-62075_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Jun Pataleta
2018-05-12 00:29:56 +08:00
2 changed files with 20 additions and 3 deletions
@@ -67,6 +67,8 @@ class my_data_requests_page implements renderable, templatable {
* @throws moodle_exception
*/
public function export_for_template(renderer_base $output) {
global $USER;
$data = new stdClass();
$data->newdatarequesturl = new moodle_url('/admin/tool/dataprivacy/createdatarequest.php');
@@ -80,10 +82,24 @@ class my_data_requests_page implements renderable, templatable {
$requestid = $request->get('id');
$status = $request->get('status');
$userid = $request->get('userid');
$usercontext = context_user::instance($userid);
$requestexporter = new data_request_exporter($request, ['context' => $usercontext]);
$usercontext = context_user::instance($userid, IGNORE_MISSING);
if (!$usercontext) {
// Use the context system.
$outputcontext = \context_system::instance();
} else {
$outputcontext = $usercontext;
}
$requestexporter = new data_request_exporter($request, ['context' => $outputcontext]);
$item = $requestexporter->export($output);
if ($request->get('userid') != $USER->id) {
// Append user name if it differs from $USER.
$a = (object)['typename' => $item->typename, 'user' => $item->foruser->fullname];
$item->typename = get_string('requesttypeuser', 'tool_dataprivacy', $a);
}
$candownload = false;
$cancancel = true;
switch ($status) {
@@ -107,7 +123,7 @@ class my_data_requests_page implements renderable, templatable {
$canceltext = get_string('cancelrequest', 'tool_dataprivacy');
$actions[] = new action_menu_link_secondary($cancelurl, null, $canceltext, $canceldata);
}
if ($candownload) {
if ($candownload && $usercontext) {
$downloadurl = moodle_url::make_pluginfile_url($usercontext->id, 'tool_dataprivacy', 'export', $requestid, '/',
'export.zip', true);
$downloadtext = get_string('download', 'tool_dataprivacy');
@@ -188,6 +188,7 @@ $string['requestfor'] = 'Requesting for';
$string['requeststatus'] = 'Status';
$string['requestsubmitted'] = 'Your request has been submitted to the site\'s Data Protection Officer';
$string['requesttype'] = 'Type';
$string['requesttypeuser'] = '{$a->typename} ({$a->user})';
$string['requesttype_help'] = 'Select the reason why you would like to contact the site\'s Data Protection Officer';
$string['requesttypedelete'] = 'Delete all of my personal data';
$string['requesttypedeleteshort'] = 'Delete';