From: moodler Date: Tue, 6 May 2003 02:51:38 +0000 (+0000) Subject: Changes to improve hide/show of individual activities when the last X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=266fbe1a8a6b0bcbdf57c2faa690ab513d10e0be;p=moodle.git Changes to improve hide/show of individual activities when the last action was to hide/show a topic --- diff --git a/course/lib.php b/course/lib.php index 981ee5f947..820e5b50c4 100644 --- a/course/lib.php +++ b/course/lib.php @@ -544,6 +544,10 @@ function set_section_visible($courseid, $sectionnumber, $visibility) { set_field("course_modules", "visible", "$visibility", "id", $moduleid); } } + $modinfo = serialize(get_array_of_activities($courseid)); + if (!set_field("course", "modinfo", $modinfo, "id", $courseid)) { + error("Could not cache module information!"); + } } } diff --git a/course/mod.php b/course/mod.php index a482bf5617..f6e05c7601 100644 --- a/course/mod.php +++ b/course/mod.php @@ -5,6 +5,7 @@ require("../config.php"); require("lib.php"); + if (isset($cancel)) { if (!empty($SESSION->returnpage)) { $return = $SESSION->returnpage; @@ -115,7 +116,12 @@ error("Could not cache module information!"); } - redirect($_SERVER["HTTP_REFERER"]); + $site = get_site(); + if ($site->id == $cm->course) { + redirect($CFG->wwwroot); + } else { + redirect("view.php?id=$cm->course"); + } exit; } else if (isset($hide)) { @@ -131,7 +137,12 @@ error("Could not cache module information!"); } - redirect($_SERVER["HTTP_REFERER"]); + $site = get_site(); + if ($site->id == $cm->course) { + redirect($CFG->wwwroot); + } else { + redirect("view.php?id=$cm->course"); + } exit; } else if (isset($show)) { @@ -139,15 +150,22 @@ if (! $cm = get_record("course_modules", "id", $show)) { error("This course module doesn't exist"); } - - show_course_module($show); - $modinfo = serialize(get_array_of_activities($cm->course)); - if (!set_field("course", "modinfo", $modinfo, "id", $cm->course)) { - error("Could not cache module information!"); + $site = get_site(); + + if ($cm->visible or $site->id == $cm->course) { + show_course_module($show); + $modinfo = serialize(get_array_of_activities($cm->course)); + if (!set_field("course", "modinfo", $modinfo, "id", $cm->course)) { + error("Could not cache module information!"); + } } - redirect($_SERVER["HTTP_REFERER"]); + if ($site->id == $cm->course) { + redirect($CFG->wwwroot); + } else { + redirect("view.php?id=$cm->course"); + } exit; } else if (isset($delete)) { // value = course module