516121bd |
1 | <?php // $Id$ |
2 | |
fbabbd23 |
3 | require_once('../../../config.php'); |
b19cad7f |
4 | require_once('../lib.php'); |
5 | |
516121bd |
6 | $id = required_param('id', PARAM_INT); |
7 | $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers |
b19cad7f |
8 | |
d3bf6f92 |
9 | if (!$chat = $DB->get_record('chat', array('id'=>$id))) { |
5c2f6a7f |
10 | print_error('invalidid', 'chat'); |
b19cad7f |
11 | } |
12 | |
d3bf6f92 |
13 | if (!$course = $DB->get_record('course', array('id'=>$chat->course))) { |
5c2f6a7f |
14 | print_error('invalidcourseid'); |
b19cad7f |
15 | } |
16 | |
fbabbd23 |
17 | if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { |
5c2f6a7f |
18 | print_error('invalidcoursemodule'); |
b19cad7f |
19 | } |
20 | |
ec81373f |
21 | require_login($course->id, false, $cm); |
b19cad7f |
22 | |
23 | if (isguest()) { |
5c2f6a7f |
24 | print_error('noguests', 'chat'); |
b19cad7f |
25 | } |
26 | |
f9a59efa |
27 | if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) { |
296b589e |
28 | echo $OUTPUT->header(); |
516121bd |
29 | notice(get_string("activityiscurrentlyhidden")); |
30 | } |
31 | |
b19cad7f |
32 | /// Check to see if groups are being used here |
a12e11c1 |
33 | if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used |
34 | if ($groupid = groups_get_activity_group($cm)) { |
35 | if (!$group = groups_get_group($groupid, false)) { |
5c2f6a7f |
36 | print_error('invalidgroupid'); |
b19cad7f |
37 | } |
38 | $groupname = ': '.$group->name; |
39 | } else { |
40 | $groupname = ': '.get_string('allparticipants'); |
41 | } |
42 | } else { |
516121bd |
43 | $groupid = 0; |
b19cad7f |
44 | $groupname = ''; |
45 | } |
46 | |
475bd5cb |
47 | $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!! |
48 | |
516121bd |
49 | if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) { |
5c2f6a7f |
50 | print_error('cantlogin'); |
b19cad7f |
51 | } |
52 | |
e7fbd0b3 |
53 | $params = "chat_sid=$chat_sid"; |
516121bd |
54 | |
1515a89e |
55 | ?> |
b19cad7f |
56 | |
1515a89e |
57 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> |
58 | <html> |
59 | <head> |
810944af |
60 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
1515a89e |
61 | <title> |
6ba65fa0 |
62 | <?php echo "$strchat: " . format_string($course->shortname) . ": ".format_string($chat->name,true)."$groupname" ?> |
1515a89e |
63 | </title> |
64 | </head> |
b19cad7f |
65 | <frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1"> |
516121bd |
66 | <frameset rows="0,*,50" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1"> |
1f8abb89 |
67 | <frame src="../empty.php" name="empty" scrolling="auto" noresize marginwidth="2" marginheight="0"> |
68 | <frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&$params"; ?>" scrolling="auto" name="msg" noresize marginwidth="2" marginheight="0"> |
b19cad7f |
69 | <frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1"> |
1515a89e |
70 | </frameset> |
e2b5964e |
71 | <frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&$params"; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5"> |
1515a89e |
72 | </frameset> |
73 | <noframes> |
b19cad7f |
74 | Sorry, this version of Moodle Chat needs a browser that handles frames. |
1515a89e |
75 | </noframes> |
76 | </html> |