You are here

public function Course::getTracker in Course 7

Same name and namespace in other branches
  1. 6 includes/course.core.inc \Course::getTracker()
  2. 7.2 includes/Course.inc \Course::getTracker()

Get the course tracker for this course/user.

Return value

CourseReport

File

includes/Course.inc, line 29

Class

Course
An object that holds CourseObjects and tracker functions?

Code

public function getTracker($account = NULL) {
  if (!$account) {

    /** @deprecated */
    if (!empty($this->user)) {
      $account = $this->user;
    }
    else {
      global $user;
      $account = $user;
    }
  }
  if ($entities = entity_load('course_report', FALSE, array(
    'nid' => $this
      ->getNode()->nid,
    'uid' => $account->uid,
  ), TRUE)) {
    return reset($entities);
  }
  else {
    return entity_create('course_report', array(
      'nid' => $this
        ->getNode()->nid,
      'uid' => $account->uid,
    ));
  }
}