diff --git a/course/view.php b/course/view.php index cb1f464fbe1..22b16089dbd 100644 --- a/course/view.php +++ b/course/view.php @@ -8,9 +8,10 @@ $id = optional_param('id', 0, PARAM_INT); $name = optional_param('name'); - $edit = optional_param('edit'); + $edit = optional_param('edit','',PARAM_ALPHA); $idnumber = optional_param('idnumber'); $topic = optional_param('topic',0,PARAM_INT); + $studentview = optional_param('studentview','',PARAM_ALPHA); if (empty($id) && empty($name)) { error("Must specify course id or short name"); @@ -59,10 +60,19 @@ $USER->editing = false; } + if (!isset($USER->studentview)) { + $USER->studentview = false; + } + + // need to check this here, as studentview=on disables edit allowed (where 'on' is checked) + if (($studentview == 'off') and confirm_sesskey()) { + $USER->studentview = false; + } + if ($PAGE->user_allowed_editing()) { - if ($edit == 'on') { + if (($edit == 'on') and confirm_sesskey()) { $USER->editing = true; - } else if ($edit == 'off') { + } else if (($edit == 'off') and confirm_sesskey()) { $USER->editing = false; if(!empty($USER->activitycopy) && $USER->activitycopycourse == $course->id) { $USER->activitycopy = false; @@ -70,6 +80,11 @@ } } + if (($studentview == 'on') and confirm_sesskey()) { + $USER->studentview = true; + $USER->editing = false; + } + if (isset($hide) && confirm_sesskey()) { set_section_visible($course->id, $hide, '0'); } @@ -126,4 +141,4 @@ echo ''; // content wrapper end print_footer(NULL, $course); -?> \ No newline at end of file +?>