You are here

function course_signup_migrate_enrollments in Course 7

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

Create a signup for every enrollment.

File

modules/course_signup/course_signup.module, line 329

Code

function course_signup_migrate_enrollments() {
  if (db_table_exists('course_enrollment') && db_table_exists('signup_log')) {

    // Ensure a signup exists for each full course enrollment.
    $sql = "SELECT ce.* FROM {course_enrollment} ce\n    LEFT JOIN {signup_log} sl ON (ce.nid = sl.nid AND ce.uid = sl.uid)\n    where sid is null and ce.status";
    $result = db_query($sql);
    while ($row = $result
      ->fetch()) {
      $row->signup_time = $row->timestamp;
      drupal_write_record('signup_log', $row);
    }
  }
}