Skip to content

Commit

Permalink
Hide author of files in anonymous posts
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Jan 16, 2024
1 parent 867cfa4 commit adf4ad1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,14 @@
empty($post->id) ? null : $post->id,
mod_moodleoverflow_post_form::attachment_options($moodleoverflow));

if ($draftitemid && $edit && \mod_moodleoverflow\anonymous::is_post_anonymous($discussion, $moodleoverflow, $post->userid) && $post->userid != $USER->id) {
$usercontext = context_user::instance($USER->id);
$anonymousstr = get_string('anonymous', 'moodleoverflow');
foreach (get_file_storage()->get_area_files($usercontext->id, 'user', 'draft', $draftitemid) as $file) {
$file->set_author($anonymousstr);
}
}

// Prepare the form.
$formarray = array(
'course' => $course,
Expand Down

0 comments on commit adf4ad1

Please sign in to comment.