]> git.mjollnir.org Git - moodle.git/commitdiff
Can now specify course by "short name" using name parameter. Useful for
authormartin <martin>
Mon, 29 Jul 2002 13:10:25 +0000 (13:10 +0000)
committermartin <martin>
Mon, 29 Jul 2002 13:10:25 +0000 (13:10 +0000)
integrating with external interfaces.  Thanks to dopey for the idea.

course/view.php

index 47380fadfa7fc69c387be4f88f56b5eacdb5b7ad..3e70955312279ca0b33573a34cf14711831bb1b0 100644 (file)
@@ -5,13 +5,25 @@
     require("../config.php");
     require("lib.php");
 
+    optional_variable($id);
+    optional_variable($name);
 
-    require_login($id);
+    if (!$id and !$name) {
+        error("Must specify course id or short name");
+    }
 
-    if (! $course = get_record("course", "id", $id) ) {
-        error("That's an invalid course id");
+    if ($name) {
+        if (! $course = get_record("course", "shortname", $name) ) {
+            error("That's an invalid short course name");
+        }
+    } else {
+        if (! $course = get_record("course", "id", $id) ) {
+            error("That's an invalid course id");
+        }
     }
 
+    require_login($id);
+
     add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
 
     if ( isteacher($course->id) ) {