$url = new moodle_url('/local/mail/create.php'); local_mail_setup_page($course, $url); $context = context_course::instance($course->id); // Create message if ($course->id != $SITE->id and has_capability('local/mail:usemail', $context)) { require_sesskey(); $message = local_mail_message::create($USER->id, $course->id); if ($recipients) { local_mail_add_recipients($message, explode(',', $recipients), $role); } else { if (local_mail_valid_recipient($recipient)) { $message->add_recipient('to', $recipient); } } $params = array('m' => $message->id()); $url = new moodle_url('/local/mail/compose.php', $params); redirect($url); } // Setup form $courses = local_mail_get_my_courses(); $customdata = array('courses' => $courses); $mform = new local_mail_create_form($url, $customdata); $mform->get_data(); // Display page echo $OUTPUT->header(); if ($courses) { $mform->display(); } else { echo $OUTPUT->notification(get_string('cannotcompose', 'local_mail')); } echo $OUTPUT->footer();
require_sesskey(); $message = local_mail_message::create($USER->id, $course->id); if ($recipients) { local_mail_add_recipients($message, explode(',', $recipients), $role); } else if (local_mail_valid_recipient($recipient)) { $message->add_recipient('to', $recipient); } $params = array('m' => $message->id()); $url = new moodle_url('/local/mail/compose.php', $params); redirect($url); } // Setup form $courses = local_mail_get_my_courses(); $customdata = array('courses' => $courses); $mform = new local_mail_create_form($url, $customdata); //$mform->get_data(); // Display page echo $OUTPUT->header(); if ($courses) { $mform->display(); } else { echo $OUTPUT->notification(get_string('cannotcompose', 'local_mail')); } //} echo $OUTPUT->footer();