Reduce code nesting level in task (#237)
Make the code easier to read and understand
This commit is contained in:
parent
30f80d70f7
commit
149e3cfc6c
1 changed files with 145 additions and 141 deletions
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue