function spaces_features in Spaces 7.3
Same name and namespace in other branches
- 5.2 spaces.module \spaces_features()
- 5 spaces.module \spaces_features()
- 6.3 spaces.module \spaces_features()
- 6 spaces.module \spaces_features()
- 6.2 spaces.module \spaces_features()
- 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 - Render the field.
- spaces_plugin_access_spaces_feature::options_form in includes/
spaces_plugin_access_spaces_feature.inc - Override of options_form().
5 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.
- space_type::access_feature in plugins/
space_type.inc - Grant a user access to the specified feature in this space.
- space_user::access_feature in spaces_user/
plugins/ space_user.inc - Override of access_feature().
File
- ./
spaces.module, line 410
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;
}