]> git.mjollnir.org Git - moodle.git/commitdiff
mod/chat: Normal method -- collate 2 SELECTs into one
authormartinlanghoff <martinlanghoff>
Mon, 17 Apr 2006 21:06:28 +0000 (21:06 +0000)
committermartinlanghoff <martinlanghoff>
Mon, 17 Apr 2006 21:06:28 +0000 (21:06 +0000)
We really don't need to ask about the user table _twice_ here. Just ask for the
right fields, and done.

mod/chat/gui_header_js/jsupdate.php

index 918492018030b5c3439ddaa442c89f5531dfcdf8..f58b78d3aba8b63be79fe1a12a3a7f039c896e84 100644 (file)
             $CFG->coursetheme = $course->theme;
         }
     }
-    //Get the user theme
-    $USER = get_record('user','id',$chatuser->userid,'','','','','id, theme');
+
+    //Get the user theme and enough info to be used in chat_format_message() which passes it along to
+    // chat_format_message_manually() -- and only id and timezone are used.
+    if (!$USER = get_record('user','id',$chatuser->userid,'','','','','id, theme, username, timezone')) {
+        error('User does not exist!');
+    }
+    $USER->description = '';
 
     //Adjust the prefered theme (main, course, user)
     theme_setup();
         $us = array ();
         if (($chat_lasttime != $chat_newlasttime) and $messages) {
 
-            // $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 = '';
-
             foreach ($messages as $message) {
                 $chat_lastrow = ($chat_lastrow + 1) % 2;
-                $formatmessage = chat_format_message($message, $chatuser->course, $currentuser, $chat_lastrow);
+                $formatmessage = chat_format_message($message, $chatuser->course, $USER, $chat_lastrow);
                 if ($formatmessage->beep) {
                      $beep = true;
                 }