]> git.mjollnir.org Git - moodle.git/commitdiff
merged: fixing warnings in stats lib - rather than doing an include_once and noticing...
authormjollnir_ <mjollnir_>
Wed, 11 Apr 2007 23:53:15 +0000 (23:53 +0000)
committermjollnir_ <mjollnir_>
Wed, 11 Apr 2007 23:53:15 +0000 (23:53 +0000)
course/report/stats/graph.php
course/report/stats/report.php
lib/statslib.php

index 18e3fc2747cfbaa620706a0b53b373d6a196a64c..1c1c18c09d21d859bee09df68e4ddae4551feeae 100644 (file)
                 $times[$stat->timeend] = userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone);
             }
         }
+        foreach (array_keys($times) as $t) {
+            foreach ($data as $roleid => $stuff) {
+                if (!array_key_exists($t, $stuff)) {
+                    $data[$roleid][$t] = 0;
+                }
+            }
+        }
+        foreach ($data as $role => $stuff) {
+            ksort($data[$role]);
+        }
         $nonzeroroleid = 0;
         foreach (array_keys($data) as $roleid) {
             if ($roleid == 0) {
index 5cf737e666fd51896c7a0db2b6c909cc145a8eb2..973e941f82912882597a14dce23d2a4e511d6f70 100644 (file)
                             $rolesdata[$roleid] = 0;
                         }
                     }
+                    else {
+                        foreach (array_keys($roles) as $r) {
+                            if (!array_key_exists($r, $rolesdata)) {
+                                $rolesdata[$r] = 0;
+                            }
+                        }
+                    }
                     krsort($rolesdata); 
                     $row = array_merge(array($times[$time]),$rolesdata);
                     if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) {
         }
     }    
 
-?>
\ No newline at end of file
+?>
index 34a6907b47009af0d8c4b53e68a351ad197945eb..7c6c53d0e45b03ffb21840a77053b2638428d4c2 100644 (file)
@@ -81,9 +81,11 @@ function stats_cron_daily () {
         $daily_modules = array();
         $mods = get_records("modules");
         foreach ($mods as $mod) {
-            // include_once() will only warn if a mod is missing
-            // as we don't want processing to stop on such minutiae (MDL-7385)
-            include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php');
+            $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php';
+            if (!is_readable($file)) {
+                continue;
+            }
+            require_once($file);
             $fname = $mod->name.'_get_daily_stats';
             if (function_exists($fname)) {
                 $daily_modules[$mod] = $fname;
@@ -238,7 +240,11 @@ function stats_cron_weekly () {
         $weekly_modules = array();
         $mods = get_records("modules");
         foreach ($mods as $mod) {
-            include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php');
+            $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php';
+            if (!is_readable($file)) {
+                continue;
+            }
+            require_once($file);
             $fname = $mod->name.'_get_weekly_stats';
             if (function_exists($fname)) {
                 $weekly_modules[$mod] = $fname;
@@ -367,7 +373,11 @@ function stats_cron_monthly () {
         $monthly_modules = array();
         $mods = get_records("modules");
         foreach ($mods as $mod) {
-            include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php');
+            $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php';
+            if (!is_readable($file)) {
+                continue;
+            }
+            require_once($file);
             $fname = $mod->name.'_get_monthly_stats';
             if (function_exists($fname)) {
                 $monthly_modules[$mod] = $fname;
@@ -769,7 +779,11 @@ function stats_get_action_sql_in($str) {
     $function = 'stats_get_'.$str.'_actions';
     $actions = $function();
     foreach ($mods as $mod) {
-        include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php');
+        $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php';
+        if (!is_readable($file)) {
+            continue;
+        }
+        require_once($file);
         $function = $mod->name.'_get_'.$str.'_actions';
         if (function_exists($function)) {
             $actions = array_merge($actions,$function());