You are here

domain_conf.install in Domain Access 7.2

Install file.

File

domain_conf/domain_conf.install
View source
<?php

/**
 * @file
 * Install file.
 */

/**
 * Implements hook_schema()
 */
function domain_conf_schema() {
  $schema['domain_conf'] = array(
    'description' => 'Stores custom settings for each domain.',
    'fields' => array(
      'domain_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'settings' => array(
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'domain_id',
    ),
    'foreign_keys' => array(
      'domain_id' => array(
        'domain' => 'domain_id',
      ),
    ),
  );
  return $schema;
}

/**
 * Update block deltas to Drupal 7.
 */
function domain_conf_update_7000() {

  // Get an array of the renamed block deltas, organized by module.
  $renamed_deltas = array(
    'domain' => array(
      'domain-primary-links' => 'domain-main-links',
    ),
  );
  $moved_deltas = array();
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas);
  return t('Domain Conf blocks updated.');
}

/**
 * Some variable names changed in Drupal 7.
 */
function domain_conf_update_7001() {
  $changes = domain_conf_d7_variable_changes();
  $domains = db_query("SELECT * FROM {domain}")
    ->FetchAllAssoc('domain_id');
  $result = db_query("SELECT domain_id, settings FROM {domain_conf}");
  foreach ($result as $object) {
    if (!isset($domains[$object->domain_id])) {

      // Remove cruft from the table.
      db_delete('domain_conf')
        ->condition('domain_id', $object->domain_id)
        ->execute();
    }
    elseif (!empty($object->settings)) {

      // Update the record with the new variables.
      $settings = unserialize($object->settings);
      foreach ($changes['removed'] as $key) {
        if (isset($settings[$key])) {
          unset($settings[$key]);
        }
      }
      foreach ($changes['renamed'] as $key => $value) {
        if (isset($settings[$key])) {
          $settings[$value] = $settings[$key];
          unset($settings[$key]);
        }
      }
      db_update('domain_conf')
        ->fields(array(
        'settings' => serialize($settings),
      ))
        ->condition('domain_id', $object->domain_id)
        ->execute();
    }
  }
  return t('Domain Conf variables updated.');
}

/**
 * Return an array of variable changes from Drupal 6 to 7.
 */
function domain_conf_d7_variable_changes() {
  $removed = array(
    'menu_default_node_menu',
    'site_mission',
    'site_footer',
    'page_compression',
  );
  $renamed = array(
    'menu_primary_links_source' => 'menu_main_links_source',
    'site_offline' => 'maintenance_mode',
    'site_offline_message' => 'maintenance_mode_message',
  );
  return array(
    'removed' => $removed,
    'renamed' => $renamed,
  );
}

/**
 * Increases the size of the {domain_conf}.settings to long blob.
 */
function domain_conf_update_7002(&$sandbox) {
  $updated_field = array(
    'type' => 'blob',
    'size' => 'big',
    'not null' => FALSE,
  );
  db_change_field('domain_conf', 'settings', 'settings', $updated_field);
}

Functions

Namesort descending Description
domain_conf_d7_variable_changes Return an array of variable changes from Drupal 6 to 7.
domain_conf_schema Implements hook_schema()
domain_conf_update_7000 Update block deltas to Drupal 7.
domain_conf_update_7001 Some variable names changed in Drupal 7.
domain_conf_update_7002 Increases the size of the {domain_conf}.settings to long blob.