You are here

function domain_theme_features_rebuild in Domain Access 7.3

Implements hook_features_rebuild().

1 call to domain_theme_features_rebuild()
domain_theme_features_revert in domain_theme/domain_theme.features.inc
Implements hook_features_revert().

File

domain_theme/domain_theme.features.inc, line 86
Features support for Domain Theme.

Code

function domain_theme_features_rebuild($module) {
  if ($defaults = domain_features_load($module, 'domain_theme_default_themes', TRUE)) {

    // Check for hard rebuild/revert.
    if ($wipe = domain_features_wipe_tables($defaults)) {
      db_delete('domain_theme')
        ->execute();
      unset($defaults['wipe-domain-tables']);
    }
    foreach ($defaults as $key => $themes) {
      $domain_id = domain_load_domain_id($key);
      if (!$domain_id) {
        continue;
      }

      // Delete existing theme settings.
      db_delete('domain_theme')
        ->condition('domain_id', $domain_id)
        ->execute();

      // Save the new theme settings.
      if (!empty($themes)) {
        foreach ($themes as $theme) {
          $record = array(
            'domain_id' => $domain_id,
            'theme' => $theme['theme'],
            'settings' => serialize($theme['settings']),
            'status' => $theme['status'],
            'filepath' => $theme['filepath'],
          );
          drupal_write_record('domain_theme', $record);
        }
      }
    }
  }
}