You are here

function fe_block_settings_features_revert in Features Extra 6

Same name and namespace in other branches
  1. 7 fe_block/fe_block.module \fe_block_settings_features_revert()

Implementation of hook_features_revert().

File

./fe_block.module, line 153

Code

function fe_block_settings_features_revert($module_name = NULL) {
  global $custom_theme, $theme_key;
  $component = 'fe_block_settings';
  $defaults = features_get_default($component, $module_name);

  // Revert.
  foreach ($defaults as $_theme_key => $theme) {
    $custom_theme = $theme_key = $_theme_key;
    _block_rehash();
    foreach ($theme as $block) {

      // Convert machine name back to bid.
      if ($block['module'] == 'block') {
        $block['delta'] = _fe_block_get_bid($block['machine_name']);
      }
      drupal_write_record('blocks', $block, array(
        'module',
        'delta',
        'theme',
      ));

      // these fields are not theme specific
      db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $block['visibility'], trim($block['pages']), $block['custom'], $block['title'], $block['module'], $block['delta']);
    }
  }
  return TRUE;
}