mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
8223d27193
servers that have register_globals turned off (this is the default setting on newer version of PHP). In fact it's partly a hack that globalises all GET, POST, FILES AND COOKIE variables. Unfortunately though the SESSION and USER global session variables are only available as $_SESSION["USER"] and $_SESSION["SESSION"], which is cumbersome to use. So, for every request I now make a copy of these two session variables into $USER and $SESSION. Whenever I update them thoughout Moodle I now have to call save_session("USER") which copies them back to the session variable. This seems to be working well now. Because I'm using $_SESSION etc now this will raise the required minimum version of PHP to 4.1.0
73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
<?PHP // $Id$
|
|
|
|
// Display the course home page.
|
|
|
|
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);
|
|
|
|
add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
|
|
|
|
if ( isteacher($course->id) ) {
|
|
if ($edit == "on") {
|
|
$USER->editing = true;
|
|
} else if ($edit == "off") {
|
|
$USER->editing = false;
|
|
}
|
|
}
|
|
if ($help == "on") {
|
|
$USER->help = true;
|
|
} else if ($help == "off") {
|
|
$USER->help = false;
|
|
}
|
|
|
|
save_session("USER");
|
|
|
|
if (! $course->category) { // This course is not a real course.
|
|
redirect("$CFG->wwwroot");
|
|
}
|
|
|
|
$courseword = get_string("course");
|
|
|
|
print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
|
|
update_course_icon($course->id));
|
|
|
|
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
|
|
$sections = get_all_sections($course->id);
|
|
|
|
switch ($course->format) {
|
|
case "weeks":
|
|
include("weeks.php");
|
|
break;
|
|
case "social":
|
|
include("social.php");
|
|
break;
|
|
case "topics":
|
|
include("topics.php");
|
|
break;
|
|
default:
|
|
error("Course format not defined yet!");
|
|
}
|
|
|
|
print_footer($course);
|
|
|
|
?>
|