]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14556 reset coursepage state after switchrole merged from MOODLE_19_STABLE
authorskodak <skodak>
Fri, 25 Apr 2008 14:10:02 +0000 (14:10 +0000)
committerskodak <skodak>
Fri, 25 Apr 2008 14:10:02 +0000 (14:10 +0000)
course/view.php

index 04f83fab402e4ffc048fce00d8f7308cc18292b5..60b75475262c891a4448cbd867881285deb6ab8b 100644 (file)
@@ -51,6 +51,7 @@
     require_login($course);
 
     // Switchrole - sanity check in cost-order...
+    $reset_user_allowed_editing = false;
     if ($switchrole > 0 && confirm_sesskey() &&
         has_capability('moodle/role:switchroles', $context)) {
         // is this role assignable in this context?
             // Double check that this role is allowed here
             require_login($course->id);
         }
+        // reset course page state - this prevents some weird problems ;-)
+        $USER->activitycopy = false;
+        $USER->activitycopycourse = NULL;
+        unset($USER->activitycopyname);
+        unset($SESSION->modform);
+        $USER->editing = 0;
+        $reset_user_allowed_editing = true;
     }
 
     //If course is hosted on an external server, redirect to corresponding
     $PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
     $pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
 
+    if ($reset_user_allowed_editing) {
+        // ugly hack
+        unset($PAGE->_user_allowed_editing);
+    }
 
     if (!isset($USER->editing)) {
         $USER->editing = 0;