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!"); } ?>
shortname); if (empty($backup_shortname) or $backup_shortname == '_' ) { $backup_shortname = $course->id; } //Calculate the final backup filename //The backup word $backup_name = $backup_word."-"; //The shortname $backup_name .= strtolower($backup_shortname)."-"; //The date format $backup_name .= userdate(time(),$backup_date_format,99,false); //The extension $backup_name .= ".zip"; //And finally, clean everything $backup_name = clean_filename($backup_name); //Calculate the backup unique code to allow simultaneus backups (to define //the temp-directory name and records in backup temp tables $backup_unique_code = time(); //Add as hidden name echo ""; if (empty($to)) { //Now print the Backup Name tr echo ""; echo ""; //Line echo ""; //Now print the To Do list echo ""; echo ""; } //This is tha align to every ingo table $table->align = array ("left","right"); if ($allmods = get_records("modules") ) { foreach ($allmods as $mod) { $modname = $mod->name; $modbackup = $modname."_backup_mods"; //If exists the lib & function $var = "exists_".$modname; if (isset($$var) && $$var) { //Add hidden fields $var = "backup_".$modname; echo ""; $var = "backup_user_info_".$modname; echo ""; $var = "backup_".$modname; //Only if selected if ($$var == 1) { //Print the full tr echo ""; echo ""; } } } //Write metacourse hidden field echo ""; if (empty($to)) { //Line echo ""; //Now print the Users tr echo ""; echo ""; } //Add as hidden name echo ""; //Now print the Logs tr conditionally if ($backup_logs && empty($to)) { echo ""; echo ""; } //Add as hidden name echo ""; //Now print the User Files tr conditionally if ($backup_user_files) { echo ""; echo ""; } //Add as hidden name echo ""; //Now print the Course Files tr conditionally if ($backup_course_files) { echo ""; echo ""; } //Add as hidden name echo ""; } ?>

"; echo get_string("name").":"; echo "

"; //Add as text field echo ""; echo "

"; } else { echo ''; } //Here we check if backup_users = None. Then, we switch off every module //user info, user_files, logs and exercises and workshop backups. A Warning is showed to //inform the user. if ($backup_users == 2) { if ($allmods = get_records("modules") ) { foreach ($allmods as $mod) { $modname = $mod->name; $var = "backup_user_info_".$modname; if (isset($$var)) { $$var = 0; } $var = "backup_".$modname; if (isset($$var)) { if ($modname == "exercise" || $modname == "workshop") { $$var = 0; } } } $backup_user_files = 0; $backup_logs = 0; } print_simple_box("".get_string("backupnoneusersinfo")."","center", "70%", '', "20", "noticebox"); echo "


"; } if (empty($to)) { echo get_string("backupdetails").":"; 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[$$var]."

    "; //Call the check function to show more info $modcheckbackup = $modname."_check_backup_mods"; $table->data = $modcheckbackup($id,$$var,$backup_unique_code); print_table($table); echo "


  • "; $user_options[0] = get_string("includeallusers"); $user_options[1] = get_string("includecourseusers"); $user_options[2] = get_string("includenoneusers"); echo "

  • ".$user_options[$backup_users]."

    "; //Print info $table->data = user_check_backup($id,$backup_unique_code,$backup_users); print_table($table); echo "

  • "; echo "

  • ".get_string("includelogentries")."

    "; //Print info $table->data = log_check_backup($id); print_table($table); echo "

  • "; echo "

  • ".get_string("includeuserfiles")."

    "; //Print info $table->data = user_files_check_backup($id,$backup_unique_code); print_table($table); echo "

  • "; echo "

  • ".get_string("includecoursefiles")."

    "; //Print info $table->data = course_files_check_backup($id,$backup_unique_code); print_table($table); echo "


  • " /> " />