]> git.mjollnir.org Git - moodle.git/commitdiff
Now restore checks that we are coming from the form page to delete any
authorstronk7 <stronk7>
Mon, 10 Apr 2006 19:02:39 +0000 (19:02 +0000)
committerstronk7 <stronk7>
Mon, 10 Apr 2006 19:02:39 +0000 (19:02 +0000)
previously stored $SESSION->restore data.

Also, the "restore to existing" feature is working again. It was broken
because of the pseudo-register-globals hack. Now course_id is retrieved
with the standar param() methods.

Bug 5145 was the original cause for investingating this.
(http://moodle.org/bugs/bug.php?op=show&bugid=5145)

backup/restore_check.html

index 5537c04d2aa54cb79471e5213bc8b7204da768c8..ac9693da0c10fe43df561926a6e57776e4e2203a 100644 (file)
         }
     }
 
-    //If restore session info exists, but we are posting parameters
-    //manually, this has prioriry
-    if (isset($restore) and isset($_POST['restore_restoreto'])) {
+    //Detect if we are coming from the restore form
+    $fromform = optional_param ('fromform', 0, PARAM_INT);
+
+    //If restore session info exists, but we are coming from the form
+    //it has prioriry
+    if (isset($restore) and !empty($fromform)) {
         unset($restore);
     }
 
         //restore_messages
         $restore_messages = required_param('restore_messages');
 
-        //Check we've selected a course
-        if (!isset($course_id)) {
-            $course_id = 0;
-        }
+        //Check we've selected a course to restore to
+        $course_id = optional_param('course_id', 0, PARAM_INT);
  
         //We are here, having all we need !!
         //Create the restore object and put it in the session
     } else {
         //We have the object, so check if we have a new course_id
         //passed as parammeter
+        $course_id = optional_param('course_id', 0, PARAM_INT);
         if ($course_id) {
             $restore->course_id=$course_id;
         }