messaging)) { error("Messaging is disabled on this site"); } /// Script parameters $userid = required_param('id', PARAM_INT); $frame = optional_param('frame', '', PARAM_ALPHA); $message = optional_param('message', '', PARAM_CLEAN); $format = optional_param('format', FORMAT_MOODLE, PARAM_INT); $addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact $removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact $blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact $unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact /// Check the user we are talking to is valid if (! $user = get_record("user", "id", $userid)) { error("User ID was incorrect"); } /// Possibly change some contacts if requested if ($addcontact and confirm_sesskey()) { add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact); message_add_contact($addcontact); } if ($removecontact and confirm_sesskey()) { add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact); message_remove_contact($removecontact); } if ($blockcontact and confirm_sesskey()) { add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&user2='.$USER->id, $blockcontact); message_block_contact($blockcontact); } if ($unblockcontact and confirm_sesskey()) { add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&user2='.$USER->id, $unblockcontact); message_unblock_contact($unblockcontact); } /// By default, print frameset to contain all the various panes if (!$frame) { $USER->message_user_refresh[$user->id] = time(); ?>
'.$user->firstname.' ['.$time.']: '. $printmessage.'
'; echo '\n\n"; /// Move the entry to the other table $message->timeread = time(); $message->message = addslashes($message->message); $messageid = $message->id; unset($message->id); if (insert_record('message_read', $message)) { delete_records('message', 'id', $messageid); } } echo '\n\n"; } // Update the info pane, but only if the data there is getting too old $timenow = time(); if ($timenow - $user->lastaccess > $CFG->message_offline_time) { // Offline if ($timenow - $USER->message_user_refresh[$user->id] < 30) { // It's just happened so refresh $USER->message_user_refresh[$user->id] = $timenow - 30; // Prevent it happening again $refreshinfo = true; } } else { // Online if ($timenow - $USER->message_user_refresh[$user->id] > 30) { // Been a while $USER->message_user_refresh[$user->id] = $timenow; // Prevent it happening again $refreshinfo = true; } } if (!empty($refreshinfo)) { echo '\n\n"; } echo '