function _course_enrollment_create in Course 6
Create an enrollment.
1 string reference to '_course_enrollment_create'
- _course_enrollment_resource in services/
course_enrollment_resource.inc - @file course_enrollment_resource.inc Expose course enrollment as as service resource.
File
- services/
course_enrollment_resource.inc, line 132 - course_enrollment_resource.inc Expose course enrollment as as service resource.
Code
function _course_enrollment_create($enrollment) {
$node = node_load($enrollment['nid']);
$user = user_load($enrollment['uid']);
if ($node->nid && $user->uid) {
if (course_enrolment_check($node->nid, $user->uid)) {
services_error('Enrollment already exists.');
}
if ($enroll = course_enrol($node, $user)) {
return $enroll;
}
else {
services_error('Enrollment failed.');
}
}
else {
services_error('Missing parameters nid and uid.');
}
}