]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-12304, fix double text merged from MOODLE_19_STABLE"
authordongsheng <dongsheng>
Wed, 18 Jun 2008 03:18:22 +0000 (03:18 +0000)
committerdongsheng <dongsheng>
Wed, 18 Jun 2008 03:18:22 +0000 (03:18 +0000)
mod/chat/gui_header_js/jsupdate.php
mod/chat/gui_header_js/users.php

index 5c39d2e1845d2ab96eb23f99667c04ad46989a3b..5d7ac74e85cafcfa4ff77fd370c077fc067ec22f 100644 (file)
@@ -62,8 +62,8 @@
     $chat_newrow = ($chat_lastrow + $num) % 2;
 
     // no &amp; in url, does not work in header!
-    $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow"; 
-    $refreshurlamp = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&amp;chat_lasttime=$chat_newlasttime&amp;chat_lastrow=$chat_newrow"; 
+    $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
+    $refreshurlamp = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&amp;chat_lasttime=$chat_newlasttime&amp;chat_lastrow=$chat_newrow";
 
     header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
     header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
@@ -90,7 +90,7 @@
         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
         <script type="text/javascript">
         //<![CDATA[
-        if (parent.msg.document.getElementById("msgStarted") == null) {
+        if (parent.msg && parent.msg.document.getElementById("msgStarted") == null) {
             parent.msg.document.close();
             parent.msg.document.open("text/html","replace");
             parent.msg.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
                      $refreshusers = true;
                 }
                 $us[$message->userid] = $timenow - $message->timestamp;
+                echo "if(parent.msg)";
                 echo "parent.msg.document.write('".addslashes_js($formatmessage->html)."\\n');\n";
              }
         }
         $DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id'=>$chatuser->id));
 
         if ($refreshusers) {
-            echo "if (parent.users.document.anchors[1] != null) {" .
-                    "parent.users.location.href = parent.users.document.anchors[1].href;}\n";
+        ?>
+        var link = parent.users.document.getElementById('refreshLink');
+        if (link != null) {
+            parent.users.location.href = link.href;
+        }
+        <?php
         } else {
             foreach($us as $uid=>$lastping) {
                 $min = (int) ($lastping/60);
                 $min = $min < 10 ? '0'.$min : $min;
                 $sec = $sec < 10 ? '0'.$sec : $sec;
                 $idle = $min.':'.$sec;
-                echo "if (parent.users.document.getElementById('uidle{$uid}') != null) {".
+                echo "if (parent.users && parent.users.document.getElementById('uidle{$uid}') != null) {".
                         "parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n";
             }
         }
         ?>
-        parent.msg.scroll(1,5000000);
+        if(parent.msg)
+            parent.msg.scroll(1,5000000);
         //]]>
         </script>
     </head>
 
 // support HTTP Keep-Alive
 header("Content-Length: " . ob_get_length() );
-ob_end_flush(); 
+ob_end_flush();
 exit;
 
 
index df65d5d2dd7dd4bbfe16daf2b930031bf15ae5e4..60453d5396279cf7a9466682d8320e614d8463b3 100644 (file)
     $strbeep    = get_string('beep', 'chat');
 
 
-    echo '<div style="display: none"><a href="'.$refreshurl.'" name="refreshLink">Refresh link</a></div>';
+    echo '<div style="display: none"><a href="'.$refreshurl.'" id="refreshLink">Refresh link</a></div>';
     echo '<table width="100%">';
     foreach ($chatusers as $chatuser) {
         $lastping = $timenow - $chatuser->lastmessageping;
     //
     // Support HTTP Keep-Alive by printing Content-Length
     //
-    // If the user pane is refreshing often, using keepalives 
-    // is lighter on the server and faster for most clients. 
+    // If the user pane is refreshing often, using keepalives
+    // is lighter on the server and faster for most clients.
     //
-    // Apache is normally configured to have a 15s timeout on 
+    // Apache is normally configured to have a 15s timeout on
     // keepalives, so let's observe that. Unfortunately, we cannot
-    // autodetect the keepalive timeout. 
+    // autodetect the keepalive timeout.
     //
     // Using keepalives when the refresh is longer than the timeout
-    // wastes server resources keeping an apache child around on a  
-    // connection that will timeout. So we don't. 
-    if ($CFG->chat_refresh_userlist < 15) {    
+    // wastes server resources keeping an apache child around on a
+    // connection that will timeout. So we don't.
+    if ($CFG->chat_refresh_userlist < 15) {
         header("Content-Length: " . ob_get_length() );
-        ob_end_flush(); 
+        ob_end_flush();
     }
 
     exit; // no further output