@@ -52,39 +52,39 @@ public function execute() {
52
52
}
53
53
// Go through each user that has unread posts.
54
54
foreach ($ users as $ user ) {
55
- $ userdata = $ DB ->get_records ('moodleoverflow_mail_info ' , array ('userid ' => $ user ->userid ), 'courseid, forumid ' ); // order by courseid
55
+ // Sorts the records with "Order by courseid".
56
+ $ userdata = $ DB ->get_records ('moodleoverflow_mail_info ' , array ('userid ' => $ user ->userid ), 'courseid, forumid ' );
56
57
$ mail = array ();
57
- // fill the $mail array.
58
+ // Fill the $mail array.
58
59
foreach ($ userdata as $ row ) {
59
60
$ currentcourse = $ DB ->get_record ('course ' , array ('id ' => $ row ->courseid ), 'fullname, id ' );
60
61
$ currentforum = $ DB ->get_record ('moodleoverflow ' , array ('id ' => $ row ->forumid ), 'name, id ' );
61
62
$ coursemoduleid = get_coursemodule_from_instance ('moodleoverflow ' , $ row ->forumid );
62
63
$ discussion = $ DB ->get_record ('moodleoverflow_discussions ' , array ('id ' => $ row ->forumdiscussionid ), 'name, id ' );
63
64
$ unreadposts = $ row ->numberofposts ;
64
65
65
- // build url to the course, forum, and discussion.
66
+ // Build url to the course, forum, and discussion.
66
67
$ linktocourse = new \moodle_url ('/course/view.php ' , array ('id ' => $ currentcourse ->id ));
67
68
$ linktoforum = new \moodle_url ('/mod/moodleoverflow/view.php ' , array ('id ' => $ coursemoduleid ->id ));
68
69
$ linktodiscussion = new \moodle_url ('/mod/moodleoverflow/discussion.php ' , array ('d ' => $ discussion ->id ));
69
70
70
- // now change the url to a clickable html link.
71
+ // Now change the url to a clickable html link.
71
72
$ linktocourse = \html_writer::link ($ linktocourse ->out (), $ currentcourse ->fullname );
72
73
$ linktoforum = \html_writer::link ($ linktoforum ->out (), $ currentforum ->name );
73
74
$ linktodiscussion = \html_writer::link ($ linktodiscussion ->out (), $ discussion ->name );
74
75
75
- // build a single line string with the digest information and add it to the mailarray.
76
+ // Build a single line string with the digest information and add it to the mailarray.
76
77
$ string = get_string ('digestunreadpost ' , 'mod_moodleoverflow ' , array ('linktocourse ' => $ linktocourse ,
77
78
'linktoforum ' => $ linktoforum ,
78
79
'linktodiscussion ' => $ linktodiscussion ,
79
80
'unreadposts ' => $ unreadposts ));
80
81
array_push ($ mail , $ string );
81
82
}
82
- // build the final message and send it to user. Then remove the sent records.
83
+ // Build the final message and send it to user. Then remove the sent records.
83
84
$ message = implode ('<br> ' , $ mail );
84
85
$ userto = $ DB ->get_record ('user ' , array ('id ' => $ user ->userid ));
85
86
$ from = \core_user::get_noreply_user ();
86
87
$ subject = get_string ('tasksenddailymail ' , 'mod_moodleoverflow ' );
87
- mtrace ($ message );
88
88
email_to_user ($ userto , $ from , $ subject , $ message );
89
89
$ DB ->delete_records ('moodleoverflow_mail_info ' , array ('userid ' => $ user ->userid ));
90
90
}
0 commit comments