You are here

function domain_conf_update_7001 in Domain Access 7.2

Same name and namespace in other branches
  1. 7.3 domain_conf/domain_conf.install \domain_conf_update_7001()

Some variable names changed in Drupal 7.

File

domain_conf/domain_conf.install, line 43
Install file.

Code

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.');
}