function hosting_determine_features_status in Hosting 7.4
Same name and namespace in other branches
- 7.3 hosting.features.inc \hosting_determine_features_status()
Determine the status and actions to take on Hosting features.
Given an array of Hosting features and their desired statuses, determine which are enabled, which should be, and which should be disabled.
1 call to hosting_determine_features_status()
- hosting_features_form_submit in ./
hosting.features.inc - Submit callback for the Hosting features form.
File
- ./
hosting.features.inc, line 490 - Include for functionality related to Hosting module features.
Code
function hosting_determine_features_status($values) {
$features = hosting_get_features();
// List of features currently enabled.
$enabled = array();
// List of features to enable.
$enable = array();
// List of features to disable.
$disable = array();
foreach ($features as $feature => $info) {
$value = $values['hosting_feature_' . $feature];
$current = $info['enabled'];
if ($current) {
$enabled[$features[$feature]['module']] = $features[$feature]['title'];
if (!$value) {
$disable[$features[$feature]['module']] = $features[$feature]['title'];
}
}
elseif ($value) {
$enable[$features[$feature]['module']] = $feature;
// Add dependencies to enable.
if (isset($info['dependencies']['features']) && count($info['dependencies']['features'])) {
foreach ($info['dependencies']['features'] as $module_dep => $feature_dep) {
$enable[$module_dep] = $feature_dep;
}
}
}
}
// Remove any features we're about to enable from those to disable.
$disable = array_diff_assoc($disable, $enable);
// Remove any features already enabled from those to enable.
$enable = array_diff_assoc($enable, $enabled);
return array(
'enabled' => $enabled,
'enable' => $enable,
'disable' => $disable,
);
}