You are here

function og_get_context_by_url in Organic groups 7

Select groups if they were passed in the URL.

You can pass a URL in in the form of node/add/post?gids_group[]=1,2,3&gids_node[]=4,5,6 Note that gids_ is the prefix followed by the entity type (e.g. "node", "user") or "group" to indicate the passed values are group ID.

3 calls to og_get_context_by_url()
og_context_handler_url in og_context/og_context.module
Context handler; Get groups from URL.
og_field_audience_default_value in ./og.field.inc
Default value function for OG audience fields.
og_field_widget_form in ./og.field.inc
Implements hook_field_widget_form().

File

./og.module, line 2246
Enable users to create and manage groups with roles and permissions.

Code

function og_get_context_by_url() {
  $return = array();
  foreach (array_keys(entity_get_info()) as $entity_type) {
    $etids = !empty($_GET['gids_' . $entity_type][0]) ? explode(',', $_GET['gids_' . $entity_type][0]) : array();
    if ($etids) {
      $return = array_merge($return, og_get_group_ids($entity_type, $etids));
    }
  }
  return $return;
}