function course_signup_course_enrollment_insert in Course 7.2
Same name and namespace in other branches
- 7 modules/course_signup/course_signup.module \course_signup_course_enrollment_insert()
Implements hook_course_enroll().
If a user is enrolled outside of signup, sign them up as well.
File
- modules/
course_signup/ course_signup.module, line 236
Code
function course_signup_course_enrollment_insert($enrollment) {
// Check if uc_signup is enabled and this enrollment is from ubercart. If it
// is, we don't want to sign the user up, because uc_signup will convert the
// temporary signup and create a duplicate.
$uc_signup = module_exists('uc_signup') && $from == 'ubercart' && isset($_SESSION['uc_signup']);
$uc_sid = FALSE;
if ($uc_signup) {
$uc_sid = db_query("SELECT ucsl.sid FROM {uc_signup_log} ucsl\n LEFT JOIN {signup_log} sl USING (sid)\n WHERE sl.nid = :sl.nid AND sl.uid = :sl.uid", array(
':sl.nid' => $enrollment->nid,
':sl.uid' => $enrollment->uid,
))
->fetchField();
}
if ($enrollment->enrollmenttype != 'course_signup' && !$uc_sid) {
$node = node_load($enrollment->nid);
$account = user_load($enrollment->uid);
course_signup_quick_register($node, $account);
}
}