Skip to content

Commit 92d0ba3

Browse files
committed
add mailsetting condition for schedule_task/sendmail
1 parent ccd70e2 commit 92d0ba3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,17 +735,23 @@ function moodleoverflow_send_mails() {
735735
}
736736

737737
// Send mails to the users with information about the posts.
738-
if ($users AND $posts) {
738+
if ($users && $posts) {
739739

740740
// Send one mail to every user.
741741
foreach ($users as $userto) {
742-
742+
743743
// Terminate if the process takes more time then two minutes.
744744
core_php_time_limit::raise(120);
745745

746746
// Tracing information.
747747
mtrace('Processing user ' . $userto->id);
748748

749+
// Check if user wants a resume.
750+
$usermailsetting = $DB->get_record('user', array('id' => $userto->id), $fields = 'maildigest');
751+
if($usermailsetting->maildigest != 0) {
752+
mtrace('mailsetting ' . $usermailsetting->maildigest);
753+
continue;
754+
}
749755
// Initiate the user caches to save memory.
750756
$userto = clone($userto);
751757
$userto->ciewfullnames = array();

0 commit comments

Comments
 (0)