From 7226ce02b182807f6ad85ee147f9a37d65c5481a Mon Sep 17 00:00:00 2001
From: moodler <moodler>
Date: Thu, 17 Apr 2003 13:20:26 +0000
Subject: [PATCH] Robustness for $course variable

---
 course/edit.html | 2 +-
 course/edit.php  | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/course/edit.html b/course/edit.html
index c1cf479fe3..ec449f003e 100644
--- a/course/edit.html
+++ b/course/edit.html
@@ -135,5 +135,5 @@
 	<td></td>
 	<td><input type="submit" value="<? print_string("savechanges") ?>"></td>
 </TABLE>
-<INPUT type="hidden" name="id" value="<?=$course->id ?>">
+<INPUT type="hidden" name="id" value="<?=$form->id ?>">
 </FORM>
diff --git a/course/edit.php b/course/edit.php
index 80cbd10431..695cd13b86 100644
--- a/course/edit.php
+++ b/course/edit.php
@@ -22,6 +22,8 @@
         if (!iscreator()) {
             error("Only administrators and teachers can use this page");
         }
+
+        $course = NULL;
     }
 
     if (! $site = get_site()) {
@@ -29,6 +31,8 @@
     }
 
 
+
+
 /// If data submitted, then process and store.
 
 	if ($form = data_submitted()) {
@@ -112,6 +116,7 @@
             $form->newsitems = 5;
             $form->showrecent = 1;
             $form->category = 1;
+            $form->id = "";
         }
     }
 
@@ -131,7 +136,7 @@
     $straddnewcourse = get_string("addnewcourse");
     $stradministration = get_string("administration");
 
-    if (isset($course)) {
+    if (!empty($course)) {
 	    print_header($streditcoursesettings, "$course->fullname", 
                      "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
                       -> $streditcoursesettings", $focus);
-- 
2.39.5