You are here

function hosting_features_form_submit in Hosting 5

Same name and namespace in other branches
  1. 6.2 hosting.features.inc \hosting_features_form_submit()
  2. 7.4 hosting.features.inc \hosting_features_form_submit()
  3. 7.3 hosting.features.inc \hosting_features_form_submit()
1 call to hosting_features_form_submit()
hosting_wizard_hosting_features_submit in ./hosting.wizard.inc

File

./hosting.features.inc, line 62
Hosting features

Code

function hosting_features_form_submit($form_id, $values) {
  $features = hosting_get_features(TRUE);
  foreach ($features as $feature => $info) {
    $value = $values[$feature];
    $current = hosting_feature($feature);
    variable_set('hosting_feature_' . $feature, $value);
    if (!$current && $value) {
      if ($module = $features[$feature]['module']) {
        include_once 'includes/install.inc';

        // turn on module
        drupal_set_message(t("Enabling %module module", array(
          '%module' => $module,
        )));
        drupal_install_modules(array(
          $module,
        ));
        module_enable(array(
          $module,
        ));
      }
      if (function_exists($callback = $features[$feature]['enable'])) {
        $callback();
      }
    }
    if ($current && !$value) {
      if ($module = $features[$feature]['module']) {
        drupal_set_message(t("Disabling %module module", array(
          '%module' => $module,
        )));

        // turn off module
        module_disable(array(
          $module,
        ));
      }
      if (function_exists($callback = $features[$feature]['disable'])) {
        $callback();
      }
    }

    #print("$feature $current $value $module <br />");
  }
  menu_rebuild();
}