You are here

function course_init in Course 8.2

Same name and namespace in other branches
  1. 8.3 course.module \course_init()
  2. 6 course.module \course_init()
  3. 7.2 course.module \course_init()
  4. 7 course.module \course_init()
  5. 3.x course.module \course_init()

Implements hook_init().

Detect and set course context. Adds javascript for course objects that require polling. Hack for #1902104.

File

./course.module, line 674
course.module Core functionality for Courses.

Code

function course_init() {
  if (class_exists('Course') && $courseNode) {

    // Check that Course exists for a special use case where Autoload hasn't yet
    // cached the Course class.
    $course = course_get_course($courseNode);
    if ($course && ($active = $course
      ->getActive())) {
      if ($active
        ->hasPolling()) {
        drupal_add_js(array(
          'courseAjaxNavPath' => url('node/' . $courseNode->nid . '/object/' . $course
            ->getActive()
            ->getId() . '/ajax/nav'),
        ), array(
          'type' => 'setting',
          'scope' => JS_DEFAULT,
        ));
      }
    }
  }
}