$id)); if ($groupid !== 0) { $url->param('groupid', $groupid); } $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); /// 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!!! if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) { print_error('cantlogin', 'chat'); } $params = "chat_id=$id&chat_sid={$chat_sid}"; // fallback to the old jsupdate, but allow other update modes $updatemode = 'jsupdate'; if (!empty($CFG->chat_normal_updatemode)) { $updatemode = $CFG->chat_normal_updatemode; } $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); ?>