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 988af1c457
commit 255743f9e0

View file

@ -61,7 +61,10 @@ class email_certificate_task extends \core\task\scheduled_task {
WHERE (c.emailstudents = :emailstudents
OR c.emailteachers = :emailteachers
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.
$htmlrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'htmlemail');
$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.
if ($issuedusers) {
if (!$issuedusers) {
continue;
}
foreach ($issuedusers as $user) {
$userfullname = fullname($user);
@ -226,5 +232,3 @@ class email_certificate_task extends \core\task\scheduled_task {
}
}
}
}
}