create_backup.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // $Id: create_backup.php 10204 2006-11-26 20:46:53Z pcool $
  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. include ('../inc/global.inc.php');
  37. include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
  38. $nameTools = get_lang('CreateBackup');
  39. Display::display_header($nameTools);
  40. require_once ('classes/CourseBuilder.class.php');
  41. require_once ('classes/CourseArchiver.class.php');
  42. require_once ('classes/CourseRestorer.class.php');
  43. require_once ('classes/CourseSelectForm.class.php');
  44. api_display_tool_title($nameTools);
  45. if (!api_is_allowed_to_edit())
  46. {
  47. api_not_allowed();
  48. }
  49. /*
  50. ==============================================================================
  51. MAIN CODE
  52. ==============================================================================
  53. */
  54. if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup'))
  55. {
  56. if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form')
  57. {
  58. $course = CourseSelectForm :: get_posted_course();
  59. }
  60. else
  61. {
  62. $cb = new CourseBuilder();
  63. $course = $cb->build();
  64. }
  65. $zip_file = CourseArchiver :: write_course($course);
  66. echo get_lang('BackupCreated').'<br/><br/><a href="../course_info/download.php?archive='.$zip_file.'">'.$zip_file.'</a>';
  67. echo '<p><a href="../course_home/course_home.php">&lt;&lt; '.get_lang('CourseHomepage').'</a></p>';
  68. ?>
  69. <!-- Manual download <script language="JavaScript">
  70. setTimeout('download_backup()',2000);
  71. function download_backup()
  72. {
  73. window.location="../course_info/download.php?archive=<?php echo $zip_file ?>";
  74. }
  75. </script> //-->
  76. <?php
  77. }
  78. elseif (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'select_items')
  79. {
  80. $cb = new CourseBuilder();
  81. $course = $cb->build();
  82. CourseSelectForm :: display_form($course);
  83. }
  84. else
  85. {
  86. $cb = new CourseBuilder();
  87. $course = $cb->build();
  88. if (!$course->has_resources())
  89. {
  90. echo get_lang('NoResourcesToBackup');
  91. }
  92. else
  93. {
  94. echo get_lang('SelectOptionForBackup')
  95. ?>
  96. <form method="post">
  97. <input type="radio" class="checkbox" id="backup_option_1" name="backup_option" value="full_backup" checked="checked"/>
  98. <label for="backup_option_1"><?php echo get_lang('CreateFullBackup') ?></label>
  99. <br/>
  100. <input type="radio" class="checkbox" id="backup_option_2" name="backup_option" value="select_items"/>
  101. <label for="backup_option_2"><?php echo get_lang('LetMeSelectItems') ?></label>
  102. <br/>
  103. <br/>
  104. <input type="submit" value="<?php echo get_lang('CreateBackup') ?>"/>
  105. </form>
  106. <?php
  107. }
  108. }
  109. /*
  110. ==============================================================================
  111. FOOTER
  112. ==============================================================================
  113. */
  114. Display::display_footer();
  115. ?>