You are here

function course_course_enrollment_presave in Course 7

Same name and namespace in other branches
  1. 7.2 course.module \course_course_enrollment_presave()

Implements hook_course_enrollment_presave().

File

./course.module, line 1345
course.module Core functionality for Courses.

Code

function course_course_enrollment_presave($enrollment) {
  $node = node_load($enrollment->nid);
  if (!isset($enrollment->status)) {
    $enrollment->status = 1;
  }
  if (!isset($enrollment->enroll_end) && !empty($node->course['duration'])) {

    // Set enrollment end to now + the duration of the course.
    $enrollment->enroll_end = REQUEST_TIME + $node->course['duration'];
  }
  if (empty($enrollment->created)) {
    $enrollment->created = REQUEST_TIME;
  }
  if (empty($enrollment->type)) {
    $enrollment->type = $node->course['enrollment_type'];
  }

  // Clear the enrollment check cache.
  drupal_static_reset('course_enrollment_check');
}