diff --git a/php_errors.info b/php_errors.info index cceaf9c..5f56f9b 100644 --- a/php_errors.info +++ b/php_errors.info @@ -1,22 +1,6 @@ -; $Id: php_errors.info,v 1.8 2010/07/07 18:26:56 ptalindstrom Exp $ name = PHP Errors description = Admin tool to help monitor PHP errors which occur on the site. package = Administration -version = 6.x-1.0 dependencies[] = token dependencies[] = cronplus - core = 6.x -; Information added by drupal.org packaging script on 2010-02-17 -version = "6.x-1.0" -core = "6.x" -project = "php_errors" -datestamp = "1266446708" - - -; Information added by drupal.org packaging script on 2010-11-08 -version = "6.x-1.3" -core = "6.x" -project = "php_errors" -datestamp = "1289187946" - diff --git a/php_errors.install b/php_errors.install index d60d848..bbbe5b0 100644 --- a/php_errors.install +++ b/php_errors.install @@ -49,7 +49,7 @@ function php_errors_uninstall() { drupal_uninstall_schema('php_errors'); // remove variables - $result = update_sql("DELETE FROM {variable} WHERE name like 'php_errors_%'"); + $result = update_sql("DELETE FROM {variable} WHERE name LIKE 'php_errors_%'"); if ($result['success']) { drupal_set_message(t('The PHP Errors module was successfully uninstalled.')); diff --git a/php_errors.module b/php_errors.module index 1118840..39798ee 100644 --- a/php_errors.module +++ b/php_errors.module @@ -6,9 +6,7 @@ function php_errors_help($path='', $arg) { switch ($path) { case 'admin/modules#description': - return t("This module helps to manage your site's PHP Errors. It performs 3 functions: it provides a summary page of the - watchdog's PHP errors, it archive's this summary and it may be set to email a summary report to specific email addresses - or roles."); + return '
' . t("This module helps to manage your site's PHP Errors. It performs 3 functions: it provides a summary page of the watchdog's PHP errors, it archive's this summary and it may be set to email a summary report to specific email addresses or roles.") . '
'; } } @@ -69,7 +67,9 @@ function php_errors_menu() { return $items; } - +/** + * Menu callback - admin settings form. + */ function php_errors_admin_settings() { // system settings $form['php_errors_notify_addresses'] = array( @@ -96,18 +96,18 @@ function php_errors_admin_settings() { return system_settings_form($form); } +/** + * Menu callback - show detail of the php error report. + */ function _php_errors_show($type = NULL) { $rows = array(); - $results = db_query("SELECT count(1) cnt, timestamp ts, message ms, variables v, location - FROM watchdog WHERE type = 'php' + $results = db_query("SELECT COUNT(wid) cnt, timestamp ts, message ms, variables v, location + FROM {watchdog} WHERE type = 'php' GROUP by MID(v, 62, 30) ORDER BY timestamp DESC, cnt DESC"); // and if results - lets print them out in a nice table if ($type == 'links') { - $header = array( - array('data' => t('Count')), - array('data' => t('Location')), - ); + $header = array(t('Count'), t('Location')); while ($result = db_fetch_object($results)) { $row = array(); $row[] = $result->cnt; @@ -116,15 +116,10 @@ function _php_errors_show($type = NULL) { } } else { - $header = array( - array('data' => t('Count')), - array('data' => t('Date')), - array('data' => t('Error')), - array('data' => t('Location')), - ); + $header = array(t('Count'), t('Date'), t('Error'), t('Location')); while ($result = db_fetch_object($results)) { $variables = unserialize($result->v); - $error = str_replace(array('%message', '%file', '%line'), array($variables['%message'], $variables['%file'], $variables['%line']), "%message in %file on line %line."); + $error = t("%message in %file on line %line.", $variables); $row = array(); $row[] = $result->cnt; $row[] = date("m-d-Y", $result->ts); @@ -137,9 +132,12 @@ function _php_errors_show($type = NULL) { return theme('table', $header, $rows); } +/** + * Helper function for email report. + */ function _php_errors_email() { - $results = db_query("SELECT count(1) cnt, timestamp ts, message ms, location - FROM watchdog WHERE type = 'php' + $results = db_query("SELECT COUNT(wid) cnt, timestamp ts, message ms, location + FROM {watchdog} WHERE type = 'php' GROUP by LEFT(ms, 30) ORDER BY timestamp DESC, cnt DESC"); // and if results - lets format them as a table for a txt email @@ -156,22 +154,21 @@ function _php_errors_email() { $rows .= strip_tags(html_entity_decode($result->ms, ENT_QUOTES)) ."\n\n"; } - $preamble = "The following is this weeks PHP Error Summary Report.\n\nRegards,\n\n" . variable_get('site_name', 'Your Site'); + $preamble = t("The following is this weeks PHP Error Summary Report.") . "\n\n"; + $preamble .= t("Regards,\n\n@sitename", array('@sitename' => variable_get('site_name', t('Your Site')))); return $preamble . $header . $rows; } +/** + * Menu callback - show list of archived PHP reports. + */ function _php_errors_show_archive() { $results = db_query("SELECT * FROM {php_errors_archive} ORDER BY created DESC"); - $header = array( - array('data' => t('Archived Reports')), - array('' => ""), - array('' => ""), - array('' => "") - ); + $header = array(t('Archived Reports'), '', '', ''); - $row = 1; + $row = 1; $col = 1; while ($report = db_fetch_object($results)) { if ($col > 4) { @@ -190,21 +187,31 @@ function _php_errors_show_archive() { return theme('table', $header, $reports); } -// Show an archived report +/** + * Show an archived report. + */ function _php_errors_archive_view($rid) { - $report = db_fetch_object(db_query("SELECT * FROM {php_errors_archive} WHERE rid = %d", $rid)); - - drupal_set_title(t("PHP Errors") ." - Archived Report for: ". date("M d, Y", $report->created) .""); + $output = ''; - $output = ''; - $output .= "