Source for file import_backup.php
Documentation is available at import_backup.php
<?php // $Id: import_backup.php 15430 2008-05-26 20:46:31Z yannoo $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Bart Mollet (bart.mollet@hogent.be)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
==============================================================================
* ==============================================================================
* @author Bart Mollet <bart.mollet@hogent.be>
* ==============================================================================
==============================================================================
==============================================================================
// name of the language file that needs to be included
$language_file = array('coursebackup','admin');
// including the global file
include ('../inc/global.inc.php');
// Check access rights (only teachers are allowed here)
//remove memory and time limits as much as possible as this might be a long process...
ini_set('max_execution_time',1800);
$interbreadcrumb[] = array ("url" => "../course_info/maintenance.php", "name" => get_lang('Maintenance'));
// include additional libraries
include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
require_once('classes/CourseBuilder.class.php');
require_once('classes/CourseArchiver.class.php');
require_once('classes/CourseRestorer.class.php');
require_once('classes/CourseSelectForm.class.php');
// Display the tool title
==============================================================================
==============================================================================
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' )
if( $_POST['backup_type'] == 'server')
$filename = $_POST['backup_server'];
if($_FILES['backup']['error']== 0){
if(!$error && $course->has_resources())
$cr->set_file_option($_POST['same_file_name_option']);
'<a class="bottom-link" href="../course_home/course_home.php?'. api_get_cidreq(). '">>> '. get_lang('CourseHomepage'). '</a>',false);
'<a class="bottom-link" href="import_backup.php?'. api_get_cidreq(). '">>> '. get_lang('TryAgain'). '</a>',false);
elseif ($filename === false)
'<a class="bottom-link" href="import_backup.php?'. api_get_cidreq(). '">>> '. get_lang('TryAgain'). '</a>',false);
'<a class="bottom-link" href="import_backup.php?'. api_get_cidreq(). '">>> '. get_lang('TryAgain'). '</a>',false);
elseif (isset ($_POST['import_option']) && $_POST['import_option'] == 'select_items')
if( $_POST['backup_type'] == 'server')
$filename = $_POST['backup_server'];
if ($course->has_resources() && ($filename !== false))
elseif ($filename === false)
'<a class="bottom-link" href="import_backup.php?'. api_get_cidreq(). '">>> '. get_lang('TryAgain'). '</a>',false);
'<a class="bottom-link" href="import_backup.php?'. api_get_cidreq(). '">>> '. get_lang('TryAgain'). '</a>',false);
$backups_available = (count($backups)> 0);
echo get_lang('SelectBackupFile'). '<br /><br />';
include (api_get_path(LIBRARY_PATH). 'formvalidator/FormValidator.class.php');
$form = new FormValidator('import_backup_form','POST','import_backup.php', '','multipart/form-data');
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<div>{element}</div> ');
$form->addElement('hidden','action', 'restore_backup');
$form->addElement('radio', 'backup_type', '', get_lang('LocalFile'), 'local', 'id="bt_local" class="checkbox" onclick="javascript:document.import_backup_form.backup_server.disabled=true;document.import_backup_form.backup.disabled=false;"');
$form->addElement('file', 'backup', '', 'style="margin-left: 50px;"');
$form->addElement('html', '<br />');
if( $backups_available ){
$form->addElement('radio', 'backup_type', '', get_lang('ServerFile'), 'server', 'id="bt_server" class="checkbox" onclick="javascript:document.import_backup_form.backup_server.disabled=false;document.import_backup_form.backup.disabled=true;"');
foreach($backups as $index => $backup)
$options[$backup['file']]= $backup['course_code']. ' ('. $backup['date'];
$form->addElement('select', 'backup_server', '', $options, 'style="margin-left: 50px;"');
$form->addElement('html','<script type="text/javascript">document.import_backup_form.backup_server.disabled=true;</script>');
$form->addElement('radio', '', '', '<i>'. get_lang('NoBackupsAvailable'). '</i>', '', 'disabled="true"');
$form->addElement('html', '<br /><br />');
$form->addElement('radio', 'import_option', '', get_lang('ImportFullBackup'), 'full_backup', 'id="import_option_1" class="checkbox"');
$form->addElement('radio', 'import_option', '', get_lang('LetMeSelectItems'), 'select_items', 'id="import_option_2" class="checkbox"');
$form->addElement('html', '<br /><br />');
$form->addElement('html', get_lang('SameFilename'));
$form->addElement('html', '<br /><br />');
$form->addElement('radio', 'same_file_name_option', '', get_lang('SameFilenameSkip'), FILE_SKIP, 'id="same_file_name_option_1" class="checkbox"');
$form->addElement('radio', 'same_file_name_option', '', get_lang('SameFilenameRename'), FILE_RENAME, 'id="same_file_name_option_2" class="checkbox"');
$form->addElement('radio', 'same_file_name_option', '', get_lang('SameFilenameOverwrite'), FILE_OVERWRITE, 'id="same_file_name_option_3" class="checkbox"');
$form->addElement('html', '<br />');
$form->addElement('submit', null, get_lang('ImportBackup'));
$values['backup_type'] = 'local';
$values['import_option'] = 'full_backup';
$form->setDefaults($values);
$form->add_progress_bar();
==============================================================================
==============================================================================
|