You are here

function domain_conf_update_7001 in Domain Access 7.3

Same name and namespace in other branches
  1. 7.2 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 for Domain Conf.

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 FROM {domain_conf}");
  foreach ($result as $object) {
    if (!isset($domains[$object->domain_id])) {

      // Remove cruft from the table.
      domain_conf_data_delete($object->domain_id);
      continue;
    }
    $settings = domain_conf_data_get($object->domain_id, TRUE);
    if (!empty($settings)) {

      // Update the record with the new variables.
      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]);
        }
      }
      domain_conf_data_set($object->domain_id, $settings, FALSE);
    }
  }
  return t('Domain Conf variables updated.');
}