From 783da26290eaa9f90a8b84cf78ec0b091aa9097e Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 24 May 2003 07:29:17 +0000 Subject: [PATCH] A bit of an audit and a clean up of require_login to add consistency. No major problems found, just some code tidy-up --- course/categories.php | 2 ++ course/edit.php | 5 ++--- course/editsection.php | 4 ++-- course/enrol.php | 3 ++- course/grades.php | 4 ++-- course/log.php | 2 +- course/loglive.php | 4 +++- course/social.php | 22 +++++++++++++--------- course/teachers.php | 4 ++-- course/view.php | 2 +- 10 files changed, 30 insertions(+), 22 deletions(-) diff --git a/course/categories.php b/course/categories.php index 7ed3adc982..762130ed35 100644 --- a/course/categories.php +++ b/course/categories.php @@ -4,6 +4,8 @@ require_once("../config.php"); require_once("lib.php"); + require_login(); + if (!isadmin()) { error("Only administrators can use this course!"); } diff --git a/course/edit.php b/course/edit.php index 36b88a6b54..72f1c32ddf 100644 --- a/course/edit.php +++ b/course/edit.php @@ -6,18 +6,17 @@ optional_variable($id, 0); // course id + require_login(); + if ($id) { if (! $course = get_record("course", "id", $id)) { error("Course ID was incorrect"); } - require_login($course->id); - if (!isteacher($course->id)) { error("Only teachers can edit the course!"); } } else { // Admin is creating a new course - require_login(); if (!iscreator()) { error("Only administrators and teachers can use this page"); diff --git a/course/editsection.php b/course/editsection.php index 280b2e0641..54d67a8526 100644 --- a/course/editsection.php +++ b/course/editsection.php @@ -6,6 +6,8 @@ require_variable($id); // Week ID + require_login(); + if (! $section = get_record("course_sections", "id", $id)) { error("Course section is incorrect"); } @@ -14,8 +16,6 @@ error("Could not find the course!"); } - require_login($course->id); - if (!isteacher($course->id)) { error("Only teachers can edit this!"); } diff --git a/course/enrol.php b/course/enrol.php index d731cf6c51..e9b64a2df3 100644 --- a/course/enrol.php +++ b/course/enrol.php @@ -4,9 +4,10 @@ require_once("../config.php"); require_once("lib.php"); - require_login(); require_variable($id); + require_login(); + if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); } diff --git a/course/grades.php b/course/grades.php index 269f77abf6..41bc5426c5 100644 --- a/course/grades.php +++ b/course/grades.php @@ -8,12 +8,12 @@ require_variable($id); // course id optional_variable($download, ""); // to download data + require_login(); + if (! $course = get_record("course", "id", $id)) { error("Course ID was incorrect"); } - require_login($course->id); - if (!isteacher($course->id)) { error("Only teachers can use this page!"); } diff --git a/course/log.php b/course/log.php index 617926adcc..68442e0c5b 100644 --- a/course/log.php +++ b/course/log.php @@ -8,7 +8,7 @@ optional_variable($user, 0); // User to display optional_variable($date, 0); // Date to display - require_login($id); + require_login(); if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); diff --git a/course/loglive.php b/course/loglive.php index d2a8354760..a643335a5a 100644 --- a/course/loglive.php +++ b/course/loglive.php @@ -4,7 +4,9 @@ require_once("../config.php"); require_once("lib.php"); - require_login($id); + require_variable($id); + + require_login(); if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); diff --git a/course/social.php b/course/social.php index c66700ba5c..6f01d81071 100644 --- a/course/social.php +++ b/course/social.php @@ -1,4 +1,4 @@ - - - - + - -
- +
+ id\">".get_string("participants").""; $modicon[]="\"\""; $editmyprofile = "firstname $USER->lastname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">". @@ -57,7 +57,11 @@ } else { $subtext = get_string("subscribe", "forum"); } - $headertext = "
".get_string("socialheadline")."id\">$subtext
"; + $headertext = "". + "
". + get_string("socialheadline"). + "". + "id\">$subtext
"; print_heading_block($headertext); echo "\"\"
"; @@ -67,7 +71,7 @@ notify("Could not find or create a social forum here"); } ?> -
+ + + diff --git a/course/teachers.php b/course/teachers.php index 186552ebc2..b065d56f90 100644 --- a/course/teachers.php +++ b/course/teachers.php @@ -6,12 +6,12 @@ require_variable($id); // course id + require_login(); + if (! $course = get_record("course", "id", $id)) { error("Course ID was incorrect"); } - require_login($course->id); - if (!isteacher($course->id)) { error("Only teachers can edit the course!"); } diff --git a/course/view.php b/course/view.php index 46c06d02bd..35a0c34216 100644 --- a/course/view.php +++ b/course/view.php @@ -22,7 +22,7 @@ } } - require_login($id); + require_login($course->id); add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id"); -- 2.39.5