Skip to content

Commit

Permalink
Added preliminary support to teachers.
Browse files Browse the repository at this point in the history
Not working yet.
  • Loading branch information
stronk7 committed Aug 2, 2003
1 parent 8f7ab28 commit 9e426d5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
33 changes: 25 additions & 8 deletions backup/restore.php
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
"<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");
Expand Down
10 changes: 8 additions & 2 deletions backup/restore_form.html
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions backup/restore_precheck.html
Expand Up @@ -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
Expand Down Expand Up @@ -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 "</CENTER>";
}
Expand Down

0 comments on commit 9e426d5

Please sign in to comment.