notify(get_string('nosenders', 'block_email_list')); $mailform->set_data($form); $mailform->display(); } else { if (!empty($form->send) or !empty($form->draft)) { // Create new eMail $email = new eMail($USER->id, $courseid); // User send mail $email->set_writer($USER->id); $email->set_course($courseid); // Generic URL for send mails errors $baseurl = $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $courseid . '&mailid=' . $form->id . '&subject=\'' . $form->subject . '\'&body=\'' . $form->body . '\''; // Add subject $email->set_subject($form->subject); // Get upload file's $email->set_attachments(isset($_FILES) ? $_FILES : NULL); // If forward or draft mail, can do old attachments $i = 0; $oldattach = 'oldattachment' . $i; if (isset($form->{$oldattach})) { $attachments = array(); while (true) { $oldattachck = $oldattach . 'ck'; // Only add if it is checked if (isset($form->{$oldattachck}) and $form->{$oldattachck}) { $attachments[] = $form->{$oldattach}; } $i++; $oldattach = "oldattachment{$i}"; if (empty($form->{$oldattach})) { break;