redirect(new moodle_url('/course/view.php?id=' . $courseid)); // DWE we should check if we have selected users or emails around here. } else { if ($data = $form->get_data()) { if (empty($data->subject)) { $warnings[] = get_string('no_subject', 'block_quickmail'); } if (empty($data->mailto) && empty($data->additional_emails)) { $warnings[] = get_string('no_users', 'block_quickmail'); } if (empty($warnings)) { // Submitted data ////////////////////////////////////////////////////// $data->time = time(); $data->format = $data->message_editor['format']; $data->message = $data->message_editor['text']; $data->attachment = quickmail::attachment_names($data->attachments); $data->messageWithSigAndAttach = ""; // Store data; id is needed for file storage /////////////////////////// if (isset($data->send)) { $data->id = $DB->insert_record('block_quickmail_log', $data); $table = 'log'; } else { if (isset($data->draft)) { $table = 'drafts'; if (!empty($typeid) and $type == 'drafts') { $data->id = $typeid; $DB->update_record('block_quickmail_drafts', $data); } else { $data->id = $DB->insert_record('block_quickmail_drafts', $data); } }