]> git.mjollnir.org Git - moodle.git/commitdiff
Mnet: Bugfix: 3 params in optional_param(): MDL-8119
authordonal72 <donal72>
Thu, 11 Jan 2007 05:55:37 +0000 (05:55 +0000)
committerdonal72 <donal72>
Thu, 11 Jan 2007 05:55:37 +0000 (05:55 +0000)
course/report/log/index.php

index 2927912df771df0d8407189c0b7fa4e9f19cd46a..8943b2c1241aa8f990fd810a61257ec7e0b9c681 100644 (file)
@@ -6,17 +6,19 @@
     require_once('lib.php');
     require_once($CFG->libdir.'/adminlib.php');
 
-    $id          = optional_param('id', PARAM_INT);// Course ID
+    $id          = optional_param('id', 0, PARAM_INT);// Course ID
     
-    $host_course = optional_param('host_course', PARAM_PATH);// Course ID
-    
-    list($hostid, $id) = explode('/', $host_course);
-    
-    $course_stub       = get_record('mnet_log', 'hostid', $hostid, 'course', $id);
-    $course->id        = $id;
-    $course->shortname = $course_stub->coursename;
-    $course->fullname  = $course_stub->coursename;
+    $host_course = optional_param('host_course', '', PARAM_PATH);// Course ID
     
+    if (empty($host_course)) {
+        $hostid = $CFG->mnet_localhost_id;
+        if (empty($id)) {
+            $site = get_site();
+            $id = $site->id;
+        }
+    } else {
+        list($hostid, $id) = explode('/', $host_course);
+    }
     
     $group       = optional_param('group', -1, PARAM_INT); // Group to display
     $user        = optional_param('user', 0, PARAM_INT); // User to display
         if (!$course = get_record('course', 'id', $id) ) {
             error('That\'s an invalid course id'.$id);
         }
+    } else {
+        $course_stub       = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1'));
+        $course->id        = $id;
+        $course->shortname = $course_stub->coursename;
+        $course->fullname  = $course_stub->coursename;
     }
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);