id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $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 (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
}
}
$backupuserinfo = has_capability('moodle/backup:userinfo', get_context_instance(CONTEXT_COURSE, $course->id));
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
$backupuserinfo = has_capability('moodle/backup:userinfo', get_context_instance(CONTEXT_SYSTEM));
}
//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', 'visible', 1) ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modbackupone = $modname.'_backup_one_mod';
$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 that there are instances and we can back them up individually
if (count_records('course_modules','course',$course->id,'module',$mod->id) && function_exists($modbackupone)) {
$var = 'exists_one_'.$modname;
$$var = true;
}
}
}
//Check data
//Check module info
$var = "backup_".$modname;
$$var = optional_param( $var,1);
//Check include user info
$var = "backup_user_info_".$modname;
$$var = optional_param( $var,1);
}
}
//Check other parameters
$backup_metacourse = optional_param('backup_metacourse',1);
$backup_users = optional_param('backup_users',1);
$backup_logs = optional_param('backup_logs',0);
$backup_user_files = optional_param('backup_user_files',1);
$backup_course_files = optional_param('backup_course_files',1);
$backup_site_files = optional_param('backup_site_files',1);
$backup_gradebook_history = optional_param('backup_gradebook_history', 0, PARAM_INT);
$backup_messages = optional_param('backup_messages',1);
$backup_blogs = optional_param('backup_blogs',1);
if ($count == 0) {
notice("No backupable modules are installed!");
}
?>