Reduce code nesting level in task (#237)
Make the code easier to read and understand
This commit is contained in:
parent
810bc2d3fd
commit
3e2e9c9c8b
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
|
||||
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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue