info;
$course_header = $SESSION->course_header;
//Check that we have all we need
//backup_unique_code
require_variable($backup_unique_code);
//file
require_variable($file);
//info
require_variable($info);
//course_header
require_variable($course_header);
//Check login
require_login();
//Check admin
if (!empty($id)) {
if (!isteacheredit($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
if (!$site = get_site()) {
error("Site not found!");
}
//Checks for the required files/functions to restore every mod
$count = 0;
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$CFG->dirroot/mod/$modname/restorelib.php";
$modrestore = $modname."_restore_mods";
if (file_exists($modfile)) {
include_once($modfile);
if (function_exists($modrestore)) {
$var = "exists_".$modname;
$$var = true;
$count++;
}
}
//Check data
//Check module info
$var = "restore_".$modname;
if (!isset($$var)) {
$$var = 1;
}
//Check include user info
$var = "restore_user_info_".$modname;
if (!isset($$var)) {
$$var = 1;
}
}
}
//Check other parameters
if (!isset($restore_metacourse)) {
$restore_metacourse = 1;
}
if (!isset($restore_users)) {
$restore_users = 1;
}
if (!isset($restore_logs)) {
$restore_logs = 1;
}
if (!isset($restore_user_files)) {
$restore_user_files = 1;
}
if (!isset($restore_course_files)) {
$restore_course_files = 1;
}
if (!isset($restore_messages)) {
$restore_messages = 1;
}
if (!isset($restore_restoreto)) {
if (isteacheredit($id) and !isadmin()) {
$restore_restoreto = 1;
}
if (isadmin()) {
$restore_restoreto = 2;
}
}
if ($count == 0) {
notice("No restorable modules are installed!");
}
?>