]> git.mjollnir.org Git - moodle.git/commitdiff
mod/chat: make http-chat more database friendly and change msg insertion to use POST
authormartinlanghoff <martinlanghoff>
Mon, 17 Apr 2006 21:03:44 +0000 (21:03 +0000)
committermartinlanghoff <martinlanghoff>
Mon, 17 Apr 2006 21:03:44 +0000 (21:03 +0000)
+ we are now more conservative in the fields it asks from the db
+ also more conservative with upates to chat_users
+ messages are now added via POST requests instead of GET

mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/insert.php
mod/chat/gui_header_js/jsupdate.php

index 8e718d4c7a39471d72708090079268a597334f46..2ed66eafffa2d4bba5715019d5bf39c726695a69 100644 (file)
     print_header('', '', '', 'inputForm.chat_message', $meta, false);
 
 ?>
-    <form action="../empty.php" method="GET" target="empty" name="inputForm"
+    <form action="../empty.php" method="POST" target="empty" name="inputForm"
           OnSubmit="return empty_field_and_submit()">
         &gt;&gt;<input type="text" name="chat_message" size="60" value="" />
         <?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?>
     </form>
 
-    <form action="insert.php" method="GET" target="empty" name="sendForm">
+    <form action="insert.php" method="POST" target="empty" name="sendForm">
         <input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
         <input type="hidden" name="chat_message" />
     </form>
index 5321fc02b29656c4d35eb1c8451959f1ab511a53..7fd33fb838fc7cc241265abfd3088a930a286f6c 100644 (file)
@@ -14,7 +14,7 @@
         error('No chat found');
     }
 
-    if (!$course = get_record('course', 'id', $chat->course)) {
+    if (!$course = get_record('course', 'id', $chat->course, '', '', '','', 'id, shortname')) {
         error('Could not find the course this belongs to!');
     }
 
index a0f356a4c9d1d25cff5bfc8802c95d70114edb0b..ba008fa93bd732b6838752ce6275b9b33f95bcd0 100644 (file)
@@ -99,7 +99,9 @@
         $us = array ();
         if (($chat_lasttime != $chat_newlasttime) and $messages) {
 
-            if (!$currentuser = get_record('user', 'id', $chatuser->userid)) {
+            // $currentuser is only used in chat_format_message() which passes it along to
+            // chat_format_message_manually() -- and only id and timezone are used.
+            if (!$currentuser = get_record('user', 'id', $chatuser->userid, '','', '','', 'id, username, timezone')) {
                 error('User does not exist!');
             }
             $currentuser->description = '';
         }
 
         $chatuser->lastping = time();
-        update_record('chat_users', $chatuser);
+        set_field('chat_users', 'lastping', $chatuser->lastping, 'sid', $chatuser->sid );
 
         if ($refreshusers) {
             echo "if (parent.users.document.anchors[0] != null) {" .