public function Course::setActive in Course 7.2
Same name and namespace in other branches
- 6 includes/course.core.inc \Course::setActive()
- 7 includes/Course.inc \Course::setActive()
Set the active CourseObject in this Course.
Parameters
int $id: A numeric course object ID.
4 calls to Course::setActive()
- Course::getActive in includes/
Course.inc - Get the active CourseObject.
- Course::getNavigation in includes/
Course.inc - Generate navigation links.
- Course::getNext in includes/
Course.inc - Get the next course object, from the active course object.
- Course::getPrev in includes/
Course.inc - Get the previous course object, from the active course object.
File
- includes/
Course.inc, line 58
Class
- Course
- An object that holds CourseObjects and tracker functions?
Code
public function setActive($id = NULL) {
if (!$id && isset($_SESSION['course'][$this
->getNode()->nid]['taking']['active'])) {
$id = $_SESSION['course'][$this
->getNode()->nid]['taking']['active'];
}
$old = NULL;
$storeNext = FALSE;
foreach ($this
->getObjects() as $courseObject) {
if (!$courseObject
->getOption('enabled')) {
// Skip disabled objects.
continue;
}
if ($id == $courseObject
->getId()) {
// Active - save old, store next.
if ($old) {
$this->prev = $old;
}
$storeNext = TRUE;
$this->active = $courseObject;
}
elseif ($storeNext) {
$this->next = clone $courseObject;
$storeNext = FALSE;
}
$old = clone $courseObject;
}
}