Selects an installation profile.
A profile will be selected if:
If multiple profiles are marked as "exclusive" then no profile will be selected.
array $profiles: An associative array of profiles with the machine-readable names as keys.
The machine-readable name of the selected profile or NULL if no profile was selected.
function _install_select_profile($profiles) {
// Don't need to choose profile if only one available.
if (count($profiles) == 1) {
$profile = array_pop($profiles);
return $profile->name;
}
elseif (!empty($_POST['profile']) && isset($profiles[$_POST['profile']])) {
return $profiles[$_POST['profile']]->name;
}
// 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;
}