summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt3
-rw-r--r--includes/install.core.inc33
-rw-r--r--includes/install.inc6
3 files changed, 41 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 1285a917f..52065b473 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,9 @@
Drupal 7.18, xxxx-xx-xx (development version)
-----------------------
+- Added an optional "exclusive" flag to installation profile .info files which
+ allows Drupal distributions to force a profile to be selected during
+ installation (API addition).
- Fixed a bug which caused the database API to not properly close database
connections.
- Added link to the URL for running cron from outside the site to the Cron
diff --git a/includes/install.core.inc b/includes/install.core.inc
index 9805e1c88..7a694e9bb 100644
--- a/includes/install.core.inc
+++ b/includes/install.core.inc
@@ -1041,7 +1041,21 @@ function install_select_profile(&$install_state) {
}
/**
- * Selects an installation profile from a list or from a $_POST submission.
+ * Selects an installation profile.
+ *
+ * A profile will be selected if:
+ * - Only one profile is available,
+ * - A profile was submitted through $_POST,
+ * - Exactly one of the profiles is marked as "exclusive".
+ * If multiple profiles are marked as "exclusive" then no profile will be
+ * selected.
+ *
+ * @param array $profiles
+ * An associative array of profiles with the machine-readable names as keys.
+ *
+ * @return
+ * The machine-readable name of the selected profile or NULL if no profile was
+ * selected.
*/
function _install_select_profile($profiles) {
if (sizeof($profiles) == 0) {
@@ -1061,6 +1075,23 @@ function _install_select_profile($profiles) {
}
}
}
+ // Check for a profile marked as "exclusive" and ensure that only one
+ // profile is marked as such.
+ $exclusive_profile = NULL;
+ foreach ($profiles as $profile) {
+ $profile_info = install_profile_info($profile->name);
+ if (!empty($profile_info['exclusive'])) {
+ if (empty($exclusive_profile)) {
+ $exclusive_profile = $profile->name;
+ }
+ else {
+ // We found a second "exclusive" profile. There's no way to choose
+ // between them, so we ignore the property.
+ return;
+ }
+ }
+ }
+ return $exclusive_profile;
}
/**
diff --git a/includes/install.inc b/includes/install.inc
index 0372483b6..c4bcb88b2 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -1244,6 +1244,12 @@ function drupal_check_module($module) {
* - distribution_name: The name of the Drupal distribution that is being
* installed, to be shown throughout the installation process. Defaults to
* 'Drupal'.
+ * - exclusive: If the install profile is intended to be the only eligible
+ * choice in a distribution, setting exclusive = TRUE will auto-select it
+ * during installation, and the install profile selection screen will be
+ * skipped. If more than one profile is found where exclusive = TRUE then
+ * this property will have no effect and the profile selection screen will
+ * be shown as normal with all available profiles shown.
*
* Note that this function does an expensive file system scan to get info file
* information for dependencies. If you only need information from the info