function oa_core_context_handler_url in Open Atrium Core 7.2
Context handler; Get groups from node create URL.
1 string reference to 'oa_core_context_handler_url'
- oa_core_og_context_negotiation_info in includes/
oa_core.context.inc - Implements hook_og_context_negotiation_info().
File
- includes/
oa_core.context.inc, line 23 - Code for getting context from URL argument.
Code
function oa_core_context_handler_url() {
$item = menu_get_item();
if (strpos($item['path'], 'node/add/') === 0 && !empty($item['map'][2])) {
$node_type = str_replace('-', '_', $item['map'][2]);
}
elseif (strpos($item['path'], 'api/oa_wizard/') === 0) {
$wizard_name = str_replace('-', '_', $item['map'][2]);
$wizard = oa_wizard_machine_name_load($wizard_name);
if (!$wizard || empty($wizard->field_wizard_type[LANGUAGE_NONE][0]['value']) || !node_access('create', $wizard->field_wizard_type[LANGUAGE_NONE][0]['value'])) {
return;
}
$node_type = $wizard->field_wizard_type[LANGUAGE_NONE][0]['value'];
}
if (empty($node_type) || !($fields = og_get_group_audience_fields('node', $node_type))) {
return;
}
$gids = array();
foreach ($fields as $field_name => $label) {
$field = field_info_field($field_name);
if (!empty($_GET[$field_name]) && ($node = node_load($_GET[$field_name])) && node_access('view', $node) && og_is_group('node', $node)) {
$gids['node'][] = $node->nid;
}
}
return $gids;
}