You are here

function better_watchdog_ui_enable in Better Watchdog UI 7

Same name and namespace in other branches
  1. 8 better_watchdog_ui.install \better_watchdog_ui_enable()
  2. 7.3 better_watchdog_ui.install \better_watchdog_ui_enable()
  3. 7.2 better_watchdog_ui.install \better_watchdog_ui_enable()

Implements hook_enable().

File

./better_watchdog_ui.install, line 11
Installation and update functions.

Code

function better_watchdog_ui_enable() {

  // Allow our view to override the basic watchdog listing
  // by increasing module weight in system database table.
  $weight = db_select('system', 's')
    ->fields('s', array(
    'weight',
  ))
    ->condition('s.name', 'better_watchdog_ui', '=')
    ->condition('type', 'module')
    ->execute()
    ->fetchField();
  db_update('system')
    ->fields(array(
    'weight' => $weight + 1,
  ))
    ->condition('name', 'better_watchdog_ui')
    ->condition('type', 'module')
    ->execute();

  // Enable watchdog view.
  module_load_include('inc', 'better_watchdog_ui', 'better_watchdog_ui/better_watchdog_ui.views_default');
  $views_status = variable_get('views_defaults', array());
  if (array_key_exists('better_watchdog_ui_view', $views_status)) {

    // TRUE means disable.
    $views_status['better_watchdog_ui_view'] = TRUE;
    variable_set('views_defaults', $views_status);
    views_invalidate_cache();
  }
}