create_backup.php 4.0 KB

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