function course_signup_course_can_enrol in Course 6
Implements hook_course_can_enrol().
File
- modules/
course_signup/ course_signup.module, line 215
Code
function course_signup_course_can_enrol($node, $user) {
$hooks = array();
// We depend on Signup Restrict by Role for enrollment access per role.
if (module_exists('signup_restrict_by_role')) {
$check = signup_restrict_by_role_access_signup($node, $user);
$check['message'] = str_replace('signup', 'course enrollment', $check['message']);
$hooks[] = $check;
}
if ($node->signup) {
// This node is signup-enabled.
if (!db_result(db_query('SELECT 1 FROM {signup_log} WHERE nid = %d AND uid = %d', $node->nid, $user->uid))) {
if ($signups[$node->nid]) {
// Block enrollments until the user is signed up.
$hooks[] = array(
'success' => FALSE,
'message' => 'You must be signed up for this course to enroll.',
);
}
}
return $hooks;
}
}