* @package dokeos.backup * ============================================================================== */ /* ============================================================================== INIT SECTION ============================================================================== */ // name of the language file that needs to be included $language_file = 'coursebackup'; include ('../inc/global.inc.php'); include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php'); $nameTools = get_lang('ImportBackup'); Display::display_header($nameTools); require_once('classes/CourseBuilder.class.php'); require_once('classes/CourseArchiver.class.php'); require_once('classes/CourseRestorer.class.php'); require_once('classes/CourseSelectForm.class.php'); api_display_tool_title($nameTools); if( ! api_is_allowed_to_edit()) { api_not_allowed(); } /* ============================================================================== MAIN CODE ============================================================================== */ if( (isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (isset($_POST['import_option']) && $_POST['import_option'] == 'full_backup' ) ) { if(isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) { $course = CourseSelectForm::get_posted_course(); } else { if( $_POST['backup_type'] == 'server') { $filename = $_POST['backup_server']; $delete_file = false; } else { $filename = CourseArchiver::import_uploaded_file($_FILES['backup']['tmp_name']); $delete_file = true; } $course = CourseArchiver::read_course($filename,$delete_file); } if( $course->has_resources()) { $cr = new CourseRestorer($course); $cr->set_file_option($_POST['same_file_name_option']); $cr->restore(); echo get_lang('ImportFinished'); } else { echo get_lang('NoResourcesInBackupFile'); } CourseArchiver::clean_backup_dir(); echo '

<< '.get_lang('CourseHomepage').'

'; } elseif( isset($_POST['import_option']) && $_POST['import_option'] == 'select_items') { if( $_POST['backup_type'] == 'server') { $filename = $_POST['backup_server']; $delete_file = false; } else { $filename = CourseArchiver::import_uploaded_file($_FILES['backup']['tmp_name']); $delete_file = true; } $course = CourseArchiver::read_course($filename,$delete_file); if( $course->has_resources()) { CourseSelectForm::display_form($course,array('same_file_name_option'=>$_POST['same_file_name_option'])); } else { echo get_lang('NoResourcesInBackupFile'); echo '

<< '.get_lang('CourseHomepage').'

'; } } else { $user = api_get_user_info(); $backups = CourseArchiver::get_available_backups($is_platformAdmin?null:$user['user_id']); $backups_available = (count($backups)>0); ?>



(*.zip)
'; echo ''.get_lang('NoBackupsAvailable').'

'; } ?>