function hosting_features_enable

7.x-3.x hosting.features.inc hosting_features_enable($features, $rebuild = TRUE, $enable = TRUE)

Enable one or more Hosting features.

Parameters

bool $rebuild: Rebuild caches afterwards, default TRUE.

bool $enable: Also enable the Drupal module, default TRUE.

2 calls to hosting_features_enable()
hosting_features_form_submit in ./hosting.features.inc
Submit callback for the Hosting features form.
hosting_modules_enabled in ./hosting.module
Implements hook_modules_enabled().

File

./hosting.features.inc, line 398
Include for functionality related to Hosting module features.

Code

function hosting_features_enable($features, $rebuild = TRUE, $enable = TRUE) {
  if (count($features)) {

    include_once 'includes/install.inc';

    $all_features = hosting_get_features();
    $titles = array();
    foreach ($features as $feature) {
      $titles[] = $all_features[$feature]['title'];
    }
    drupal_set_message(t("Enabling %feature feature!plural.", array(
      '%feature' => implode(", ", $titles),
      '!plural' => count($features) > 1 ? 's' : '',
    )));

    foreach ($features as $module => $feature) {
      variable_set('hosting_feature_' . $feature, HOSTING_FEATURE_ENABLED);
      if ($enable) {
        module_enable(array($module));
      }
      if (isset($all_features[$feature]['enable']) && function_exists($callback = $all_features[$feature]['enable'])) {
        $callback();
      }
      $role_perms = isset($all_features[$feature]['role_permissions']) ? $all_features[$feature]['role_permissions'] : array();
      hosting_add_permissions($module, $role_perms);
    }
    if ($rebuild) {
      hosting_feature_rebuild_caches($features);
    }
  }

}