demo.install 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // $Id: demo.install,v 1.9 2010/09/04 02:42:26 sun Exp $
  3. /**
  4. * @file
  5. * Demonstration site module installation functions.
  6. */
  7. /**
  8. * Implements hook_uninstall().
  9. */
  10. function demo_uninstall() {
  11. variable_del('demo_reset_last');
  12. }
  13. /**
  14. * Move existing dumps to new directory without site name sub-folder.
  15. */
  16. function demo_update_6100() {
  17. // If file_directory_path() contains the site name already or is
  18. // 'sites/all/files', create new folder without site name and move existing
  19. // files to the new location.
  20. $new_path = variable_get('demo_dump_path', file_directory_path() . '/demo');
  21. if (strpos($new_path, conf_path()) !== FALSE || strpos($new_path, '/all/') !== FALSE) {
  22. $old_path = $new_path . str_replace('sites', '', conf_path());
  23. if ($new_path != $old_path && file_check_directory($old_path)) {
  24. // Fetch list of available files.
  25. $files = file_scan_directory($old_path, '/\.(info|sql)$/');
  26. foreach ($files as $file) {
  27. rename($file->filename, $new_path . '/' . $file->basename);
  28. }
  29. // Ignore any warnings from rmdir() about remaining files in the old
  30. // directory (they will NOT be deleted).
  31. @rmdir($old_path);
  32. }
  33. }
  34. }
  35. /**
  36. * @todo Remove file_directory_path() from demo_dump_path variable.
  37. */