function spaces_features in Spaces 5
Same name and namespace in other branches
- 5.2 spaces.module \spaces_features()
- 6.3 spaces.module \spaces_features()
- 6 spaces.module \spaces_features()
- 6.2 spaces.module \spaces_features()
- 7.3 spaces.module \spaces_features()
- 7 spaces.module \spaces_features()
Retrieve available features
Parameters
$gid: An optional group ID -- if provided, an array of enabled features for that group will be provided.
$op: An operation to perform. This is only for caching purposes. Do not use this parameter -- use spaces_settings instead.
Return value
Keyed array of potential group features.
18 calls to spaces_features()
- spaces::testSpaces in tests/
spaces.test - spaces_admin_debug in ./
spaces.module - Provides a debug page to display all group privacy settings
- spaces_content_types in ./
spaces.module - Returns a content type => features map
- spaces_feature in ./
spaces.module - Test if feature exists
- spaces_features_form in ./
spaces_admin.inc - Define form for controlling features
File
- ./
spaces.module, line 771
Code
function spaces_features($gid = -1, $op = 'features') {
if ($gid == -1) {
static $spaces_features;
if (!isset($spaces_features)) {
$spaces_features = array();
foreach (context_ui_defaults('spaces') as $feature) {
if ($feature->spaces) {
$spaces_features[$feature->value] = $feature;
}
}
}
return $spaces_features;
}
else {
static $cache = array();
if (!isset($cache[$gid])) {
$result = db_query('SELECT type, id, value FROM {spaces_features} WHERE gid = %d', $gid);
while ($row = db_fetch_object($result)) {
$cache[$gid][$row->type == 0 ? 'features' : 'settings'][$row->id] = $row->value;
}
}
switch ($op) {
case 'settings':
return is_array($cache[$gid]['settings']) ? $cache[$gid]['settings'] : array();
case 'features':
return is_array($cache[$gid]['features']) ? $cache[$gid]['features'] : array();
default:
return is_array($cache[$gid]) ? $cache[$gid] : array();
}
}
}