You are here

function course_signup_signup_enroll in Course 7.2

Same name and namespace in other branches
  1. 6 modules/course_signup/course_signup.module \course_signup_signup_enroll()
  2. 7 modules/course_signup/course_signup.module \course_signup_signup_enroll()

Helper signup course enroll criteria function for insert & update.

See also

course_signup_signup_insert()

course_signup_signup_update()

2 calls to course_signup_signup_enroll()
course_signup_signup_insert in modules/course_signup/course_signup.module
Implements hook_signup_insert().
course_signup_signup_update in modules/course_signup/course_signup.module
Implements hook_signup_update().

File

modules/course_signup/course_signup.module, line 145

Code

function course_signup_signup_enroll($signup) {
  if ($enrollment = course_enrollment_load($signup->nid, $signup->uid)) {

    // Found an enrollment already.
    if (!$enrollment->status) {

      // Don't process this enrollment, because it was marked as inactive.
      return;
    }
  }
  if ($signup->uid && $signup->nid && $signup->count_towards_limit && empty($signup->anon_mail)) {
    $node = node_load($signup->nid);
    if (course_node_is_course($node)) {
      $user = user_load($signup->uid);
      course_enroll($node, $user, 'course_signup');
    }
  }
}