Reduce code nesting level in task (#237)

Make the code easier to read and understand
This commit is contained in:
mwithheld 2018-10-05 14:31:37 -07:00 committed by Mark Nelson
parent 30f80d70f7
commit 149e3cfc6c

View file

@ -61,7 +61,10 @@ class email_certificate_task extends \core\task\scheduled_task {
WHERE (c.emailstudents = :emailstudents WHERE (c.emailstudents = :emailstudents
OR c.emailteachers = :emailteachers OR c.emailteachers = :emailteachers
OR $emailotherslengthsql >= 3)"; OR $emailotherslengthsql >= 3)";
if ($customcerts = $DB->get_records_sql($sql, array('emailstudents' => 1, 'emailteachers' => 1))) { if (!$customcerts = $DB->get_records_sql($sql, array('emailstudents' => 1, 'emailteachers' => 1))) {
return false;
}
// The renderers used for sending emails. // The renderers used for sending emails.
$htmlrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'htmlemail'); $htmlrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'htmlemail');
$textrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'textemail'); $textrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'textemail');
@ -147,7 +150,10 @@ class email_certificate_task extends \core\task\scheduled_task {
} }
// Now, email the people we need to. // Now, email the people we need to.
if ($issuedusers) { if (!$issuedusers) {
continue;
}
foreach ($issuedusers as $user) { foreach ($issuedusers as $user) {
$userfullname = fullname($user); $userfullname = fullname($user);
@ -226,5 +232,3 @@ class email_certificate_task extends \core\task\scheduled_task {
} }
} }
} }
}
}