You are here

function course_update_uuid in Course 7

Same name and namespace in other branches
  1. 7.2 course.install \course_update_uuid()

Give course objects and fulfillments UUIDs.

1 call to course_update_uuid()
course_update_6135 in ./course.install
Naming conventions update.

File

./course.install, line 841
course.install Install and update functions for Courses.

Code

function course_update_uuid() {
  $uuid_field = array(
    'type' => 'varchar',
    'length' => 36,
    'not null' => TRUE,
    'default' => '',
    'description' => 'The Universally Unique Identifier.',
  );
  db_add_field('course_outline', 'uuid', $uuid_field);
  db_add_field('course_outline_fulfillment', 'uuid', $uuid_field);
  module_enable(array(
    'uuid',
  ));
  $sql = "SELECT * FROM {course_outline}";
  $result = db_query($sql);
  while ($row = $result
    ->fetch()) {
    db_query("update {course_outline} set uuid = :uuid where coid = :coid", array(
      ':uuid' => uuid_generate(),
      ':coid' => $row->coid,
    ));
  }
  $sql = "SELECT * FROM {course_outline_fulfillment}";
  $result = db_query($sql);
  while ($row = $result
    ->fetch()) {
    db_query("update {course_outline_fulfillment} set uuid = :uuid where cofid = :cofid", array(
      ':uuid' => uuid_generate(),
      ':cofid' => $row->cofid,
    ));
  }
  db_add_unique_key('course_outline', 'uuid', array(
    'uuid',
  ));
  db_add_unique_key('course_outline_fulfillment', 'uuid', array(
    'uuid',
  ));
  return t('Gave course objects and fulfillments UUIDs.');
}