demo.install in Demonstration site (Sandbox / Snapshot) 6
Same filename and directory in other branches
Demonstration site module installation functions.
File
demo.installView source
<?php
/**
* @file
* Demonstration site module installation functions.
*/
/**
* Implements hook_uninstall().
*/
function demo_uninstall() {
variable_del('demo_reset_last');
}
/**
* Move existing dumps to new directory without site name sub-folder.
*/
function demo_update_6100() {
$ret = array();
// If file_directory_path() contains the site name already or is
// 'sites/all/files', create new folder without site name and move existing
// files to the new location.
$new_path = variable_get('demo_dump_path', file_directory_path() . '/demo');
if (strpos($new_path, conf_path()) !== FALSE || strpos($new_path, '/all/') !== FALSE) {
$old_path = $new_path . str_replace('sites', '', conf_path());
if ($new_path != $old_path && file_check_directory($old_path)) {
// Fetch list of available files.
$files = file_scan_directory($old_path, '\\.(info|sql)$');
foreach ($files as $file) {
rename($file->filename, $new_path . '/' . $file->basename);
}
// Ignore any warnings from rmdir() about remaining files in the old
// directory (they will NOT be deleted).
@rmdir($old_path);
$ret[] = array(
'success' => TRUE,
'query' => strtr('Demo snapshot files have been successfully moved to <em>%path</em>.', array(
'%path' => $new_path,
)),
);
}
}
return $ret;
}
Functions
Name | Description |
---|---|
demo_uninstall | Implements hook_uninstall(). |
demo_update_6100 | Move existing dumps to new directory without site name sub-folder. |