course)) { error('Could not find the course this belongs to!'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { error('Course Module ID was incorrect'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_login($course->id, false, $cm); require_capability('mod/chat:chat',$context); /// Check to see if groups are being used here if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid, false)) { error("That group (id $groupid) doesn't exist!"); } $groupname = ': '.$group->name; } else { $groupname = ': '.get_string('allparticipants'); } } else { $groupid = 0; $groupname = ''; } $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!! $strchats = get_string('modulenameplural', 'chat'); $stridle = get_String('idle', 'chat'); if (!$chat_sid = chat_login_user($chat->id, 'basic', $groupid, $course)) { error('Could not log in to chat room!!'); } if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) { print_error('errornousers', 'chat'); } set_field('chat_users', 'lastping', time(), 'sid', $chat_sid); if (!isset($SESSION->chatprefs)) { $SESSION->chatprefs = array(); } if (!isset($SESSION->chatprefs[$chat->id])) { $SESSION->chatprefs[$chat->id] = array(); $SESSION->chatprefs[$chat->id]['chatentered'] = time(); } $chatentered = $SESSION->chatprefs[$chat->id]['chatentered']; $refreshedmessage = ''; if (!empty($refresh) and data_submitted()) { $refreshedmessage = $message; chat_delete_old_users(); } else if (empty($refresh) and data_submitted() and confirm_sesskey()) { if ($message!='') { $newmessage = new object(); $newmessage->chatid = $chat->id; $newmessage->userid = $USER->id; $newmessage->groupid = $groupid; $newmessage->systrem = 0; $newmessage->message = $message; $newmessage->timestamp = time(); if (!insert_record('chat_messages', $newmessage)) { error('Could not insert a chat message!'); } set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid); add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id); } chat_delete_old_users(); redirect('index.php?id='.$id.'&newonly='.$newonly.'&last='.$last); } print_header("$strchat: $course->shortname: ".format_string($chat->name,true)."$groupname", '', '', 'message'); echo '
'; echo '

'.get_string('participants').'

'; echo '
'; echo '
'; echo '
'; $usehtmleditor = can_use_html_editor(); echo '

'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ' '; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo '

'.get_string('messages', 'chat').'

'; $allmessages = array(); $options = new object(); $options->para = false; $options->newlines = true; if ($newonly) { $lastsql = "AND timestamp > $last"; } else { $lastsql = ""; } $groupselect = $groupid ? "AND (groupid='$groupid' OR groupid='0')" : ""; $messages = get_records_select("chat_messages", "chatid = '$chat->id' AND timestamp > $chatentered $lastsql $groupselect", "timestamp DESC"); if ($messages) { foreach ($messages as $message) { $allmessages[] = chat_format_message($message, $course->id, $USER); } } if (empty($allmessages)) { echo get_string('nomessagesfound', 'message'); } else { foreach ($allmessages as $message) { echo $message->basic; } } echo '
'; print_footer('none'); ?>