Index: watchdog_live.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/watchdog_live/watchdog_live.info,v retrieving revision 1.1 diff -u -p -r1.1 watchdog_live.info --- watchdog_live.info 23 Jan 2008 19:12:20 -0000 1.1 +++ watchdog_live.info 16 Apr 2009 19:56:12 -0000 @@ -1,3 +1,10 @@ ; $Id: watchdog_live.info,v 1.1 2008/01/23 19:12:20 stevemckenzie Exp $ name = "Watchdog Live" description = "Adds auto update functionality to the watchdog table with jQuery." +core = 6.x + +dependencies[] = dblog + +version = "6.x-1.0beta" +project = "watchdog_live" + Index: watchdog_live.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/watchdog_live/watchdog_live.js,v retrieving revision 1.2 diff -u -p -r1.2 watchdog_live.js --- watchdog_live.js 28 Jan 2008 22:43:26 -0000 1.2 +++ watchdog_live.js 16 Apr 2009 19:56:12 -0000 @@ -26,13 +26,14 @@ Drupal.watchdog = { // Check callback for update and display new content if any. load: function() { - $.get(Drupal.settings.watchdogLive.basePath +'admin/logs/watchdog/live/callback', function(data) { + $.get(Drupal.settings.watchdogLive.callback_url, function(data) { var result = Drupal.parseJson(data); // Only if we get content back. if (result.content) { + var animated = false; - $('#watchdog-form-overview').parent().children().not('#watchdog-form-overview').fadeOut('fast', function() { + $('#dblog-filter-form').parent().children().not('#dblog-filter-form').fadeOut('fast', function() { // Since we have multiple children, the callback will be called multiple times. // Force a stop. if (animated) { @@ -41,11 +42,11 @@ Drupal.watchdog = { animated = true; // Remove old table. - $('#watchdog-form-overview').parent().children().not('#watchdog-form-overview').remove(); + $('#dblog-filter-form').parent().children().not('#dblog-filter-form').remove(); // Bring in new content. - $('#watchdog-form-overview').parent().append(result.content); - $('#watchdog-form-overview').parent().children().not('#watchdog-form-overview').fadeIn('fast'); + $('#dblog-filter-form').parent().append(result.content); + $('#dblog-filter-form').parent().children().not('#dblog-filter-form').fadeIn('fast'); }); } @@ -56,7 +57,9 @@ Drupal.watchdog = { // Save a setting for the configurable options. saveSetting: function(name, value) { - $.post(Drupal.settings.watchdogLive.basePath +'admin/logs/watchdog/live/settings', {name: value}) + var setting = {}; + setting[name] = value; + $.post(Drupal.settings.watchdogLive.setting_url, setting); Drupal.watchdog[name] = value; }, Index: watchdog_live.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/watchdog_live/watchdog_live.module,v retrieving revision 1.2 diff -u -p -r1.2 watchdog_live.module --- watchdog_live.module 28 Jan 2008 22:43:26 -0000 1.2 +++ watchdog_live.module 16 Apr 2009 19:56:12 -0000 @@ -2,30 +2,29 @@ // $Id: watchdog_live.module,v 1.2 2008/01/28 22:43:26 stevemckenzie Exp $ /** - * * @file * Adds auto update functionality to the watchdog table. - * */ /** * Implementation of hook_menu(). */ -function watchdog_live_menu($may_cache) { +function watchdog_live_menu() { $items = array(); - - if ($may_cache) { - $items[] = array( - 'path' => 'admin/logs/watchdog/live/callback', - 'callback' => 'watchdog_live_callback', - 'type' => MENU_CALLBACK - ); - $items[] = array( - 'path' => 'admin/logs/watchdog/live/settings', - 'callback' => 'watchdog_live_settings', - 'type' => MENU_CALLBACK - ); - } + + $items['admin/logs/watchdog/live/callback'] = array( + 'page callback' => 'watchdog_live_callback', + 'access arguments' => array('access site reports'), + 'type' => MENU_CALLBACK, + 'file' => 'watchdog_live.module', + ); + + $items['admin/logs/watchdog/live/settings'] = array( + 'page callback' => 'watchdog_live_settings', + 'access arguments' => array('administer site configuration'), + 'type' => MENU_CALLBACK, + 'file' => 'watchdog_live.module', + ); return $items; } @@ -33,19 +32,32 @@ function watchdog_live_menu($may_cache) /** * Implementation of hook_form_alter(). */ -function watchdog_live_form_alter($form_id, &$form) { - if ($form_id == 'watchdog_form_overview') { +function watchdog_live_form_alter(&$form, &$form_state , $form_id) { + if ($form_id == 'dblog_filter_form' && empty($_GET['page'])) { // Include needed JavaScript. - drupal_add_js(array('watchdogLive' => array('basePath' => base_path())), 'setting'); + + $path = array( + 'callback_url' => url('admin/logs/watchdog/live/callback'), + 'setting_url' => url('admin/logs/watchdog/live/settings') + ); + + drupal_add_js(array('watchdogLive' => $path), 'setting'); drupal_add_js(drupal_get_path('module', 'watchdog_live') .'/watchdog_live.js'); // Keep record of the newest log they have seen. $_SESSION['watchdog_live_latest_wid'] = watchdog_live_latest_wid(); - + $intervals = drupal_map_assoc(array(0, 50, 100, 200, 300, 400, 500, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 10000), create_function('$a', 'return $a/1000 . " '. t('seconds'). '";')); + // Add configurable options right on the watchdog page so we can update instantly.. just for kicks. $form['watchdog_live'] = array('#type' => 'fieldset', '#title' => t('Live settings'), '#tree' => TRUE); - $form['watchdog_live']['interval'] = array('#type' => 'select', '#title' => t('Update interval'), '#options' => drupal_map_assoc(array(0, 50, 100, 200, 300, 400, 500, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 10000)), '#default_value' => variable_get('watchdog_live_interval', 1000)); - $form['watchdog_live']['disabled'] = array('#type' => 'checkbox', '#title' => t('Disable'), '#default_value' => $_SESSION['watchdog_live_disabled']); + $form['watchdog_live']['interval'] = array( + '#type' => 'select', '#title' => t('Update interval'), + '#options' => $intervals, '#default_value' => variable_get('watchdog_live_interval', 2000) + ); + $form['watchdog_live']['disabled'] = array( + '#type' => 'checkbox', '#title' => t('Disable'), + '#default_value' => $_SESSION['watchdog_live_disabled'] + ); } } @@ -53,11 +65,17 @@ function watchdog_live_form_alter($form_ * Callback used to retrieve the updated table. */ function watchdog_live_callback() { + require_once drupal_get_path('module','dblog') . '/dblog.admin.inc'; + // Make sure we need to update the table. $latest_wid = watchdog_live_latest_wid(); if ($_SESSION['watchdog_live_latest_wid'] < $latest_wid) { $_SESSION['watchdog_live_latest_wid'] = $latest_wid; - $output['content'] = watchdog_live_overview(); + + $output['content'] = preg_replace('#