function og_context_create_og_group in Organic groups 7
Return OG group form context.
1 string reference to 'og_context_create_og_group'
- og_context_ctools_entity_contexts_alter in og_context/
og_context.module - Implements hook_ctools_entity_contexts_alter().
File
- og_context/
og_context.module, line 188 - Get a group from a viewed page.
Code
function og_context_create_og_group($empty, $data = NULL, $conf = FALSE) {
$context = new ctools_context(array(
'entity:group',
'entity',
'group',
));
$context->plugin = 'og_group';
if ($empty) {
return $context;
}
if ($conf) {
if ($data['type'] == 'select') {
global $user;
$data = og_load($data->gid);
}
else {
$data = og_context();
}
}
// Load entity if the data provided is a numeric value. This kind of data is
// passed by some relationships.
if (!empty($data) && is_numeric($data)) {
$data = og_load($data);
}
if (!$data) {
return ctools_context_create_empty('entity:group', NULL);
}
$context->data = $data;
$context->argument = $data->gid;
$context->title = og_label($data->gid);
return $context;
}