summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Rossouw2008-06-03 01:46:08 +0000
committeradrian2008-06-03 01:46:08 +0000
commit0eaaba421ef6543fc0c2764b11bee0907b740ca7 (patch)
treef1c1236fabfecd01806fd5c1dacca9b8a34d8fc6
parenta9aed4983ab82f883a74a4442f93f9b0ea3965cb (diff)
Importing all the sites on a platform now works in the provision backend5.x-0.1-alpha1
-rw-r--r--platform/provision_drupal.module48
-rw-r--r--provision.module22
2 files changed, 47 insertions, 23 deletions
diff --git a/platform/provision_drupal.module b/platform/provision_drupal.module
index 509eb4f..03dacdb 100644
--- a/platform/provision_drupal.module
+++ b/platform/provision_drupal.module
@@ -337,8 +337,10 @@ 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;
+}
diff --git a/provision.module b/provision.module
index a82aee2..77947c2 100644
--- a/provision.module
+++ b/provision.module
@@ -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);
}