create_backup.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. // $Id: create_backup.php 11389 2007-03-05 10:46:21Z elixir_julian $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. Copyright (c) Bart Mollet (bart.mollet@hogent.be)
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  18. Mail: info@dokeos.com
  19. ==============================================================================
  20. */
  21. /**
  22. * ==============================================================================
  23. * Create a backup.
  24. *
  25. * @author Bart Mollet <bart.mollet@hogent.be>
  26. * @package dokeos.backup
  27. * ==============================================================================
  28. */
  29. /*
  30. ==============================================================================
  31. INIT SECTION
  32. ==============================================================================
  33. */
  34. // name of the language file that needs to be included
  35. //$language_file = 'coursebackup';
  36. $language_file = array ('admin','coursebackup');
  37. include ('../inc/global.inc.php');
  38. include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
  39. $nameTools = get_lang('CreateBackup');
  40. $interbreadcrumb[] = array ("url" => "../course_info/maintenance.php", "name" => get_lang('Maintenance'));
  41. Display::display_header($nameTools);
  42. require_once ('classes/CourseBuilder.class.php');
  43. require_once ('classes/CourseArchiver.class.php');
  44. require_once ('classes/CourseRestorer.class.php');
  45. require_once ('classes/CourseSelectForm.class.php');
  46. api_display_tool_title($nameTools);
  47. if (!api_is_allowed_to_edit())
  48. {
  49. api_not_allowed();
  50. }
  51. /*
  52. ==============================================================================
  53. MAIN CODE
  54. ==============================================================================
  55. */
  56. if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup'))
  57. {
  58. if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form')
  59. {
  60. $course = CourseSelectForm :: get_posted_course();
  61. }
  62. else
  63. {
  64. $cb = new CourseBuilder();
  65. $course = $cb->build();
  66. }
  67. $zip_file = CourseArchiver :: write_course($course);
  68. echo get_lang('BackupCreated').'<br/><br/><a href="../course_info/download.php?archive='.$zip_file.'">'.$zip_file.'</a>';
  69. echo '<p><a href="../course_home/course_home.php">&lt;&lt; '.get_lang('CourseHomepage').'</a></p>';
  70. ?>
  71. <!-- Manual download <script language="JavaScript">
  72. setTimeout('download_backup()',2000);
  73. function download_backup()
  74. {
  75. window.location="../course_info/download.php?archive=<?php echo $zip_file ?>";
  76. }
  77. </script> //-->
  78. <?php
  79. }
  80. elseif (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'select_items')
  81. {
  82. $cb = new CourseBuilder();
  83. $course = $cb->build();
  84. CourseSelectForm :: display_form($course);
  85. }
  86. else
  87. {
  88. $cb = new CourseBuilder();
  89. $course = $cb->build();
  90. if (!$course->has_resources())
  91. {
  92. echo get_lang('NoResourcesToBackup');
  93. }
  94. else
  95. {
  96. echo get_lang('SelectOptionForBackup');
  97. include (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  98. $form = new FormValidator('create_backup_form','POST');
  99. $renderer = $form->defaultRenderer();
  100. $renderer->setElementTemplate('<div>{element}</div> ');
  101. $form->addElement('radio', 'backup_option', '', get_lang('CreateFullBackup'), 'full_backup');
  102. $form->addElement('radio', 'backup_option', '', get_lang('LetMeSelectItems'), 'select_items');
  103. $form->addElement('html','<br/>');
  104. $form->addElement('submit', null, get_lang('CreateBackup'));
  105. $form->add_progress_bar();
  106. $values['backup_option'] = 'full_backup';
  107. $form->setDefaults($values);
  108. $form->display();
  109. }
  110. }
  111. /*
  112. ==============================================================================
  113. FOOTER
  114. ==============================================================================
  115. */
  116. Display::display_footer();
  117. ?>