Skip to content

Commit

Permalink
add attributes from postletter
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed May 16, 2024
1 parent 84cf7b9 commit 5522f22
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion classes/moodleoverflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use local_townsquaresupport\townsquaresupportinterface;
use mod_moodleoverflow\anonymous;
use moodle_url;

global $CFG;
require_once($CFG->dirroot . '/blocks/townsquare/locallib.php');
Expand Down Expand Up @@ -73,10 +74,23 @@ public static function get_events(): array {
if ($event->anonymoussetting == anonymous::EVERYTHING_ANONYMOUS) {
$event->anonymous = true;
} else if ($event->anonymoussetting == anonymous::QUESTION_ANONYMOUS) {
$event->anonymous = $event->postuserid == $event->discussionuserid;
$event->anonymous = $event->postuserid == $event->discussionuserid;
} else {
$event->anonymous = false;
}

// If the post is anonymous, make the author anonymous.
if ($event->anonymous) {
$event->postuserfirstname = 'anonymous';
$event->postuserlastname = '';
$event->postuserid = -1;
}

// Add links.
$event->linktopost = new moodle_url('/mod/moodleoverflow/discussion.php',
['d' => $event->postdiscussion], 'p' . $event->postid);
$event->linktoauthor = $event->anonymous ? new moodle_url('') :
new moodle_url('/user/view.php', ['id' => $event->postuserid]);
}

return $moodleoverflowevents;
Expand Down

0 comments on commit 5522f22

Please sign in to comment.