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!"); } ?>
'; /// Acummulator for hidden options and proper XHTML output $hidden_options = ''; //Now, check modules and info and show posibilities if ($allmods = get_records('modules', 'visible', 1) ) { //Print option to select/deselect everything with 1 click. echo ""; echo ""; if (empty($to) and $backupuserinfo) { echo ""; } else { echo ""; } echo ""; echo ""; $currentrow = 0; foreach ($allmods as $mod) { $modname = $mod->name; $modbackup = $modname."_backup_mods"; //If exists the lib & function $var = 'exists_'.$modname; $exvar = 'exists_one_'.$modname; if (!empty($$var) and !empty($$exvar)) { //Print the full tr echo ""; echo " \n"; echo ''; } } //Line echo "\n"; if (empty($to) && !empty($course->metacourse)) { //Now print the Metacourse tr echo ""; echo ""; } else { $hidden_options .= ''; } if (empty($to) and $backupuserinfo) { //Now print the Users tr echo ""; echo ""; } else { $hidden_options .= ''; } if (empty($to) and $backupuserinfo) { //Now print the Logs tr echo ""; echo ""; } else { $hidden_options .= ''; } if (empty($to) and $backupuserinfo) { //Now print the User Files tr echo ""; echo ""; } else { $hidden_options .= ''; } //Now print the Course Files tr echo ""; echo ""; if ($course->id != SITEID){ //Now print the site Files tr echo ""; echo ""; } // do you want grade histories to be backed up? if (empty($to) and $backupuserinfo and empty($CFG->disablegradehistory)) { echo ""; echo ""; } else { $hidden_options .= ''; } if (empty($to) and $backupuserinfo and $course->id == SITEID) { //If we are in a SITEID backup print the Messages tr echo ""; echo ""; } else { $hidden_options .= ''; } if (empty($to) and $backupuserinfo and $course->id == SITEID and !empty($CFG->bloglevel)) { //If we are in a SITEID backup and blogs are enabled print the Blogs tr echo ""; echo ""; } else { $hidden_options .= ''; } } //Now print a place to select which role assignments to back up. if (empty($to) and $backupuserinfo) { //Line echo "\n"; echo ""; echo ""; } $backup_unique_code = time(); //Calculate the backup string //Calculate the backup unique code to allow simultaneus backups (to define //the temp-directory name and records in backup temp tables $backup_name = backup_get_zipfile_name($course, $backup_unique_code); ?>
"; echo ''.get_string("include").""; echo ""; echo "". get_string("all")."/"; echo "". get_string("none").""; echo ""; echo ' '; echo ""; echo "". get_string("all")."/"; echo "". get_string("none").""; echo " 

 "; echo "\n"; $backup_options[0] = get_string("no"); $backup_options[1] = get_string("yes"); $var = "backup_".$modname; //choose_from_menu($backup_options, $var, $$var, ""); //Print the checkbox print_checkbox($var, $$var, $$var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'backup_'.$modname.'\',this.checked)'); echo " "; echo ""; $var = "backup_user_info_".$modname; if (empty($to) and $backupuserinfo) { $backup_user_options[0] = get_string("withoutuserdata"); $backup_user_options[1] = get_string("withuserdata"); //choose_from_menu($backup_user_options, $var, $$var, ""); print_checkbox($var, $$var, $$var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'backup_user_info_'.$modname.'\',this.checked)'); } else { echo ''; } echo "
'; $instances = get_all_instances_in_course($modname, $course, NULL, true); $var = $exvar; foreach ($instances as $instance) { echo ''; } echo '
'; $var = 'backup_'.$modname.'_instance_'.$instance->id; $$var = optional_param($var,1); print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'backup_'.$modname.'\'].checked=1;'); echo ' '; $var = 'backup_user_info_'.$modname.'_instance_'.$instance->id; $$var = optional_param($var,1); if (empty($to) and $backupuserinfo) { print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'backup_user_info_'.$modname.'\'].checked=1;'); } else { echo ''; } echo '

"; echo ''; echo ""; $meta_options[0] = get_string("no"); $meta_options[1] = get_string("yes"); choose_from_menu($meta_options, "backup_metacourse", $backup_metacourse, ""); echo "
"; echo ''; echo ""; if (has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) { $user_options[0] = get_string("all"); } $user_options[1] = get_string("course"); $user_options[2] = get_string("none"); choose_from_menu($user_options, "backup_users", $backup_users, ""); echo "
"; echo ''; echo ""; $log_options[0] = get_string("no"); $log_options[1] = get_string("yes"); choose_from_menu($log_options, "backup_logs", $backup_logs, ""); echo "
"; echo ''; echo ""; $user_file_options[0] = get_string("no"); $user_file_options[1] = get_string("yes"); choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, ""); echo "
"; echo ''; echo ""; $course_file_options[0] = get_string("no"); $course_file_options[1] = get_string("yes"); choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, ""); echo "
"; echo ''; helpbutton('sitefilesused', get_string('sitefilesused')); echo ""; $course_file_options[0] = get_string("no"); $course_file_options[1] = get_string("yes"); choose_from_menu($course_file_options, "backup_site_files", $backup_site_files, ""); echo "
"; echo ''; echo ""; $gradebook_history_options[0] = get_string("no"); $gradebook_history_options[1] = get_string("yes"); choose_from_menu($gradebook_history_options, "backup_gradebook_history", $backup_gradebook_history, ""); echo "
"; echo ''; echo ""; $mess_options[0] = get_string("no"); $mess_options[1] = get_string("yes"); choose_from_menu($mess_options, "backup_messages", $backup_messages, ""); echo "
"; echo get_string ('blogs','blog').":"; echo ""; $blog_options[0] = get_string("no"); $blog_options[1] = get_string("yes"); choose_from_menu($blog_options, "backup_blogs", $backup_blogs, ""); echo "

"; echo get_string("backuproleassignments"); echo ""; $roles = get_records('role', '', '', 'sortorder'); foreach ($roles as $role) { print_checkbox('backupassignments_' . $role->shortname, 1, true, strip_tags(format_string($role->name, true))); echo "
"; } echo "". get_string("all")."/"; echo "". get_string("none").""; echo "
" /> " />