$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 = context_module::instance($cm->id); require_login($course, false, $cm); require_capability('mod/chat:chat', $context); $PAGE->set_pagelayout('base'); $PAGE->set_popup_notification_allowed(false); /// 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!='') { $chatuser = $DB->get_record('chat_users', array('sid' => $chat_sid)); chat_send_chatmessage($chatuser, $message, 0, $cm); $DB->set_field('chat_users', 'lastmessageping', time(), array('sid'=>$chat_sid)); } 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(format_string($course->shortname), 1); echo $OUTPUT->heading(format_string($chat->name), 2); echo $OUTPUT->heading(get_string('participants'), 3); echo $OUTPUT->box_start('generalbox', 'participants'); echo '
' . get_string('from') . ' | ' . get_string('message', 'message') . ' | ' . get_string('time') . ' |
---|