mirror of
https://github.com/moodle/moodle.git
synced 2025-04-11 11:23:52 +02:00
Merge branch 'MDL-67846-master' of git://github.com/lameze/moodle
This commit is contained in:
commit
88fb49b657
@ -117,9 +117,11 @@ if ($form->is_cancelled()) {
|
||||
$striphtml = !empty($data->striphtml);
|
||||
$humandates = !empty($data->humandates);
|
||||
|
||||
$fields = ['id', 'discussion', 'parent', 'userid', 'created', 'modified', 'mailed', 'subject', 'message',
|
||||
$fields = ['id', 'discussion', 'parent', 'userid', 'userfullname', 'created', 'modified', 'mailed', 'subject', 'message',
|
||||
'messageformat', 'messagetrust', 'attachment', 'totalscore', 'mailnow', 'deleted', 'privatereplyto',
|
||||
'wordcount', 'charcount'];
|
||||
'privatereplytofullname', 'wordcount', 'charcount'];
|
||||
|
||||
$canviewfullname = has_capability('moodle/site:viewfullnames', $forum->get_context());
|
||||
|
||||
$datamapper = $legacydatamapperfactory->get_post_data_mapper();
|
||||
$exportdata = new ArrayObject($datamapper->to_legacy_objects($posts));
|
||||
@ -132,8 +134,29 @@ if ($form->is_cancelled()) {
|
||||
$dataformat,
|
||||
$fields,
|
||||
$iterator,
|
||||
function($exportdata) use ($fields, $striphtml, $humandates) {
|
||||
$data = $exportdata;
|
||||
function($exportdata) use ($fields, $striphtml, $humandates, $canviewfullname) {
|
||||
$data = new stdClass();
|
||||
|
||||
foreach ($fields as $field) {
|
||||
// Set data field's value from the export data's equivalent field by default.
|
||||
$data->$field = $exportdata->$field ?? null;
|
||||
|
||||
if ($field == 'userfullname') {
|
||||
$user = \core_user::get_user($data->userid);
|
||||
$data->userfullname = fullname($user, $canviewfullname);
|
||||
}
|
||||
|
||||
if ($field == 'privatereplytofullname' && !empty($data->privatereplyto)) {
|
||||
$user = \core_user::get_user($data->privatereplyto);
|
||||
$data->privatereplytofullname = fullname($user, $canviewfullname);
|
||||
}
|
||||
|
||||
// Convert any boolean fields to their integer equivalent for output.
|
||||
if (is_bool($data->$field)) {
|
||||
$data->$field = (int) $data->$field;
|
||||
}
|
||||
}
|
||||
|
||||
if ($striphtml) {
|
||||
// The following call to html_to_text uses the option that strips out
|
||||
// all URLs, but format_text complains if it finds @@PLUGINFILE@@ tokens.
|
||||
@ -147,12 +170,6 @@ if ($form->is_cancelled()) {
|
||||
$data->created = userdate($data->created);
|
||||
$data->modified = userdate($data->modified);
|
||||
}
|
||||
foreach ($fields as $field) {
|
||||
// Convert any boolean fields to their integer equivalent for output.
|
||||
if (is_bool($data->$field)) {
|
||||
$data->$field = (int) $data->$field;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
});
|
||||
die;
|
||||
|
Loading…
x
Reference in New Issue
Block a user