id)) {
if (!isteacheredit($course->id)) {
if (empty($to)) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
} else {
if (!isteacheredit($to)) {
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 backup every mod
//And check if there is data about it
$count = 0;
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
include_once($modfile);
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
$var = "exists_".$modname;
$$var = true;
$count++;
}
}
//Check data
//Check module info
$var = "backup_".$modname;
if (!isset($$var)) {
$$var = 1;
}
//Check include user info
$var = "backup_user_info_".$modname;
if (!isset($$var)) {
$$var = 1;
}
}
}
//Check other parameters
if (!isset($backup_metacourse)) {
$backup_metacourse = 1;
}
if (!isset($backup_users)) {
$backup_users = 1;
}
if (!isset($backup_logs)) {
$backup_logs = 0;
}
if (!isset($backup_user_files)) {
$backup_user_files = 1;
}
if (!isset($backup_course_files)) {
$backup_course_files = 2;
}
if ($count == 0) {
notice("No backupable modules are installed!");
}
?>