You are here

function view_custom_table_disable in Views Custom Table 7

Implements hook_disable().

File

./view_custom_table.install, line 88
Installation functions for the View Custom Table module.

Code

function view_custom_table_disable() {

  // Disable views created from custom tables.
  if (db_table_exists('custom_table_view_data')) {
    $query = db_select('custom_table_view_data', 'ctvd')
      ->fields('ctvd', array(
      'table_name',
    ));
    $custom_tables = $query
      ->execute()
      ->fetchCol();
    if (!empty($custom_tables)) {
      $query = db_select('views_view', 'v')
        ->fields('v', array(
        'name',
      ))
        ->condition('base_table', $custom_tables, 'IN');
      $custom_table_view = $query
        ->execute()
        ->fetchCol();
      if (!empty($custom_table_view)) {
        foreach ($custom_table_view as $view_name) {
          $status = variable_get('views_defaults', array());
          $status[$view_name] = TRUE;
          variable_set('views_defaults', $status);
        }
      }
    }
  }
}