function _oa_sections_get_current_selected_space in Open Atrium Core 7.2
Get the currently selected group.
2 calls to _oa_sections_get_current_selected_space()
- oa_core_form_views_content_views_panes_content_type_edit_form_alter in ./
oa_core.module - Implements hook_form_FORM_ID_alter().
- oa_sections_query_entityreference_alter in modules/
oa_sections/ oa_sections.module - Implements hook_query_TAG_alter().
File
- modules/
oa_sections/ oa_sections.module, line 164
Code
function _oa_sections_get_current_selected_space($entity, $set_value = NULL) {
static $found_value;
if (isset($set_value)) {
$found_value = $set_value;
}
if (isset($found_value)) {
return $found_value ? $found_value : NULL;
}
$value = NULL;
if (isset($_POST['og_group_ref'])) {
$process = $_POST['og_group_ref'];
}
elseif ($entity && isset($entity->og_group_ref)) {
$process = $entity->og_group_ref;
}
// First check active view filter
if (!empty($_GET['og_group_ref_target_id'])) {
$value = $_GET['og_group_ref_target_id'];
}
elseif (!empty($_POST['exposed']['og_group_ref_target_id'])) {
$value = $_POST['exposed']['og_group_ref_target_id'];
}
elseif (isset($process) && is_array($process)) {
if (!empty($process[LANGUAGE_NONE][0]['target_id'])) {
$value = $process[LANGUAGE_NONE][0]['target_id'];
}
elseif (!empty($process[LANGUAGE_NONE][0]['default'])) {
$value = $process[LANGUAGE_NONE][0]['default'];
}
elseif (!empty($process[LANGUAGE_NONE][0]['admin'])) {
$value = $process[LANGUAGE_NONE][0]['admin'];
}
}
else {
$value = oa_core_get_space_context();
}
$matches = array();
if (is_string($value) && !is_numeric($value) && preg_match('/.*\\(([0-9]*)\\)/', $value, $matches) && !empty($matches[1])) {
$value = $matches[1];
}
$found_value = $value;
// Make sure the current user has access.
if (!is_numeric($value) || !($node = node_load($value)) || !node_access('view', $node)) {
$found_value = FALSE;
return NULL;
}
return $value;
}