You are here

public static function CourseObjectNode::context in Course 7.2

Same name and namespace in other branches
  1. 7 includes/CourseObjectNode.inc \CourseObjectNode::context()

Course context handler callback.

Overrides CourseObject::context

File

includes/CourseObjectNode.inc, line 15

Class

CourseObjectNode
A course object that uses a node as a base.

Code

public static function context() {

  // Get node from URL.
  if (arg(0) == 'node' && ($node = node_load(arg(1)))) {

    // This node might not be in a course, so let's check for related nodes.
    $instances = static::getNodeInstances($node);
    if (!empty($instances)) {
      $node = node_load($instances[0]);
    }
    if (isset($node->nid)) {
      return array(
        'object_type' => $node->type,
        'instance' => $node->nid,
      );
    }
  }
}