From: stronk7 Date: Sat, 2 Aug 2003 16:06:33 +0000 (+0000) Subject: Added preliminary support to teachers. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9e426d54eefd1e433924fe3666af8f57b507b012;p=moodle.git Added preliminary support to teachers. Not working yet. --- diff --git a/backup/restore.php b/backup/restore.php index f261950e13..1bd8fd4ae0 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -11,14 +11,20 @@ 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 @@ -31,11 +37,10 @@ //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 @@ -63,10 +68,22 @@ } //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, - "wwwroot/$CFG->admin/index.php\">$stradministration -> - $strcourserestore -> ".basename($file)); + if (isadmin()) { + print_header("$site->shortname: $strcourserestore", $site->fullname, + "wwwroot/$CFG->admin/index.php\">$stradministration -> + $strcourserestore -> ".basename($file)); + } else { + print_header("$course->shortname: $strcourserestore", $course->fullname, + "wwwroot/course/view.php?id=$course->id\">$course->shortname -> + $strcourserestore"); + } //Print form print_heading("$strcourserestore: ".basename($file)); print_simple_box_start("center", "", "$THEME->cellheading"); diff --git a/backup/restore_form.html b/backup/restore_form.html index 22df920769..12dd72718c 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -22,8 +22,14 @@ 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 diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html index d036944d06..e875f88c52 100644 --- a/backup/restore_precheck.html +++ b/backup/restore_precheck.html @@ -13,8 +13,14 @@ 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 @@ -120,6 +126,7 @@ $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 ""; }