if ($mform->is_submitted()) { // check the validation rules if ($mform->is_validated()) { //get the form data submitted $formdata = $mform->get_data(); // process the data $success = $mform->process_data($formdata); //if saving the data was not successful if (!$success) { //print an error message print_error('commentcreationerror', 'block_ilp'); } if (!isset($formdata->saveanddisplaybutton)) { //notify the user that a comment has been made on one of their report entries if ($USER->id != $entry->user_id) { $reportsviewtab = $dbc->get_tab_plugin_by_name('ilp_dashboard_reports_tab'); $reportstaburl = !empty($reportsviewtab) ? "&selectedtab={$reportsviewtab->id}&tabitem={$reportsviewtab->id}:{$report->id}" : ""; $message = new stdClass(); $message->component = 'block_ilp'; $message->name = 'ilp_comment'; $message->subject = get_string('newreportcomment', 'block_ilp', $report); $message->userfrom = $dbc->get_user_by_id($USER->id); $message->userto = $dbc->get_user_by_id($entry->user_id); $message->fullmessage = get_string('newreportcomment', 'block_ilp', $report); $message->fullmessageformat = FORMAT_PLAIN; $message->contexturl = $CFG->wwwroot . "/blocks/ilp/actions/view_main.php?user_id={$entry->user_id}{$reportstaburl}"; $message->contexturlname = get_string('viewreport', 'block_ilp'); if (stripos($CFG->release, "2.") !== false) { message_send($message); } else { require_once $CFG->dirroot . '/message/lib.php';