function og_membership_from_group_context in Organic groups 7
Return a new context based on an existing context.
1 string reference to 'og_membership_from_group_context'
- og_membership_from_group.inc in plugins/
relationships/ og_membership_from_group.inc - Plugin to provide a relationship handler for OG membership from group and user.
File
- plugins/
relationships/ og_membership_from_group.inc, line 27 - Plugin to provide a relationship handler for OG membership from group and user.
Code
function og_membership_from_group_context($context, $conf) {
list($group_context, $user_context) = $context;
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($group_context->data)) {
return ctools_context_create_empty('entity:og_membership', NULL);
}
if (empty($group_context) || empty($group_context->data)) {
return;
}
if (empty($user_context) || empty($user_context->data)) {
return;
}
$og_membership = og_get_group_membership($group_context->data->gid, 'user', $user_context->data->uid);
if (!$og_membership) {
return;
}
// Send it to ctools.
return ctools_context_create('entity:og_membership', $og_membership);
}