You are here

function spaces_preset_enforce in Spaces 5.2

Same name and namespace in other branches
  1. 6 spaces.module \spaces_preset_enforce()
  2. 6.2 spaces.module \spaces_preset_enforce()

Enforces a spaces preset.

5 calls to spaces_preset_enforce()
spaces_basic_form_submit in ./spaces_admin.inc
spaces_features_form in ./spaces_admin.inc
FEATURE SETTINGS ===================================================
spaces_load in ./spaces.module
Load a space.
spaces_preset_form in ./spaces_admin.inc
Form for adding or editing a spaces preset.
spaces_save in ./spaces.module
Saves a space object's feature/setting values.

File

./spaces.module, line 715

Code

function spaces_preset_enforce(&$space) {
  $presets = spaces_presets($space->type);
  if (isset($space->preset) && isset($presets[$space->preset])) {
    $preset = $presets[$space->preset]['preset'];

    // Enforce features
    if (is_array($preset['features'])) {
      foreach ($preset['features'] as $feature => $value) {
        if ($preset['locked']['features'][$feature] || !isset($space->features[$feature])) {
          $space->features[$feature] = $value;
        }
      }
    }

    // Enforce settings
    if (is_array($preset['settings'])) {
      foreach ($preset['settings'] as $setting => $value) {
        if ($preset['locked']['settings'][$setting] || !isset($space->features[$setting])) {
          $space->settings[$setting] = $value;
        }
      }
    }

    // Type-specific presets
    $space
      ->preset_enforce($preset);
  }
}