function course_init in Course 6
Same name and namespace in other branches
- 8.3 course.module \course_init()
- 8.2 course.module \course_init()
- 7.2 course.module \course_init()
- 7 course.module \course_init()
- 3.x course.module \course_init()
Implements hook_init().
File
- ./
course.module, line 2083 - course.module Core functionality for Courses.
Code
function course_init() {
course_context();
if (!($courseNode = course_get_context())) {
// Set course context for all modules that define course context handlers.
// @see hook_course_handlers().
$modules = course_get_handlers('context');
foreach ($modules as $module => $handlers) {
if (is_array($handlers)) {
foreach ($handlers as $handler) {
$callback = $handler['callback'];
// Calculate and include the file for each callback, if specified.
if (isset($handler['file'])) {
$file_path = isset($handler['file path']) ? $handler['file path'] : drupal_get_path('module', $module);
$include_file = $file_path . '/' . $handler['file'];
include_once $include_file;
}
// We expect query parameters suitable for course_determine_context().
if (function_exists($callback)) {
$params = $callback();
if (is_array($params) && isset($params['object_type']) && isset($params['instance'])) {
if ($courseNode = course_determine_context($module, $params['object_type'], $params['instance'])) {
course_set_context($courseNode);
}
}
}
}
}
}
}
if (class_exists('Course')) {
// 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 . '/course-object/' . $course
->getActive()
->getId() . '/ajax/nav'),
), 'setting');
}
}
}
}