You are here

function spaces_settings in Spaces 6.2

Same name and namespace in other branches
  1. 5.2 spaces.module \spaces_settings()
  2. 5 spaces.module \spaces_settings()
  3. 6 spaces.module \spaces_settings()

Retrieve all available settings.

Parameters

$type: Optional space type to return a subset of settings that only apply to the given space type.

$reset: Optional boolean flag for resetting the static cache.

Return value

Keyed array of potential settings.

5 calls to spaces_settings()
spaces_features_form_submit in ./spaces_admin.inc
Submit handler for spaces features form
spaces_features_form_validate in ./spaces_admin.inc
Validate handler for spaces features form
spaces_preset_form_submit in ./spaces_admin.inc
Submit handler for spaces preset form.
spaces_save in ./spaces.module
Saves a space object's feature/setting values.
_spaces_features_form in ./spaces_admin.inc
Core form for controlling features / settings

File

./spaces.module, line 1070

Code

function spaces_settings($type = NULL, $reset = FALSE) {
  static $spaces_settings;
  if (!isset($spaces_settings) || $reset) {
    $spaces_settings = array(
      'all' => array(),
      'common' => array(),
    );

    // Exclude feature-specific settings.
    // Use spaces_feature_settings() to retrieve these.
    $settings = array();
    $features = spaces_features();
    foreach (module_implements('spaces_settings') as $module) {
      if (!isset($features[$module])) {
        $settings = array_merge($settings, module_invoke($module, 'spaces_settings'));
      }
    }
    foreach ($settings as $setting_name => $info) {

      // Load any setting includes before instantiating its class.
      if (is_array($info)) {
        if (isset($info['file']) && is_file($info['file'])) {
          require_once $info['file'];
        }
        if (isset($info['class']) && class_exists($info['class'])) {
          $class = $info['class'];
          $setting = new $class();
        }
      }
      else {
        if (is_string($info) && class_exists($info)) {
          $setting = new $info();
        }
        else {
          if (is_object($info)) {
            $setting = $info;
          }
        }
      }
      if (!empty($setting->types)) {
        foreach ($setting->types as $t) {
          if (!isset($spaces_settings[$t])) {
            $spaces_settings[$t] = array();
          }
          $spaces_settings[$t][$setting_name] = $setting;
        }
      }
      else {
        $spaces_settings['common'][$setting_name] = $setting;
      }
      $spaces_settings['all'][$setting_name] = $setting;
    }
    foreach (array_keys($spaces_settings) as $t) {
      if ($t != 'all' && $t != 'common') {
        $spaces_settings[$t] = array_merge($spaces_settings[$t], $spaces_settings['common']);
      }
    }
  }
  if ($type) {
    return !empty($spaces_settings[$type]) ? $spaces_settings[$type] : $spaces_settings['common'];
  }
  return $spaces_settings['all'];
}