update-files-1.8.5-1.8.6.inc.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Dokeos files from version 1.8.5 to version 1.8.6
  7. * This script operates only in the case of an update, and only to change the
  8. * active version number (and other things that might need a change) in the
  9. * current configuration file.
  10. * As of 1.8.6, the Dokeos version has been added to configuration.php to
  11. * allow for edition (inc/conf is one of the directories that needs write
  12. * permissions on upgrade).
  13. * Being in configuration.php, it benefits from the configuration.dist.php
  14. * advantages that a new version doesn't overwrite it, thus letting the old
  15. * version be available until the end of the installation.
  16. * @package chamilo.install
  17. */
  18. Log::notice('Entering file');
  19. if (defined('SYSTEM_INSTALLATION')) {
  20. // Edit the configuration file
  21. $file = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php');
  22. $fh = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w');
  23. $found_version = false;
  24. $found_stable = false;
  25. foreach ($file as $line) {
  26. $ignore = false;
  27. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  28. $found_version = true;
  29. $line = '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n";
  30. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  31. $found_stable = true;
  32. $line = '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n";
  33. } elseif (stripos($line, '$userPasswordCrypted') !== false) {
  34. $line = '$userPasswordCrypted = \'' . ($userPasswordCrypted) . '\';' . "\r\n";
  35. } elseif (stripos($line, '?>') !== false) {
  36. // Ignore the line
  37. $ignore = true;
  38. }
  39. if (!$ignore) {
  40. fwrite($fh, $line);
  41. }
  42. }
  43. if (!$found_version) {
  44. fwrite($fh, '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n");
  45. }
  46. if (!$found_stable) {
  47. fwrite($fh, '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n");
  48. }
  49. fwrite($fh, '?>');
  50. fclose($fh);
  51. $sys_course_path = $pathForm . 'courses/';
  52. //$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  53. //// Linking (The following line is disabled, connection has been already done)
  54. //$res = @iDatabase::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
  55. //iDatabase::select_db($dbNameForm, $link);
  56. iDatabase::select_db($dbNameForm);
  57. $db_name = $dbNameForm;
  58. $sql = "SELECT * FROM $db_name.course";
  59. Log::notice('Getting courses for files updates: ' . $sql);
  60. $result = iDatabase::query($sql);
  61. while ($courses_directories = iDatabase::fetch_array($result)) {
  62. $currentCourseRepositorySys = $sys_course_path . $courses_directories['directory'] . '/';
  63. $db_name = $courses_directories['db_name'];
  64. $origCRS = $updatePath . 'courses/' . $courses_directories['directory'];
  65. if (!is_dir($origCRS)) {
  66. Log::error('Directory ' . $origCRS . ' does not exist. Skipping.');
  67. continue;
  68. }
  69. // Move everything to the new hierarchy (from old path to new path)
  70. Log::notice('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories['directory']);
  71. rename($origCRS, $sys_course_path . $courses_directories['directory']);
  72. Log::notice('Creating dirs in ' . $currentCourseRepositorySys);
  73. // DOCUMENT FOLDER
  74. // document > shared_folder
  75. if (!is_dir($currentCourseRepositorySys . "document/shared_folder")) {
  76. mkdir($currentCourseRepositorySys . "document/shared_folder", $perm);
  77. }
  78. // UPLOAD FOLDER
  79. // upload > forum > images
  80. if (!is_dir($currentCourseRepositorySys . "upload/forum/images")) {
  81. mkdir($currentCourseRepositorySys . "upload/forum/images", $perm);
  82. }
  83. // upload > learning_path
  84. if (!is_dir($currentCourseRepositorySys . "upload/learning_path")) {
  85. mkdir($currentCourseRepositorySys . "upload/learning_path", $perm);
  86. }
  87. // upload > learning_path > images
  88. if (!is_dir($currentCourseRepositorySys . "upload/learning_path/images")) {
  89. mkdir($currentCourseRepositorySys . "upload/learning_path/images", $perm);
  90. }
  91. // upload > calendar
  92. if (!is_dir($currentCourseRepositorySys . "upload/calendar")) {
  93. mkdir($currentCourseRepositorySys . "upload/calendar", $perm);
  94. }
  95. // upload > calendar > images
  96. if (!is_dir($currentCourseRepositorySys . "upload/calendar/images")) {
  97. mkdir($currentCourseRepositorySys . "upload/calendar/images", $perm);
  98. }
  99. }
  100. } else {
  101. echo 'You are not allowed here !' . __FILE__;
  102. }