wwwroot); } if (empty($CFG->messaging)) { error("Messaging is disabled on this site"); } /// Don't use print_header, for more speed $stylesheetshtml = ''; foreach ($CFG->stylesheets as $stylesheet) { $stylesheetshtml .= ''; } echo '
'; echo $stylesheetshtml; /// Script parameters $userid = required_param('id', PARAM_INT); $message = optional_param('message', '', PARAM_CLEANHTML); $format = optional_param('format', FORMAT_MOODLE, PARAM_INT); /// Check the user we are talking to is valid if (! $user = get_record('user', 'id', $userid)) { error("User ID was incorrect"); } /// Check that the user is not blocking us!! if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) { if ($contact->blocked and !isadmin()) { print_heading(get_string('userisblockingyou', 'message')); exit; } } if ($message and confirm_sesskey()) { /// Current user has just sent a message /// Save it to the database... $messageid = message_post_message($USER, $user, addslashes($message), $format, 'direct'); /// Format the message as HTML $options = NULL; $options->para = false; $options->newlines = true; $message = format_text($message, $format, $options, 0); $message = str_replace("\r", ' ', $message); $message = str_replace("\n", ' ', $message); $time = userdate(time(), get_string('strftimedaytime')); $message = ' '; $message = addslashes($message); // So Javascript can write it $message = str_replace('', '<\/', $message); // XHTML compliance /// Then write it to our own message screen immediately echo "\n\n\n"; $date = usergetdate($message->timecreated); $datestring = $date['year'].$date['mon'].$date['mday']; add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&user2='.$USER->id.'#m'.$messageid, $user->id); } echo ''; echo ''; echo ' '. '