';
if (empty($to)) {
//Now print the Backup Name tr
echo "";
echo "";
echo get_string("name").":";
echo " ";
//Add as text field
echo " backup_name."\" />";
echo " ";
//Line
echo " ";
//Now print the To Do list
echo "";
echo "";
}
// Re-enforce 'moodle/site:backup' at system context to be able to backup all users
if ($backupprefs->backup_users == 0 and !has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
$backupprefs->backup_users = 1; // users => course
}
// Re-enforce moodle/backup:userinfo capability
if (!$backupuserinfo) {
$backupprefs->backup_users = 2; // users => none
}
//Here we check if backup_users = None. Then, we switch off every module
//user info, user_files, logs and exercises, workshop and messages & blogs backups. A Warning is showed to
//inform the user.
// TODO: Move this logic to one function to be shared by any (manual, scheduled) backup
if ($backupprefs->backup_users == 2) {
if ($allmods = get_records('modules') ) {
foreach ($allmods as $mod) {
/// Reset global user_info settings to "no" (0)
$modname = $mod->name;
$var = 'backup_user_info_'.$modname;
if (isset($backupprefs->$var)) {
$backupprefs->$var = 0;
}
/// Reset each instance userinfo settings to "no" (0)
if (isset($backupprefs->mods[$modname])) {
/// Set the module userinfo to no (0)
$backupprefs->mods[$modname]->userinfo = 0;
/// Set the instances to no (o)
foreach ($backupprefs->mods[$modname]->instances as $key => $instance) {
$backupprefs->mods[$modname]->instances[$key]->userinfo = 0;
$var = 'backup_user_info_' . $modname . '_instance_' . $key;
$backupprefs->$var = 0;
}
}
/// If modules are workshop or exercise, disable their backup completely
if ($modname == 'exercise' || $modname == 'workshop') {
$var = 'backup_'.$modname;
if (isset($backupprefs->$var)) {
$backupprefs->$var = 0;
/// Reset each instance backup settings to "no" (0)
if (isset($backupprefs->mods[$modname])) {
/// Set the module backup to no (0)
$backupprefs->mods[$modname]->backup = 0;
$var = 'backup_' . $modname . '_instances';
$backupprefs->$var = 0;
/// Set the instances backup to no (o)
foreach ($backupprefs->mods[$modname]->instances as $key => $instance) {
$backupprefs->mods[$modname]->instances[$key]->backup = 0;
$var = 'backup_' . $modname . '_instance_' . $key;
$backupprefs->$var = 0;
}
}
}
}
}
}
$backupprefs->backup_user_files = 0;
$backupprefs->backup_logs = 0;
$backupprefs->backup_messages = 0;
$backupprefs->backup_blogs = 0;
$backupprefs->backuproleassignments = array();
if ($backupuserinfo) { // Based on perms, decide the msg to show
$nousersmsgtoshow = 'backupnoneusersinfo';
} else {
$nousersmsgtoshow = 'backupmissinguserinfoperms';
}
print_simple_box("".get_string($nousersmsgtoshow)." ","center", "70%", '', "20", "noticebox");
echo " ";
}
if (empty($to)) {
echo get_string("backupdetails").":";
echo " ";
}
//This is the alignment of every row in the table
$table->align = array ("left","right");
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = $CFG->dirroot.'/mod/'.$modname.'/backuplib.php';
if (!file_exists($modfile)) {
continue;
}
require_once($modfile);
$modbackup = $modname."_backup_mods";
//If exists the lib & function
$var = "exists_".$modname;
if (isset($backupprefs->$var) && $backupprefs->$var) {
$var = "backup_".$modname;
//Only if selected
if (!empty($backupprefs->$var) and ($backupprefs->$var == 1)) {
//Print the full tr
echo "";
echo "";
//Print the mod name
echo "".get_string("include")." ".get_string("modulenameplural",$modname)." ";
//Now look for user-data status
$backup_user_options[0] = get_string("withoutuserdata");
$backup_user_options[1] = get_string("withuserdata");
$var = "backup_user_info_".$modname;
//Print the user info
echo $backup_user_options[$backupprefs->$var]." ";
//Call the check function to show more info
$modcheckbackup = $modname."_check_backup_mods";
$var = $modname.'_instances';
$instancestopass = array();
if (!empty($backupprefs->$var) && is_array($backupprefs->$var) && count($backupprefs->$var)) {
$table->data = array();
$countinstances = 0;
foreach ($backupprefs->$var as $instance) {
$var1 = 'backup_'.$modname.'_instance_'.$instance->id;
$var2 = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
if (!empty($backupprefs->$var1)) {
$obj = new StdClass;
$obj->name = $instance->name;
$obj->userdata = $backupprefs->$var2;
$obj->id = $instance->id;
$instancestopass[$instance->id]= $obj;
$countinstances++;
}
}
}
$table->data = $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code,$instancestopass);
print_table($table);
echo " ";
}
}
}
if (empty($to)) {
//Line
echo " ";
//Now print the Users tr
echo "";
echo "";
$user_options[0] = get_string("includeallusers");
$user_options[1] = get_string("includecourseusers");
$user_options[2] = get_string("includenoneusers");
echo $user_options[$backupprefs->backup_users].' ';
//Print info
$table->data = user_check_backup($id,$backupprefs->backup_unique_code,$backupprefs->backup_users,$backupprefs->backup_messages, $backupprefs->backup_blogs);
print_table($table);
echo " ";
}
//Now print the Logs tr conditionally
if ($backupprefs->backup_logs && empty($to)) {
echo "";
echo "";
echo get_string("includelogentries").' ';
//Print info
$table->data = log_check_backup($id);
print_table($table);
echo " ";
}
//Now print the User Files tr conditionally
if ($backupprefs->backup_user_files) {
echo "";
echo "";
echo get_string("includeuserfiles").' ';
//Print info
$table->data = user_files_check_backup($id,$backupprefs->backup_unique_code);
print_table($table);
echo " ";
}
//Now print the Course Files tr conditionally
if ($backupprefs->backup_course_files) {
echo "";
echo "";
echo get_string("includecoursefiles").' ';
//Print info
$table->data = course_files_check_backup($id,$backupprefs->backup_unique_code);
print_table($table);
echo " ";
}
//Now print the site Files tr conditionally
if ($backupprefs->backup_site_files) {
echo "";
echo "";
echo get_string("includesitefiles").' ';
//Print info
$table->data = site_files_check_backup($id,$backupprefs->backup_unique_code);
print_table($table);
echo " ";
}
//Now print the role assignments information conditionally
if (!empty($backupprefs->backuproleassignments)) {
echo "";
echo "";
echo get_string("includeroleassignments").' ';
//Print info
$table->data = array(array(get_string('roles'), count($backupprefs->backuproleassignments)));
print_table($table);
echo " ";
}
}
// now keep it for next time.
$SESSION->backupprefs[$course->id] = $backupprefs;
?>