You are here

function CourseObjectAccessTiming::take in Course 6

Same name and namespace in other branches
  1. 7.2 plugins/course_object_access/timing.inc \CourseObjectAccessTiming::take()
  2. 7 plugins/course_object_access/timing.inc \CourseObjectAccessTiming::take()

Overrides CourseObjectAccess::take

1 call to CourseObjectAccessTiming::take()
CourseObjectAccessTiming::view in plugins/course/access/timing.inc

File

plugins/course/access/timing.inc, line 27

Class

CourseObjectAccessTiming

Code

function take() {
  $time = time();
  if ($this
    ->getOption('duration')) {
    if ($this
      ->getCourseObject()
      ->getFulfillment()
      ->getOption('date_started')) {
      $duration_end = $this
        ->getCourseObject()
        ->getFulfillment()
        ->getOption('date_started') + $this
        ->getOption('duration');
      if ($time > $duration_end) {
        $duration_end_h = date('Y-m-d H:i:s', $duration_end);
        $this
          ->getCourseObject()
          ->setAccessMessage('duration-expired', 'Your enrollment in this activity expired on ' . $duration_end_h);
        return FALSE;
      }
    }
  }
  $released = $this
    ->isReleased();
  $expired = $this
    ->isExpired();
  return $released && !$expired;
}