You are here

function spaces_features in Spaces 6.3

Same name and namespace in other branches
  1. 5.2 spaces.module \spaces_features()
  2. 5 spaces.module \spaces_features()
  3. 6 spaces.module \spaces_features()
  4. 6.2 spaces.module \spaces_features()
  5. 7.3 spaces.module \spaces_features()
  6. 7 spaces.module \spaces_features()

Retrieve all available features.

Parameters

$type: Optional type flag by which to filter available features.

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

Return value

Keyed array of potential features.

8 calls to spaces_features()
spaces_access_feature in ./spaces.module
Access check for a given feature in the current space.
spaces_customtext_feature_strings in spaces_customtext/spaces_customtext.admin.inc
Retrieve strings related to the given feature.
spaces_features_form in ./spaces.admin.inc
Spaces features form.
spaces_handler_field_spaces_feature::render in includes/spaces_handler_field_spaces_feature.inc
spaces_plugin_access_spaces_feature::options_form in includes/spaces_plugin_access_spaces_feature.inc
Override of options_form().

... See full list

7 string references to 'spaces_features'
spaces_access_feature in ./spaces.module
Access check for a given feature in the current space.
spaces_dashboard_access in spaces_dashboard/spaces_dashboard.module
Menu access callback.
spaces_features_form in ./spaces.admin.inc
Spaces features form.
spaces_update_6001 in ./spaces.install
Update script 6001.
spaces_update_6301 in ./spaces.install
Update to version 3.

... See full list

File

./spaces.module, line 405

Code

function spaces_features($type = NULL, $reset = FALSE) {
  static $features;
  static $by_type;
  if (!isset($features) || $reset) {
    $features = array();
    $by_type = array();

    // Include the 'site' key.
    $types = array_merge(array_keys(spaces_types()), array(
      'site',
    ));
    foreach (features_get_features() as $feature) {
      if (module_exists($feature->name) && !empty($feature->info['spaces']['types'])) {
        $features[$feature->name] = $feature;
        $feature->info['spaces']['types'] = is_array($feature->info['spaces']['types']) ? $feature->info['spaces']['types'] : array(
          $feature->info['spaces']['types'],
        );
        foreach ($feature->info['spaces']['types'] as $enabled_type) {

          // Feature specifies 'all' type, allow it to be used with all types.
          if ($enabled_type === 'all') {
            foreach ($types as $t) {
              $by_type[$t][$feature->name] = $feature;
            }
          }
          elseif (in_array($enabled_type, $types, TRUE)) {
            $by_type[$enabled_type][$feature->name] = $feature;
          }
          else {
            $by_type['site'][$feature->name] = $feature;
          }
        }
      }
    }
  }
  if (isset($type)) {
    return !empty($by_type[$type]) ? $by_type[$type] : array();
  }
  return $features;
}