function course_enrollment_load in Course 7
Same name and namespace in other branches
- 7.2 course.module \course_enrollment_load()
Load an enrollment from a node ID and user ID.
Parameters
int $nid: Enrollment ID, or node ID.
int $uid: User ID.
Return value
CourseEnrollment Enrollment object or FALSE
14 calls to course_enrollment_load()
- CourseAccessTestCase::testDurationExpiration in tests/
CourseAccessTestCase.test - Test the enrollment duration. This does not test the enrollment end date being set correctly.
- CourseEnrollmentTestCase::testCourseBundles in tests/
CourseEnrollmentTestCase.test - Test course bundles.
- CourseEnrollmentTestCase::testCourseDuration in tests/
CourseEnrollmentTestCase.test - Test for course duration being set properly on enrollment.
- CourseEnrollmentTestCase::testCourseEnrollment in tests/
CourseEnrollmentTestCase.test - Test for enrollment access and timestamping.
- CourseEnrollmentTestCase::testCourseEnrollmentTimestamps in tests/
CourseEnrollmentTestCase.test - Test a manual course enrollment. Ensure that created and started timestamping works as expected.
File
- ./
course.module, line 985 - course.module Core functionality for Courses.
Code
function course_enrollment_load($nid, $uid = NULL) {
if (is_object($nid)) {
$nid = $nid->nid;
}
if (is_null($uid)) {
$eid = $nid;
return entity_load_single('course_enrollment', $eid);
}
if (is_object($uid)) {
$uid = $uid->uid;
}
if ($enrollment = db_query("SELECT * FROM {course_enrollment} WHERE nid = :nid AND uid = :uid", array(
':nid' => $nid,
':uid' => $uid,
))
->fetch()) {
return entity_load_single('course_enrollment', $enrollment->eid);
}
return FALSE;
}