2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 require_once('../../../config.php');
18 require_once('../lib.php');
20 $id = required_param('id', PARAM_INT
);
21 $groupid = optional_param('groupid', 0, PARAM_INT
); // Only for teachers.
23 $url = new moodle_url('/mod/chat/gui_sockets/index.php', array('id' => $id));
25 $url->param('groupid', $groupid);
29 if (!$chat = $DB->get_record('chat', array('id' => $id))) {
30 throw new \
moodle_exception('invalidid', 'chat');
33 if (!$course = $DB->get_record('course', array('id' => $chat->course
))) {
34 throw new \
moodle_exception('invalidcourseid');
37 if (!$cm = get_coursemodule_from_instance('chat', $chat->id
, $course->id
)) {
38 throw new \
moodle_exception('invalidcoursemodule');
41 require_login($course, false, $cm);
42 $context = context_module
::instance($cm->id
);
43 require_capability('mod/chat:chat', $context);
45 // Check to see if groups are being used here
46 if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
47 if ($groupid = groups_get_activity_group($cm)) {
48 if (!$group = groups_get_group($groupid)) {
49 throw new \
moodle_exception('invalidgroupid');
51 $groupname = ': '.$group->name
;
53 $groupname = ': '.get_string('allparticipants');
60 $strchat = get_string('modulename', 'chat'); // Must be before current_language() in chat_login_user() to force course language!
62 if (!$chatsid = chat_login_user($chat->id
, 'sockets', $groupid, $course)) {
63 throw new \
moodle_exception('cantlogin');
66 $params = "chat_sid=$chatsid";
67 $courseshortname = format_string($course->shortname
, true, array('context' => context_course
::instance($course->id
)));
69 $chatname = format_string($chat->name
, true, array('context' => $context));
70 $winchaturl = "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&$params";
71 $winusersurl = "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&$params"
73 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
76 <meta http
-equiv
="content-type" content
="text/html; charset=utf-8" />
78 <?php
echo "$strchat: " . $courseshortname . ": " . $chatname . "$groupname" ?
>
81 <frameset cols
="*,200" border
="5" framespacing
="no" frameborder
="yes" marginwidth
="2" marginheight
="1">
82 <frameset rows
="0,*,70" border
="0" framespacing
="no" frameborder
="no" marginwidth
="2" marginheight
="1">
83 <frame src
="../empty.php" name
="empty" scrolling
="auto" noresize marginwidth
="2" marginheight
="0">
84 <frame src
="<?php echo $winchaturl; ?>" scrolling
="auto" name
="msg" noresize marginwidth
="2" marginheight
="0">
85 <frame src
="chatinput.php?<?php echo $params ?>" name
="input" scrolling
="no" marginwidth
="2" marginheight
="1">
87 <frame src
="<?php echo $winusersurl; ?>" name
="users" scrolling
="auto" marginwidth
="5" marginheight
="5">
90 Sorry
, this version of Moodle Chat needs a browser that handles frames
.