Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
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.
8
//
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.
13
//
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/>.
16
 
17
require_once('../../../config.php');
18
require_once('../lib.php');
19
 
20
$id      = required_param('id', PARAM_INT);
21
$groupid = optional_param('groupid', 0, PARAM_INT); // Only for teachers.
22
 
23
$url = new moodle_url('/mod/chat/gui_sockets/index.php', array('id' => $id));
24
if ($groupid !== 0) {
25
    $url->param('groupid', $groupid);
26
}
27
$PAGE->set_url($url);
28
 
29
if (!$chat = $DB->get_record('chat', array('id' => $id))) {
30
    throw new \moodle_exception('invalidid', 'chat');
31
}
32
 
33
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
34
    throw new \moodle_exception('invalidcourseid');
35
}
36
 
37
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
38
    throw new \moodle_exception('invalidcoursemodule');
39
}
40
 
41
require_login($course, false, $cm);
42
$context = context_module::instance($cm->id);
43
require_capability('mod/chat:chat', $context);
44
 
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');
50
        }
51
        $groupname = ': '.$group->name;
52
    } else {
53
        $groupname = ': '.get_string('allparticipants');
54
    }
55
} else {
56
    $groupid = 0;
57
    $groupname = '';
58
}
59
 
60
$strchat = get_string('modulename', 'chat'); // Must be before current_language() in chat_login_user() to force course language!
61
 
62
if (!$chatsid = chat_login_user($chat->id, 'sockets', $groupid, $course)) {
63
    throw new \moodle_exception('cantlogin');
64
}
65
 
66
$params = "chat_sid=$chatsid";
67
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
68
 
69
$chatname = format_string($chat->name, true, array('context' => $context));
70
$winchaturl = "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&amp;$params";
71
$winusersurl = "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&amp;$params"
72
 
73
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
74
<html>
75
 <head>
76
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
77
  <title>
78
   <?php echo "$strchat: " . $courseshortname . ": " . $chatname . "$groupname" ?>
79
  </title>
80
 </head>
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">
86
  </frameset>
87
  <frame src="<?php echo $winusersurl; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
88
 </frameset>
89
 <noframes>
90
  Sorry, this version of Moodle Chat needs a browser that handles frames.
91
 </noframes>
92
</html>