You are here

function opigno_quiz_app_og_context_handler in Opigno Quiz App 7

OG Context provider.

When creating a Quiz question, check the parent Quiz. If it's part of a group, return the group context.

Return value

array

1 string reference to 'opigno_quiz_app_og_context_handler'
opigno_quiz_app_og_context_negotiation_info in ./opigno_quiz_app.module
Implements hook_og_context_negotiation_info

File

./opigno_quiz_app.module, line 428
Module file. Defines module hooks.

Code

function opigno_quiz_app_og_context_handler() {
  if (opigno_quiz_app_is_node_add_question()) {
    $args = explode('/', current_path());
    $node = (object) array(
      'type' => str_replace('-', '_', array_pop($args)),
    );
    og_quiz_node_prepare($node);
    if (isset($node->og_group_ref)) {
      $items = array_shift($node->og_group_ref);
      $gid = $items[0]['target_id'];
      return array(
        'node' => array(
          $gid,
        ),
      );
    }
  }
}