You are here

function course_signup_quick_register in Course 6

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

Do a quick registration.

Parameters

stdClass $node: A signup enabled course node.

stdClass $user: A user.

bool $notify: Notify the user of this signup. This is passed to signup_sign_up_user().

1 call to course_signup_quick_register()
course_signup_course_enrol in modules/course_signup/course_signup.module
Implements hook_course_enrol().

File

modules/course_signup/course_signup.module, line 48

Code

function course_signup_quick_register($node, $account, $notify = TRUE) {
  if (!($signup = db_fetch_object(db_query('SELECT * FROM {signup_log} WHERE nid = %d AND uid = %d', $node->nid, $account->uid)))) {

    // Save a new signup.
    if ($node->signup_status && $notify) {

      // Signup is open so we can use signup's function.
      signup_sign_up_user(array(
        'nid' => $node->nid,
        'uid' => $account->uid,
      ), $notify);
    }
    else {

      // The signup was closed. Do it silently. We can't use
      // signup_sign_up_user() because this would result in a
      // drupal_access_denied() call.
      $signup = new stdClass();
      $signup->nid = $node->nid;
      $signup->uid = $account->uid;
      $signup->signup_time = time();
      $signup->attended = 0;
      $signup->form_data = array();
      $signup->count_towards_limit = 1;
      signup_save_signup($signup);
    }
  }
  else {

    // Maybe we are "approving" an enrollment.
    $signup->count_towards_limit = 1;
    signup_save_signup($signup);
  }
}