MDL-8323 finished full conversion to proper $COURSE global - no more $CFG->coursethem...
[moodle.git] / mod / chat / gui_sockets / chatinput.php
CommitLineData
03f5a0f8 1<?php // $Id$
2
3 $nomoodlecookie = true; // Session not needed!
4
5 require('../../../config.php');
6 require('../lib.php');
7
8 $chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
9
10 if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
11 error('Not logged in!');
12 }
13
9152fc99 14 //Get the user theme
15 $USER = get_record('user', 'id', $chatuser->userid);
16
17 //Setup course, lang and theme
18 course_setup($chatuser->course);
03f5a0f8 19
20 ob_start();
21 ?>
22<script type="text/javascript">
23<!--
24
25scroll_active = true;
26function empty_field_and_submit() {
27 var cf = document.getElementById('sendform');
28 var inpf = document.getElementById('inputform');
29 cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
30 cf.chat_message.value = inpf.chat_message.value;
31 inpf.chat_message.value='';
32 cf.submit();
33 inpf.chat_message.focus();
34 return false;
35}
36function prepareusers() {
37 var frm = window.parent.frames;
38 for(i = 0; i < frm.length; ++i) {
39 if(frm[i].name == "users") {
40 window.userFrame = frm[i];
41 window.userHREF = frm[i].location.href;
42 window.setTimeout("reloadusers();", <?php echo $CFG->chat_refresh_userlist; ?> * 1000);
43 }
44 }
45}
46function reloadusers() {
47 if(window.userFrame) {
48 window.userFrame.location.href = window.userFrame.location.href;
49 window.setTimeout("reloadusers();", <?php echo $CFG->chat_refresh_userlist; ?> * 1000);
50 }
51}
52// -->
53</script>
54 <?php
55
56 $meta = ob_get_clean();
57 // TODO: there will be two onload in body tag, does it matter?
58 print_header('', '', '', 'inputform.chat_message', $meta, false, '&nbsp;', '', false, 'onload="setfocus(); prepareusers();"');
59
60?>
61
62 <form action="../empty.php" method="get" target="empty" id="inputform"
63 onsubmit="return empty_field_and_submit();">
64 &gt;&gt;<input type="text" name="chat_message" size="60" value="" />
65 <?php helpbutton("chatting", get_string("helpchatting", "chat"), "chat", true, false); ?>
66 </form>
67
68 <form action="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport/"; ?>" method="get" target="empty" id="sendform">
69 <input type="hidden" name="win" value="message" />
70 <input type="hidden" name="chat_message" value="" />
71 <input type="hidden" name="chat_msgidnr" value="0" />
72 <input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
73 </form>
74</body>
75
76</html>