]> git.mjollnir.org Git - moodle.git/commitdiff
New versions for socket-based chat
authormoodler <moodler>
Fri, 30 Jul 2004 15:33:52 +0000 (15:33 +0000)
committermoodler <moodler>
Fri, 30 Jul 2004 15:33:52 +0000 (15:33 +0000)
mod/chat/gui_sockets/chatinput.php
mod/chat/gui_sockets/index.php

index 354486fac6fb43a519ec73295012e1829d5fb051..01d5f1dd3f565fd4998187e460d6be1c7dfbcc3b 100644 (file)
@@ -1,36 +1,75 @@
 <?php
 
-include("../config.inc.php");
-include("../functions.inc.php");
-include("../filter.inc.php");
-
-if ($arsc_my = arsc_getdatafromsid($arsc_sid))
-{
- include("../shared/language/".$arsc_my["language"].".inc.php");
- if ($arsc_my["level"] >= 0)
- {
-  echo $arsc_parameters["htmlhead_msginput_js"];
-  ?>
-    <form action="../shared/chatins.php" method="GET" target="empty" name="f" OnSubmit="return empty_field_and_submit()">
-     <input type="text" name="arsc_message" size="50" maxlength="<?php echo $arsc_parameters["input_maxsize"]; ?>" value="<?php echo $arsc_pretext; ?>">
-    </form>
-    <form action="../shared/chatins.php" method="GET" target="empty" name="fdummy" OnSubmit="return empty_field_and_submit()">
-     <input type="hidden" name="arsc_sid" value="<?php echo $arsc_sid; ?>">
-     <input type="hidden" name="arsc_chatversion" value="sockets">
-     <input type="hidden" name="arsc_message">
-    </form>
-   </body>
-  </html>
-  <?php
- }
- else
- {
-  echo $arsc_htmlhead_out;
- }
+require("../../../config.php");
+require("../lib.php");
+
+require_variable($chat_sid);
+optional_variable($groupid);
+
+if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
+    echo "Not logged in!";
+    die;
 }
-else
-{
- echo $arsc_htmlhead_out;
+
+if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
+    error("No chat found");
+}
+
+require_login($chat->course);
+optional_variable($chat_pretext, '');
+
+?>
+
+<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
+<html>
+<head>
+<title>Message Input</title>
+
+<?php include("$CFG->javascript"); ?>
+
+<script language="Javascript">
+<!--
+scroll_active = true;
+function empty_field_and_submit() {
+    cf = document.getElementById('chatform');
+    cf.chat_message.value=document.f.chat_message.value;
+    cf.submit();
+    document.f.chat_message.value='';
+    document.f.chat_message.focus();
+    return false;
 }
-?>
\ No newline at end of file
+// -->
+</script>
+</head>
+
+<body bgcolor="<?php echo $THEME->body ?>"
+      OnLoad="document.f.chat_message.focus();document.f.chat_message.select();">
+
+
+
+<!--
+<form action="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport"; ?>" method="GET" target="empty" name="f" onsubmit="return empty_field_and_submit()">
+-->
+<form action="../insert.php" method="GET" target="empty" name="f" onsubmit="return empty_field_and_submit()">
+
+&gt;&gt;<input type="text" name="chat_message" size="60" value="<?php echo $chat_pretext; ?>">
+<?php helpbutton("chatting", get_string("helpchatting", "chat"), "chat", true, false); ?>
+</form>
+
+
+
+<form action="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport/"; ?>" method="GET" target="empty" id="chatform">
+<!--
+<form action="../insert.php" method="GET" target="empty" id="chatform" onsubmit="return empty_field_and_submit()">
+-->
+    <input type="hidden" name="win" value="message">
+    <input type="hidden" name="chat_version" value="sockets">
+    <input type="hidden" name="chat_message">
+    <input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>">
+    <input type="hidden" name="groupid" value="<?php echo $groupid ?>">
+</form>
+
+</body>
+
+</html>
+
index aae09dc209ae5731175e0ea6031b0923d9f1ce92..e3ea7c5c93f2f6deab4c73c97f3ac6a94a1200a4 100644 (file)
@@ -1,26 +1,77 @@
 <?php
-include("../config.inc.php");
-include("../functions.inc.php");
+require_once('../../../config.php');
+    require_once('../lib.php');
+
+    require_variable($id);
+    optional_variable($groupid, -1);
+
+    if (!$chat = get_record("chat", "id", $id)) {
+        error("Could not find that chat room!");
+    }
+
+    if (!$course = get_record("course", "id", $chat->course)) {
+        error("Could not find the course this belongs to!");
+    }
+
+    if (!$cm = get_coursemodule_from_instance("chat", $chat->id, $course->id)) {
+        error("Course Module ID was incorrect");
+    }
+
+    require_login($course->id);
+
+    if (isguest()) {
+        error("Guest does not have access to chat rooms");
+    }
+
+/// Check to see if groups are being used here
+    if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
+        if ($currentgroup = get_and_set_current_group($course, $groupmode, $groupid)) {
+            if (!$group = get_record('groups', 'id', $currentgroup)) {
+                error("That group (id $currentgroup) doesn't exist!");
+            }
+            $groupname = ': '.$group->name;
+        } else {
+            $groupname = ': '.get_string('allparticipants');
+        }
+    } else {
+        $currentgroup = false;
+        $groupname = '';
+    }
+
+    if (!$chat_sid = chat_login_user($chat->id, 'sockets', $currentgroup)) {
+        error("Could not log in to chat room!!");
+    }
+
+    if ($currentgroup !== false) {
+        $params = "chat_enter=true&amp;chat_sid=$chat_sid&amp;groupid=$currentgroup";
+    } else {
+        $params = "chat_enter=true&amp;chat_sid=$chat_sid&amp;groupid=0";
+    }
+
+    $strchat = get_string("modulename", "chat");
+
+
 ?>
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
 <html>
  <head>
   <title>
-   <?php echo $arsc_parameters["title"]; ?>
+   <?php echo "$strchat: $course->shortname: $chat->name$groupname" ?>
   </title>
  </head>
- <frameset cols="193,*" border="0" framespacing="no" frameborder="0" marginwidth="2" marginheight="1">
-  <frame src="../shared/roomlist.php?arsc_sid=<?php echo $arsc_sid; ?>" name="roomlist" scrolling="auto" noresize marginwidth="0" marginheight="0">
-  <frameset cols="*,120" border="0" framespacing="no" frameborder="0" marginwidth="2" marginheight="1">
-   <frameset rows="1,*,40" border="1" framespacing="no" frameborder="0" marginwidth="2" marginheight="1">
-    <frame src="../shared/empty.php" NAME="empty" scrolling="no" noresize marginwidth="0" marginheight="0">
-    <frame src="http://<?php echo $arsc_parameters["socketserver_adress"].":".$arsc_parameters["socketserver_port"]; ?>/?arsc_sid=<?php echo $arsc_sid; ?>" NAME="msg" scrolling="auto" noresize marginwidth="2" marginheight="0">
-    <frame src="chatinput.php?arsc_sid=<?php echo $arsc_sid; ?>" name="input" scrolling="no" noresize marginwidth="2" marginheight="1">
-   </frameset>
-   <frame src="../shared/userlist.php?arsc_sid=<?php echo $arsc_sid; ?>&arsc_enter=true" name="users" scrolling="auto" noresize marginwidth="2" marginheight="2">
+ <frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
+  <frameset rows="0,*,40" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
+   <frame src="empty.php" name="empty" scrolling="auto" noresize marginwidth="2" marginheight="0">
+   <frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&amp;$params"; ?>" NAME="msg" scrolling="auto" noresize marginwidth="2" marginheight="0">
+   <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">
+<!--  
+  <frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&amp;$params"; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5"> 
+  -->
  </frameset>
  <noframes>
-  Sorry, this version of ARSC needs a browser that understands framesets. But we have a lynx-friendly version too.
+  Sorry, this version of Moodle Chat needs a browser that handles frames.
  </noframes>
 </html>