]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14706, see tracker"
authordongsheng <dongsheng>
Fri, 23 May 2008 13:17:56 +0000 (13:17 +0000)
committerdongsheng <dongsheng>
Fri, 23 May 2008 13:17:56 +0000 (13:17 +0000)
lib/adminlib.php

index 70fd58a89f4b4a59fff26e21d47e53bf5430a14b..670c549d37aabf4207965cc4dfa5199dcc49f1d8 100644 (file)
@@ -4829,13 +4829,7 @@ EOT;
       * @param $msg     string the message needed to be shown
       */
     function update_full($percent, $msg){
-        if ($percent >= 100){
-            $percent = 1; 
-        }
-        if ($percent <= 0)
-        {
-            $percent = 0; 
-        }
+        $percent = max(min($percent, 100), 0);
         $this->_update($percent/100, $msg);
     }
     /**
@@ -4846,14 +4840,12 @@ EOT;
       * @param $msg   string    message
       */
     function update($cur, $total, $msg){
+        $cur = max($cur, 0);
         if ($cur >= $total){
             $percent = 1; 
+        } else {
+            $percent = $cur / $total;
         }
-        if ($cur <= 0)
-        {
-            $percent = 0; 
-        }
-        $percent = $cur / $total;
         $es = $this->estimate(microtime(true), $percent);
         $this->_update($percent, $msg, $es);
     }