You are here

public function Course::setActive in Course 6

Same name and namespace in other branches
  1. 7.2 includes/Course.inc \Course::setActive()
  2. 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.core.inc
Get the active CourseObject.
Course::getNavigation in includes/course.core.inc
Generate navigation links.
Course::getNext in includes/course.core.inc
Get the next course object, from the active course object.
Course::getPrev in includes/course.core.inc
Get the previous course object, from the active course object.

File

includes/course.core.inc, line 439
course.core.inc File for main Course class.

Class

Course
An object that holds CourseObjects and tracker functions?

Code

public function setActive($id = NULL) {
  if (!$id && isset($_SESSION['course'][$this->node->nid]['taking']['active'])) {
    $id = $_SESSION['course'][$this->node->nid]['taking']['active'];
  }
  $old = NULL;
  $storeNext = FALSE;
  foreach ($this
    ->getObjects() as $courseObject) {
    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;
  }
}