$id)); if ($groupid !== 0) { $url->param('groupid', $groupid); } if ($message !== 0) { $url->param('message', $message); } if ($refresh !== 0) { $url->param('refresh', $refresh); } if ($last !== 0) { $url->param('last', $last); } if ($newonly !== 0) { $url->param('newonly', $newonly); } $PAGE->set_url($url); if (!$chat = $DB->get_record('chat', array('id'=>$id))) { print_error('invalidid', 'chat'); } if (!$course = $DB->get_record('course', array('id'=>$chat->course))) { print_error('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { print_error('invalidcoursemodule'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_login($course->id, false, $cm); require_capability('mod/chat:chat', $context); $PAGE->set_pagelayout('base'); $PAGE->set_popup_notification_allowed(false); // No popup notifications in the chat window /// 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)) { print_error('invalidgroupid'); } $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)) { print_error('cantlogin', 'chat'); } if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) { print_error('errornousers', 'chat'); } $DB->set_field('chat_users', 'lastping', time(), array('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 stdClass(); $newmessage->chatid = $chat->id; $newmessage->userid = $USER->id; $newmessage->groupid = $groupid; $newmessage->systrem = 0; $newmessage->message = $message; $newmessage->timestamp = time(); $DB->insert_record('chat_messages', $newmessage); $DB->insert_record('chat_messages_current', $newmessage); $DB->set_field('chat_users', 'lastmessageping', time(), array('sid'=>$chat_sid)); add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id); } chat_delete_old_users(); $url = new moodle_url('/mod/chat/gui_basic/index.php', array('id'=>$id, 'newonly'=>$newonly, 'last'=>$last)); redirect($url); } $PAGE->set_title("$strchat: $course->shortname: ".format_string($chat->name,true)."$groupname"); echo $OUTPUT->header(); echo $OUTPUT->container_start(null, 'page-mod-chat-gui_basic'); echo $OUTPUT->heading(get_string('participants'), 2, 'mdl-left'); echo $OUTPUT->box_start('generalbox', 'participants'); echo '