function spaces_feature in Spaces 5
Test if feature exists
If in a group context we check on a group-by-group basis to see if an feature is enabled, and that the current user has access.
Parameters
$feature: String, a feature to check if it is active (in the current group)
Return value
bool, true if feature is enabled.
4 calls to spaces_feature()
- spaces_router in ./
spaces.module - Consolidated group context routing logic.
- theme_spaces_button in ./
spaces.module - Generates a themed set of links for node types associated with the current active contexts.
- _spaces_core_book_link in spaces_core/
spaces_core.module - _spaces_views_empty in ./
spaces_views.inc - Function that handles a variety of tasks needed when view is empty
File
- ./
spaces.module, line 832
Code
function spaces_feature($feature, $gid = null) {
$gid = !$gid ? spaces_gid() : $gid;
$features = $gid ? spaces_features($gid) : array();
if (array_key_exists($feature, $features)) {
// If using OG check if user can access feature. true if feature is public or user is member of the group.
global $user;
if ($features[$feature] == SPACES_PUBLIC) {
return true;
}
elseif ($features[$feature] == SPACES_PRIVATE && spaces_is_member($gid, $user->uid)) {
return true;
}
}
return false;
}