| 1 |
<?php
|
| 2 |
// $Id: demo.install,v 1.5 2009/05/16 17:54:40 sun Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Demonstration site module installation functions.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Move existing dumps to new directory without site name sub-folder.
|
| 11 |
*/
|
| 12 |
function demo_update_6100() {
|
| 13 |
$ret = array();
|
| 14 |
|
| 15 |
// If file_directory_path() contains the site name already or is
|
| 16 |
// 'sites/all/files', create new folder without site name and move existing
|
| 17 |
// files to the new location.
|
| 18 |
$new_path = variable_get('demo_dump_path', file_directory_path() . '/demo');
|
| 19 |
if (strpos($new_path, conf_path()) !== FALSE || strpos($new_path, '/all/') !== FALSE) {
|
| 20 |
$old_path = $new_path . str_replace('sites', '', conf_path());
|
| 21 |
if ($new_path != $old_path && file_check_directory($old_path)) {
|
| 22 |
// Fetch list of available files.
|
| 23 |
$files = file_scan_directory($old_path, '/\.(info|sql)$/');
|
| 24 |
foreach ($files as $file) {
|
| 25 |
rename($file->filename, $new_path . '/' . $file->basename);
|
| 26 |
}
|
| 27 |
// Ignore any warnings from rmdir() about remaining files in the old
|
| 28 |
// directory (they will NOT be deleted).
|
| 29 |
@rmdir($old_path);
|
| 30 |
$ret[] = array('success' => TRUE, 'query' => strtr('Demo snapshot files have been successfully moved to <em>%path</em>.', array('%path' => $new_path)));
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|
| 34 |
return $ret;
|
| 35 |
}
|
| 36 |
|