Commit 0eaaba42 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Importing all the sites on a platform now works in the provision backend

parent a9aed498
......@@ -338,7 +338,9 @@ function provision_drupal_provision_verify($url, &$data) {
$data['themes'] = system_theme_data();
$sites = provision_drupal_find_sites();
$data['sites'] = array_keys($sites); // return list of hosted sites. used to determine whether or not to import.
}
/**
......@@ -383,8 +385,14 @@ function provision_drupal_provision_delete($url, $data) {
}
function provision_drupal_find_sites() {
$sitephp = file_scan_directory('./sites', 'site\.php$', array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name', 0);
$settingsphp = file_scan_directory('./sites', 'site\.php$', array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name', 0);
$sitephp = file_scan_directory('./sites', 'settings\.php$', array('.', '..', 'CVS', '.svn'), 0, TRUE, 'filename', 0);
foreach ($sitephp as $file => $info) {
$path = explode("/", $file);
array_pop($path);
$sites[array_pop($path)] = $file;
}
return $sites;
}
function provision_drupal_restore($url, $backup_file, &$data) {
......@@ -406,3 +414,37 @@ function _provision_drupal_get_cvs_versions($files) {
return $files;
}
function provision_drupal_provision_import($url, &$data) {
$sites = provision_drupal_find_sites();
foreach ($sites as $site => $file) {
if ($site != 'default') {
$info = _provision_drupal_import_site($site);
if ($info['site_installed']) {
provision_log("notice", "Returning information for $site");
$data['sites'][$site] = $info;
}
}
}
}
function _provision_drupal_import_site($url) {
if (!($data = provision_get_site_data($url))) {
$data = array(); // initialize site data to empty array
}
include_once("sites/$url/settings.php");
if ($parts = @parse_url($db_url)) {
$data['site_db_type'] = $parts['scheme'];
$data['site_db_user'] = $parts['user'];
$data['site_db_host'] = $parts['host'];
$data['site_db_passwd'] = $parts['pass'];
$data['site_db_name'] = substr($parts['path'], 1);
$data['site_profile'] = $installed_profile;
$data['site_installed'] = TRUE;
provision_save_site_data($url, $data);
}
return $data;
}
......@@ -533,26 +533,8 @@ function _provision_backup_site($url, &$data, $file = null) {
* Output of provision_output() function.
* Will exit with a PROVISION_SITE_NOT_FOUND error if the site does not exist.
*/
function _provision_import($url) {
if (!_provision_drupal_site_exists($url)) {
provision_log("Error", "Site directory is not present, and can not be imported.");
provision_set_error(PROVISION_SITE_NOT_FOUND);
provision_output($url, $data);
}
$data = provision_get_site_data($url);
include_once("sites/$url/settings.php");
$parts = parse_url($db_url);
$data['site_db_type'] = $parts['scheme'];
$data['site_db_user'] = $parts['user'];
$data['site_db_host'] = $parts['host'];
$data['site_db_passwd'] = $parts['pass'];
$data['site_db_name'] = substr($parts['path'], 1);
$data['site_profile'] = $installed_profile;
provision_save_site_data($url, $data);
function _provision_import($url = null) {
$rolled_back = provision_invoke("import", $url, $data);
provision_output($url, $data);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment