mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
index.php
85 lines (69 loc) · 3.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require_once('../../../config.php');
require_once('../lib.php');
$id = required_param('id', PARAM_INT);
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
$url = new moodle_url('/mod/chat/gui_header_js/index.php', array('id'=>$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 = context_module::instance($cm->id);
require_login($course, 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' => context_course::instance($course->id)));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>
<?php echo "$strchat: " . $courseshortname . ": " . format_string($chat->name, true, array('context' => $context)) . "$groupname" ?>
</title>
</head>
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
<frameset rows="0,0,*,50" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
<frame src="../empty.php" name="empty" scrolling="no" marginwidth="0" marginheight="0">
<frame src="<?php echo $updatemode ?>.php?<?php echo $params ?>" name="jsupdate" scrolling="no" marginwidth="0" marginheight="0">
<frame src="chatmsg.php?<?php echo $params ?>" name="msg" scrolling="auto" marginwidth="2" marginheight="1">
<frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
</frameset>
<frame src="users.php?<?php echo $params ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
</frameset>
<noframes>
Sorry, this version of Moodle Chat needs a browser that handles frames.
</noframes>
</html>