You are here

function course_enrollment_check in Course 7

Same name and namespace in other branches
  1. 8.3 course.module \course_enrollment_check()
  2. 8.2 course.module \course_enrollment_check()
  3. 7.2 course.module \course_enrollment_check()

Check if the user has enrolled in a course.

Parameters

mixed $nid: A course node ID.

mixed $uid: A user ID.

Return value

bool TRUE if the user is enrolled, FALSE otherwise.

7 calls to course_enrollment_check()
CourseObject::access in includes/CourseObject.inc
Access functionality for course objects.
CourseObjectFulfillment::save in includes/CourseObjectFulfillment.inc
Track course after saving fulfillment.
course_completion_page_access in ./course.module
Access callback for completion page.
course_enroll in ./course.module
Enrolls a user in a course.
course_rules_condition_course_enrollment_check in includes/course.rules.inc
Rules condition handler to check enrollment.

... See full list

1 string reference to 'course_enrollment_check'
course_course_enrollment_presave in ./course.module
Implements hook_course_enrollment_presave().

File

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

Code

function course_enrollment_check($nid, $uid) {
  $checked =& drupal_static(__FUNCTION__, array());
  if (!isset($checked[$nid][$uid])) {
    $query = db_query("SELECT 1 FROM {course_enrollment} WHERE nid = :nid AND uid = :uid AND status = :status", array(
      ':nid' => $nid,
      ':uid' => $uid,
      ':status' => 1,
    ));
    $status = $query
      ->fetchField() > 0;
    $checked[$nid][$uid] = $status;
  }
  return $checked[$nid][$uid];
}