From 388f8911e3e6f259bf6b3ac924ae5c369af7cf36 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 29 Jul 2002 13:10:25 +0000 Subject: [PATCH] Can now specify course by "short name" using name parameter. Useful for integrating with external interfaces. Thanks to dopey for the idea. --- course/view.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/course/view.php b/course/view.php index 47380fadfa7..3e709553122 100644 --- a/course/view.php +++ b/course/view.php @@ -5,13 +5,25 @@ require("../config.php"); require("lib.php"); + optional_variable($id); + optional_variable($name); + + if (!$id and !$name) { + error("Must specify course id or short name"); + } + + 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); - if (! $course = get_record("course", "id", $id) ) { - error("That's an invalid course id"); - } - add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id"); if ( isteacher($course->id) ) {