You are here

dynamic_background_user.install in Dynamic Background 7.2

Installes the database scheme and handles install and uninstall of the module.

File

modules/dynamic_background_user/dynamic_background_user.install
View source
<?php

/**
 * @file
 * Installes the database scheme and handles install and uninstall of the
 * module.
 */

/**
 * Implements hook_uninstall().
 */
function dynamic_background_user_uninstall() {

  // Remove settings.
  variable_del('dynamic_background_user_css');
  variable_del('dynamic_background_user');
  variable_del('dynamic_background_user_image_style');
}

/**
 * Update stored data to use the new database tables.
 */
function dynamic_background_user_update_7000() {
  $query = db_select('dynamic_background_user', 'dbu');
  $result = $query
    ->fields('dbu', array(
    'uid',
    'data',
  ))
    ->execute();

  // Load the old stored image, as the old node extension used the array index
  // and not the fid (doh).
  $images = variable_get('dynamic_background_images', array());
  while ($row = $result
    ->fetchObject()) {
    db_insert('dynamic_background_usage')
      ->fields(array(
      'fid' => $images[$row->data]['fid'],
      'type' => 'user',
      'data' => $row->uid,
    ))
      ->execute();
  }
}

/**
 * Remove old database scheme.
 */
function dynamic_background_user_update_7001() {
  db_query('drop table {dynamic_background_user}');
}

Functions

Namesort descending Description
dynamic_background_user_uninstall Implements hook_uninstall().
dynamic_background_user_update_7000 Update stored data to use the new database tables.
dynamic_background_user_update_7001 Remove old database scheme.