diff --git a/backup/restore_check.html b/backup/restore_check.html
index f0e0c19f6eb..abe804a380d 100644
--- a/backup/restore_check.html
+++ b/backup/restore_check.html
@@ -98,8 +98,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
@@ -108,16 +114,43 @@
}
//Depending the selected restoreto:
- // 0-Existing course: Select the destination course and launch the check again.
- // 1-New course: Create the restore object (checking everything) and launch the execute.
+ // If user is a teacher (and nor admin):
+ // 0-Current course, deleting: Put $restore->course_id and $restore->deleting (true), create the restore object
+ // 1-Current course, adding: Put $restore->course_id and $restore->deleting (false), create the restore object
+ // If the uses is an admin:
+ // 0-Existing course, deleting: Select the destination course and launch the check again, then
+ // put $restore->course_id and $restore->deleting (true), create the restore object.
+ // 1-Existing course, adding: Select the destination course and launch the check again, then
+ // put $restore->course_id and $restore->deleting (false), create the restore object.
+ // 2-New course: Create the restore object and launch the execute.
- //Select course
- if (($restore->restoreto == 0) and ($restore->course_id == 0)) {
+ //If the user is a teacher and not an admin
+ if (isteacher($id) and !isadmin()) {
+ $restore->course_id = $id;
+ if ($restore->restoreto == 0) {
+ $restore->deleting = true;
+ } else {
+ $restore->deleting = false;
+ }
+ }
+
+ //If the user is an admin
+ if (isadmin()) {
+ //Set restore->deleting as needed
+ if ($restore->restoreto == 0) {
+ $restore->deleting = true;
+ } else {
+ $restore->deleting = false;
+ }
+ }
+
+ //Now, select the course if needed
+ if (($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id == 0) and (isadmin())) {
if ($courses = get_courses()) {
print_heading(get_string("choosecourse"));
print_simple_box_start("CENTER");
foreach ($courses as $course) {
- echo "id&launch=check&file=$file\">$course->fullname ($course->shortname)
";
+ echo "id&launch=check&id=$id&file=$file\">$course->fullname ($course->shortname)
";
}
print_simple_box_end();
} else {
@@ -125,7 +158,7 @@
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
}
//Checks everything and execute restore
- } else if ((($restore->restoreto == 0) and ($restore->course_id != 0)) or ($restore->restoreto == 1)) {
+ } else if ((($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id != 0)) or ($restore->restoreto == 2)) {
$show_continue_button = true;
//Check if we've selected any mod's user info and restore->users
//is set to none. Change it to course and inform.
@@ -151,6 +184,7 @@
echo "
"; echo get_string("restoreto").":"; echo "