]> git.mjollnir.org Git - moodle.git/commitdiff
Added preliminary support to teachers.
authorstronk7 <stronk7>
Sat, 2 Aug 2003 16:06:33 +0000 (16:06 +0000)
committerstronk7 <stronk7>
Sat, 2 Aug 2003 16:06:33 +0000 (16:06 +0000)
Not working yet.

backup/restore.php
backup/restore_form.html
backup/restore_precheck.html

index f261950e134449ac3a0f291420147effa2acb36d..1bd8fd4ae009a193f13214d5b51db4e026b1d29a 100644 (file)
     require_once ("restorelib.php");
 
     //Optional
+    optional_variable($id);
     optional_variable($file);
 
     //Check login       
     require_login();
 
-    //Check admin
-    if (!isadmin()) {
-        error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+    if (!empty($id)) {
+        if (!isteacher($id)) {
+            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+        }
+    } else {
+        if (!isadmin()) {
+            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+        }
     }
 
     //Check site
     
     //Check backup_version
     if ($file) {
-        $linkto = "restore.php?file=".$file;
+        $linkto = "restore.php?id=".$id."&file=".$file;
     } else {
         $linkto = "restore.php";
     }
-
     upgrade_backup_db($linkto);
 
     //Get strings
     }
 
     //We are here, so me have a file.
+
+    //Get and check course
+    if (! $course = get_record("course", "id", $id)) {
+        error("Course ID was incorrect (can't find it)");
+    }
+
     //Print header
-    print_header("$site->shortname: $strcourserestore", $site->fullname,
-                 "<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> ->
-                  $strcourserestore -> ".basename($file));
+    if (isadmin()) {
+        print_header("$site->shortname: $strcourserestore", $site->fullname,
+                     "<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
+                      $strcourserestore -> ".basename($file));
+    } else {
+        print_header("$course->shortname: $strcourserestore", $course->fullname,
+                     "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
+                     $strcourserestore");
+    }
     //Print form
     print_heading("$strcourserestore: ".basename($file));
     print_simple_box_start("center", "", "$THEME->cellheading");
index 22df9207692efbe10459d3d733046b4eeb6df5f1..12dd72718c08e941b44b80f002a07a0a7f5da916 100644 (file)
     require_login();
 
     //Check admin
-    if (!isadmin()) {
-        error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+    if (!empty($id)) {
+        if (!isteacher($id)) {
+            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+        }
+    } else {
+        if (!isadmin()) {
+            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");   
+        }
     }
 
     //Check site
index d036944d063160154edf60a1fc1a17c021351cb9..e875f88c52272e7aeb3dc9d177f8ba11ccea23bd 100644 (file)
     require_login();
  
     //Check admin
-    if (!isadmin()) {
-        error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+    if (!empty($id)) {
+        if (!isteacher($id)) {
+            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+        }
+    } else {
+        if (!isadmin()) {
+            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");   
+        }
     }
 
     //Check site
         $hidden["backup_unique_code"] = $backup_unique_code;
         $hidden["launch"]             = "form";
         $hidden["file"]               =  $file;
+        $hidden["id"]                 =  $id;
         print_single_button("restore.php", $hidden, get_string("continue"),"post");
         echo "</CENTER>";
     }