Skip to content

Commit 0702bd3

Browse files
authored
Merge pull request #214 from learnweb/fix/anonymousmail
Hotfix for anonymous Mail
2 parents 568997d + 9975ead commit 0702bd3

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

CHANGES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
4.5.1 (2025-05-19)
5+
------------------
6+
[HOTFIX] #214
7+
48
4.5.0 (2025-05-06)
59
------------------
6-
* Moodle 4.5 compatible version
10+
* Moodle 4.5 compatible version

classes/output/moodleoverflow_email.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public function get_discussionname() {
358358
* @return string
359359
*/
360360
public function get_author_fullname() {
361-
if (anonymous::is_post_anonymous($this->discussion, $this->moodleoverflow, $this->author->id)) {
361+
if ($this->author->anonymous) {
362362
return get_string('privacy:anonym_user_name', 'mod_moodleoverflow');
363363
} else {
364364
return fullname($this->author, $this->viewfullnames);
@@ -521,7 +521,7 @@ public function get_moodleoverflowviewlink() {
521521
* @return string
522522
*/
523523
public function get_authorlink() {
524-
if (anonymous::is_post_anonymous($this->discussion, $this->moodleoverflow, $this->author->id)) {
524+
if ($this->author->anonymous) {
525525
return null;
526526
}
527527

@@ -542,7 +542,7 @@ public function get_authorlink() {
542542
*/
543543
public function get_author_picture() {
544544
global $OUTPUT;
545-
if (anonymous::is_post_anonymous($this->discussion, $this->moodleoverflow, $this->author->id)) {
545+
if ($this->author->anonymous) {
546546
return '';
547547
}
548548

@@ -555,7 +555,7 @@ public function get_author_picture() {
555555
* @return string
556556
*/
557557
public function get_group_picture() {
558-
if (anonymous::is_post_anonymous($this->discussion, $this->moodleoverflow, $this->author->id)) {
558+
if ($this->author->anonymous) {
559559
return '';
560560
}
561561

classes/task/send_mails.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
namespace mod_moodleoverflow\task;
2626

2727
use core\session\exception;
28+
use mod_moodleoverflow\anonymous;
2829
use mod_moodleoverflow\output\moodleoverflow_email;
2930

3031
defined('MOODLE_INTERNAL') || die();
@@ -122,6 +123,7 @@ public function send_review_notifications() {
122123

123124
$post = $postinfo;
124125
$userfrom = \core_user::get_user($postinfo->userid, '*', MUST_EXIST);
126+
$userfrom->anonymous = anonymous::is_post_anonymous($discussion, $moodleoverflow, $postinfo->userid);
125127

126128
foreach ($usersto as $userto) {
127129
try {

externallib.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424

25+
use mod_moodleoverflow\anonymous;
2526
use mod_moodleoverflow\output\moodleoverflow_email;
2627
use mod_moodleoverflow\review;
2728

@@ -121,7 +122,7 @@ public static function record_vote($postid, $ratingid) {
121122
$ownerrating = \mod_moodleoverflow\ratings::moodleoverflow_get_reputation($moodleoverflow->id, $postownerid);
122123
$raterrating = \mod_moodleoverflow\ratings::moodleoverflow_get_reputation($moodleoverflow->id, $USER->id);
123124

124-
$cannotseeowner = \mod_moodleoverflow\anonymous::is_post_anonymous($discussion, $moodleoverflow, $USER->id) &&
125+
$cannotseeowner = anonymous::is_post_anonymous($discussion, $moodleoverflow, $USER->id) &&
125126
$USER->id != $postownerid;
126127

127128
$params['postrating'] = $rating->upvotes - $rating->downvotes;
@@ -254,6 +255,7 @@ public static function review_reject_post($postid, $reason = null) {
254255
$renderertext = $PAGE->get_renderer('mod_moodleoverflow', 'email', 'textemail');
255256

256257
$userto = core_user::get_user($post->userid);
258+
$userto->anonymous = anonymous::is_post_anonymous($discussion, $moodleoverflow, $post->userid);
257259

258260
$maildata = new moodleoverflow_email(
259261
$course,

lib.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,17 +820,20 @@ function moodleoverflow_send_mails() {
820820

821821
if (\mod_moodleoverflow\anonymous::is_post_anonymous($discussion, $moodleoverflow, $post->userid)) {
822822
$userfrom = \core_user::get_noreply_user();
823+
$userfrom->anonymous = true;
823824
} else {
824825
// Check whether the sending user is cached already.
825826
if (array_key_exists($post->userid, $users)) {
826827
$userfrom = $users[$post->userid];
828+
$userfrom->anonymous = false;
827829
} else {
828830
// We dont know the the user yet.
829831

830832
// Retrieve the user from the database.
831833
$userfrom = $DB->get_record('user', ['id' => $post->userid]);
832834
if ($userfrom) {
833835
moodleoverflow_minimise_user_record($userfrom);
836+
$userfrom->anonymous = false;
834837
} else {
835838
$uid = $post->userid;
836839
$pid = $post->id;
@@ -1093,7 +1096,7 @@ function moodleoverflow_mark_old_posts_as_mailed($endtime) {
10931096
*
10941097
* @param stdClass $user
10951098
*/
1096-
function moodleoverflow_minimise_user_record(stdClass $user) {
1099+
function moodleoverflow_minimise_user_record(stdClass &$user) {
10971100

10981101
// Remove all information for the mail generation that are not needed.
10991102
unset($user->institution);

templates/email_text.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
{{{ coursename }}} -> {{#str}} moodleoverflows, moodleoverflow {{/str}} -> {{{ moodleoverflowname }}}{{#showdiscussionname}} -> {{{ discussionname }}} {{/showdiscussionname}}
7373
{{ permalink }}
7474
{{{ subject }}}
75-
{{#str}} bynameondate, moodleoverflow, {
75+
{{#str}} bynameondatenorating, moodleoverflow, {
7676
"name": {{#quote}}{{{ authorfullname }}}{{/quote}},
7777
"date": {{#quote}}{{ postdate }}{{/quote}}
7878
} {{/str}}

version.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
defined('MOODLE_INTERNAL') || die();
2929

3030
$plugin->component = 'mod_moodleoverflow';
31-
$plugin->version = 2025050600;
32-
$plugin->requires = 2022112800;
33-
$plugin->release = 'v4.5-r1';
31+
$plugin->version = 2025050601;
32+
$plugin->requires = 2022112800;
33+
$plugin->release = 'v4.5-r2';
3434
$plugin->supported = [401, 405];
3535
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)