overlay.install 1.69 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Install, update, and uninstall functions for the Overlay module.
6 7 8
 */

/**
9
 * Implements hook_install().
10 11
 *
 * If the module is being enabled through the admin UI, and not from an
12
 * installation profile, reopen the modules page in an overlay.
13
 */
14
function overlay_install() {
15
  if (strpos(current_path(), 'admin/modules') === 0) {
16 17
    // Flag for a redirect to <front>#overlay=admin/modules on hook_init().
    $_SESSION['overlay_enable_redirect'] = 1;
18 19
  }
}
20 21 22 23 24 25 26

/**
 * Implements hook_update_dependencies().
 */
function overlay_update_dependencies() {
  // Migrate users.data after User module prepared the tables.
  $dependencies['overlay'][8000] = array(
27
    'user' => 8016,
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  );
  return $dependencies;
}

/**
 * Migrate {users}.data into {users_data}.
 */
function overlay_update_8000() {
  $query = db_select('_d7_users_data', 'ud');
  $query->condition('name', 'overlay');
  $query->addField('ud', 'uid');
  $query->addExpression("'overlay'", 'module');
  $query->addExpression("'enabled'", 'name');
  $query->addField('ud', 'value', 'value');
  $query->addExpression(1, 'serialized');

  db_insert('users_data')
    ->from($query)
    ->execute();

  // Migrate 'overlay_message_dismissed'.
  $query = db_select('_d7_users_data', 'ud');
  $query->condition('name', 'overlay_message_dismissed');
  $query->addField('ud', 'uid');
  $query->addExpression("'overlay'", 'module');
  $query->addExpression("'message_dismissed'", 'name');
  $query->addField('ud', 'value', 'value');
  $query->addExpression(1, 'serialized');

  db_insert('users_data')
    ->from($query)
    ->execute();

  db_delete('_d7_users_data')
    ->condition('name', array('overlay', 'overlay_message_dismissed'))
    ->execute();
}