wwwroot); } if (empty($CFG->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_CLEANHTML); $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(); ?> <?php echo get_string('discussion', 'message').': '.fullname($user) ?> Sorry, but support for Frames is required to use Messaging '; echo ''; echo print_user_picture($user->id, SITEID, $user->picture, true, true, true, 'userwindow').''; echo ''; echo fullname($user); echo '
'; /// Print login status of this user if ($user->lastaccess) { if (time() - $user->lastaccess > $CFG->message_offline_time) { echo get_string('offline', 'message').': '.format_time(time() - $user->lastaccess); } else { echo get_string('lastaccess').': '.get_string('ago', 'message', format_time(time() - $user->lastaccess)); } } else { echo get_string("lastaccess").":". get_string("never"); } echo ''; echo '
'; echo '
'; if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) { if ($contact->blocked) { message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id.'&frame=info'); echo " "; message_contact_link($user->id, 'unblock', false, 'user.php?id='.$user->id.'&frame=info'); echo " "; } else { message_contact_link($user->id, 'remove', false, 'user.php?id='.$user->id.'&frame=info'); echo " "; message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id.'&frame=info'); echo " "; } } else { message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id.'&frame=info'); echo " "; message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id.'&frame=info'); echo " "; } message_history_link($user->id, 0, false, '', '', 'icon'); echo '
'; echo ''; echo ''; // Close possible theme tables off break; case 'messages': /// Print the main frame containing the current chat echo ''; echo ''; break; case 'refresh': /// Print the main frame containing the current chat $stylesheetshtml = ''; foreach ($CFG->stylesheets as $stylesheet) { $stylesheetshtml .= ''; } header("Expires: Sun, 28 Dec 1997 09:32:45 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-Type: text/html"); header("Refresh: $CFG->message_chat_refresh; url=user.php?id=$user->id&frame=refresh"); echo ''."\n"; echo ' '; echo ''."\n"; echo ''."\n"; echo ''."\n"; if (!empty($playbeep)) { echo ''; } sleep($CFG->message_chat_refresh); // Javascript for Mozilla to cope with the redirect bug from editor being on in this page echo ''."\n"; echo ''."\n"; echo ''."\n"; break; case 'edit': /// Print the bottom frame with the text editor /// 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 = '
'.fullname($USER).' '. '['.$time.']: '. ''.$message.'
'; $message = addslashes($message); // So Javascript can write it $message = str_replace('\n"; $script .= "parent.messages.document.write('".$message."\\n');\n"; $script .= "parent.messages.scroll(1,5000000);\n"; $script .= "\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); } else { $script = ''; } print_header('','','','',$script,false,'','',false,''); echo '
'; echo '
'; echo ''; echo ''; echo ''; $usehtmleditor = (can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0)); if ($usehtmleditor) { echo '
'; print_textarea($usehtmleditor, 8, 34, 0, 0, 'message', ''); echo '
'; use_html_editor('message', 'formatblock subscript superscript copy cut paste clean undo redo justifyleft justifycenter justifyright justifyfull lefttoright righttoleft insertorderedlist insertunorderedlist outdent indent forecolor hilitecolor inserthorizontalrule createanchor nolink inserttable'); echo ''; } else { print_textarea(false, 5, 34, 0, 0, 'message', ''); echo ''; } echo '
'; echo '
'; echo '
'; break; } ?>