diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-01-04 11:03:15 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-01-04 11:03:15 +0000 |
commit | 8a636465767fc47f37a0768d45b86ca53a722085 (patch) | |
tree | 85d014902b87d9a695358fae16b64726b882b5f4 | |
parent | 7a6b8e3d3cc26d242b3c7cbb2eaf252d69b8192f (diff) | |
download | brdo-8a636465767fc47f37a0768d45b86ca53a722085.tar.gz brdo-8a636465767fc47f37a0768d45b86ca53a722085.tar.bz2 |
- Added an extra parameter to watchdog() which lets you specifiy an "action"
or "operation" link.
- Made the main page of the administration section show an overview of all
watchdog entries with such action link.
- Fixed typo in PostgreSQL database scheme.
-rw-r--r-- | admin.php | 7 | ||||
-rw-r--r-- | database/database.mysql | 1 | ||||
-rw-r--r-- | database/database.pgsql | 3 | ||||
-rw-r--r-- | includes/common.inc | 4 | ||||
-rw-r--r-- | modules/comment.module | 6 | ||||
-rw-r--r-- | modules/comment/comment.module | 6 | ||||
-rw-r--r-- | modules/node.module | 4 | ||||
-rw-r--r-- | modules/node/node.module | 4 | ||||
-rw-r--r-- | modules/user.module | 16 | ||||
-rw-r--r-- | modules/user/user.module | 16 | ||||
-rw-r--r-- | modules/watchdog.module | 8 | ||||
-rw-r--r-- | modules/watchdog/watchdog.module | 8 | ||||
-rw-r--r-- | update.php | 7 |
13 files changed, 43 insertions, 47 deletions
@@ -62,8 +62,13 @@ function admin_page($mod) { print "<small>$help</small><br /><br />"; } + if ($mod) { + print module_invoke($mod, "admin"); + } + else { + print watchdog_overview("actions"); + } - module_invoke($mod, "admin"); print "</div>"; db_query("DELETE FROM menu"); diff --git a/database/database.mysql b/database/database.mysql index abe436601..d84761b4b 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -554,6 +554,7 @@ CREATE TABLE watchdog ( uid int(10) NOT NULL default '0', type varchar(16) NOT NULL default '', message text NOT NULL, + link varchar(255) NOT NULL default '', location varchar(128) NOT NULL default '', hostname varchar(128) NOT NULL default '', timestamp int(11) NOT NULL default '0', diff --git a/database/database.pgsql b/database/database.pgsql index 62c7ae03d..7c0c04c58 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -192,7 +192,7 @@ CREATE TABLE item ( link varchar(255) NOT NULL default '', author varchar(255) NOT NULL default '', description text NOT NULL default '', - timestamp integer default NULL default '', + timestamp integer NOT NULL default '0', attributes varchar(255) NOT NULL default '', PRIMARY KEY (iid) ); @@ -554,6 +554,7 @@ CREATE TABLE watchdog ( uid integer NOT NULL default '0', type varchar(16) NOT NULL default '', message text NOT NULL default '', + link varchar(255) NOT NULL default '', location varchar(128) NOT NULL default '', hostname varchar(128) NOT NULL default '', timestamp integer NOT NULL default '0', diff --git a/includes/common.inc b/includes/common.inc index db5bc4591..d9470bb3c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -33,9 +33,9 @@ function error_handler($errno, $message, $filename, $line, $variables) { } } -function watchdog($type, $message) { +function watchdog($type, $message, $link = NULL) { global $user; - db_query("INSERT INTO watchdog (uid, type, message, location, hostname, timestamp) VALUES ('$user->uid', '%s', '%s', '%s', '%s', '%s')", $type, $message, request_uri(), getenv("REMOTE_ADDR"), time()); + db_query("INSERT INTO watchdog (uid, type, message, link, location, hostname, timestamp) VALUES ('$user->uid', '%s', '%s', '%s', '%s', '%s', '%s')", $type, $message, $link, request_uri(), getenv("REMOTE_ADDR"), time()); } function throttle($type, $rate) { diff --git a/modules/comment.module b/modules/comment.module index b4f1971ec..8ac83dde8 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -201,7 +201,7 @@ function comment_post($edit) { */ $edit["subject"] = strip_tags($edit["subject"]); - + if ($edit["subject"] == "") { $edit["subject"] = substr(strip_tags($edit["comment"]), 0, 29); } @@ -249,7 +249,7 @@ function comment_post($edit) { ** Add entry to the watchdog log: */ - watchdog("special", "comment: updated '". $edit["subject"] ."'"); + watchdog("special", "comment: updated '". $edit["subject"] ."'", l(t("view comment"), array("id" => $edit["nid"], "cid" => $edit["cid"]))); } else { /* @@ -282,7 +282,7 @@ function comment_post($edit) { ** Add entry to the watchdog log: */ - watchdog("special", "comment: added '". $edit["subject"] ."'"); + watchdog("special", "comment: added '". $edit["subject"] ."'", l(t("view comment"), array("id" => $edit["nid"], "cid" => $edit["cid"]))); } /* diff --git a/modules/comment/comment.module b/modules/comment/comment.module index b4f1971ec..8ac83dde8 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -201,7 +201,7 @@ function comment_post($edit) { */ $edit["subject"] = strip_tags($edit["subject"]); - + if ($edit["subject"] == "") { $edit["subject"] = substr(strip_tags($edit["comment"]), 0, 29); } @@ -249,7 +249,7 @@ function comment_post($edit) { ** Add entry to the watchdog log: */ - watchdog("special", "comment: updated '". $edit["subject"] ."'"); + watchdog("special", "comment: updated '". $edit["subject"] ."'", l(t("view comment"), array("id" => $edit["nid"], "cid" => $edit["cid"]))); } else { /* @@ -282,7 +282,7 @@ function comment_post($edit) { ** Add entry to the watchdog log: */ - watchdog("special", "comment: added '". $edit["subject"] ."'"); + watchdog("special", "comment: added '". $edit["subject"] ."'", l(t("view comment"), array("id" => $edit["nid"], "cid" => $edit["cid"]))); } /* diff --git a/modules/node.module b/modules/node.module index 56dbd2d2e..f9ea17b38 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1085,7 +1085,7 @@ function node_submit($node) { taxonomy_node_save($nid, $node->taxonomy); } - watchdog("special", "$node->type: updated '$node->title'"); + watchdog("special", "$node->type: updated '$node->title'", l("view post", array("id" => $node->nid))); $output = t("The node has been updated."); } } @@ -1127,7 +1127,7 @@ function node_submit($node) { taxonomy_node_save($nid, $node->taxonomy); } - watchdog("special", "$node->type: added '$node->title'"); + watchdog("special", "$node->type: added '$node->title'", l("view post", array("id" => $nid))); $output = t("Thanks for your submission."); } } diff --git a/modules/node/node.module b/modules/node/node.module index 56dbd2d2e..f9ea17b38 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1085,7 +1085,7 @@ function node_submit($node) { taxonomy_node_save($nid, $node->taxonomy); } - watchdog("special", "$node->type: updated '$node->title'"); + watchdog("special", "$node->type: updated '$node->title'", l("view post", array("id" => $node->nid))); $output = t("The node has been updated."); } } @@ -1127,7 +1127,7 @@ function node_submit($node) { taxonomy_node_save($nid, $node->taxonomy); } - watchdog("special", "$node->type: added '$node->title'"); + watchdog("special", "$node->type: added '$node->title'", l("view post", array("id" => $nid))); $output = t("Thanks for your submission."); } } diff --git a/modules/user.module b/modules/user.module index 1f1493385..a788b1dc1 100644 --- a/modules/user.module +++ b/modules/user.module @@ -532,7 +532,7 @@ function user_login($edit = array(), $msg = "") { if (!$user && $server && $result = user_get_authmaps("$name@$server")) { if (module_invoke(key($result), "auth", $name, $pass, $server)) { $user = user_external_load("$name@$server"); - watchdog("user", "external load: $name@$server, module: " . key($result)); + watchdog("user", "external load: $name@$server, module: ". key($result)); } else { $error = t("Invalid password for %s.", array("%s" => "<i>$name@$server</i>")); @@ -548,8 +548,8 @@ function user_login($edit = array(), $msg = "") { if (module_hook($module, "auth")) { if (module_invoke($module, "auth", $name, $pass, $server)) { if (variable_get("user_register", 1) == 1 && !user_load(array("name" => "$name@$server"))) { //register this new user - watchdog("user", "new user: $name@$server ($module ID)"); $user = user_save("", array("name" => "$name@$server", "pass" => user_password(), "init" => "$name@$server", "status" => 1, "authname_$module" => "$name@$server", "rid" => _user_authenticated_id())); + watchdog("user", "new user: $name@$server ($module ID)", la("edit user", array("mod" => "user", "op" => "edit", "id" => $user->uid))); break; } } @@ -788,7 +788,7 @@ function user_register($edit = array()) { // TODO: is this necessary? Won't session_write replicate this? unset($edit["session"]); $account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "rating" => 0, "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data)); - watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">"); + watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">", la("edit user", array("mod" => "user", "op" => "edit", "id" => $account->uid))); $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time())); @@ -1134,7 +1134,6 @@ function user_admin_create($edit = array()) { } if ($success) { - watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">"); user_save("", array("name" => $edit["name"], "pass" => $edit["pass"], "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => 1)); @@ -1719,16 +1718,13 @@ function user_help_devel_da() { // Since Blogger doesn't return a properly formed FaultCode, we just search for the string 'fault'. if ($result && !stristr($result->serialize(), "fault")) { - // watchdog("user", "Success Blogger Auth. Response: " . $result->serialize()); return 1; } else if ($result) { - // watchdog("user", "Blogger Auth failure. Response was " . $result->serialize()); return 0; } else { - // watchdog("user", "Blogger Auth failure. Could not connect."); return 0; } }</pre> @@ -1778,15 +1774,12 @@ function user_help_devel_da() { to the user.module if your registration database has become inoperable or unreachable.</p> <pre> if ($result && !stristr($result->serialize(), "fault")) { - // watchdog("user", "Success Blogger auth. Response was " . $result->serialize()); return 1; } else if ($result) { - // watchdog("user", "Blogger auth failure. Response was " . $result->serialize()); return 0; } else { - // watchdog("user", "Blogger auth failure. Could not connect.");<br> return 0; } </pre> @@ -1796,8 +1789,7 @@ function user_help_devel_da() { testing for all cases. In the case of Blogger, we search for the string 'fault' in the response. If that string is present, or there is no repsonse, our function returns FALSE. Otherwise, Blogger has returned valid data to our method request - and we return TRUE. There are several watchdog() calls here which are commented - out. These are useful for debugging, so I've left them in the code as comments. + and we return TRUE. </p> <pre>function blogger_page() { global $theme; diff --git a/modules/user/user.module b/modules/user/user.module index 1f1493385..a788b1dc1 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -532,7 +532,7 @@ function user_login($edit = array(), $msg = "") { if (!$user && $server && $result = user_get_authmaps("$name@$server")) { if (module_invoke(key($result), "auth", $name, $pass, $server)) { $user = user_external_load("$name@$server"); - watchdog("user", "external load: $name@$server, module: " . key($result)); + watchdog("user", "external load: $name@$server, module: ". key($result)); } else { $error = t("Invalid password for %s.", array("%s" => "<i>$name@$server</i>")); @@ -548,8 +548,8 @@ function user_login($edit = array(), $msg = "") { if (module_hook($module, "auth")) { if (module_invoke($module, "auth", $name, $pass, $server)) { if (variable_get("user_register", 1) == 1 && !user_load(array("name" => "$name@$server"))) { //register this new user - watchdog("user", "new user: $name@$server ($module ID)"); $user = user_save("", array("name" => "$name@$server", "pass" => user_password(), "init" => "$name@$server", "status" => 1, "authname_$module" => "$name@$server", "rid" => _user_authenticated_id())); + watchdog("user", "new user: $name@$server ($module ID)", la("edit user", array("mod" => "user", "op" => "edit", "id" => $user->uid))); break; } } @@ -788,7 +788,7 @@ function user_register($edit = array()) { // TODO: is this necessary? Won't session_write replicate this? unset($edit["session"]); $account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "rating" => 0, "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data)); - watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">"); + watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">", la("edit user", array("mod" => "user", "op" => "edit", "id" => $account->uid))); $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time())); @@ -1134,7 +1134,6 @@ function user_admin_create($edit = array()) { } if ($success) { - watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">"); user_save("", array("name" => $edit["name"], "pass" => $edit["pass"], "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => 1)); @@ -1719,16 +1718,13 @@ function user_help_devel_da() { // Since Blogger doesn't return a properly formed FaultCode, we just search for the string 'fault'. if ($result && !stristr($result->serialize(), "fault")) { - // watchdog("user", "Success Blogger Auth. Response: " . $result->serialize()); return 1; } else if ($result) { - // watchdog("user", "Blogger Auth failure. Response was " . $result->serialize()); return 0; } else { - // watchdog("user", "Blogger Auth failure. Could not connect."); return 0; } }</pre> @@ -1778,15 +1774,12 @@ function user_help_devel_da() { to the user.module if your registration database has become inoperable or unreachable.</p> <pre> if ($result && !stristr($result->serialize(), "fault")) { - // watchdog("user", "Success Blogger auth. Response was " . $result->serialize()); return 1; } else if ($result) { - // watchdog("user", "Blogger auth failure. Response was " . $result->serialize()); return 0; } else { - // watchdog("user", "Blogger auth failure. Could not connect.");<br> return 0; } </pre> @@ -1796,8 +1789,7 @@ function user_help_devel_da() { testing for all cases. In the case of Blogger, we search for the string 'fault' in the response. If that string is present, or there is no repsonse, our function returns FALSE. Otherwise, Blogger has returned valid data to our method request - and we return TRUE. There are several watchdog() calls here which are commented - out. These are useful for debugging, so I've left them in the code as comments. + and we return TRUE. </p> <pre>function blogger_page() { global $theme; diff --git a/modules/watchdog.module b/modules/watchdog.module index 396351953..eeabdd453 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -43,16 +43,16 @@ function watchdog_cron() { } function watchdog_overview($type) { - $color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); - $query = array(user => "WHERE type = 'user'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'"); + $color = array("user" => "#FFEEAA", "message" => "#FFFFFF", "special" => "#A49FFF", "warning" => "#FFAA22", "httpd" => "#99DD99", "error" => "#EE4C4C"); + $query = array("user" => "WHERE type = 'user'", "regular" => "WHERE type = 'message'", "special" => "WHERE type = 'special'", "warning" => "WHERE type = 'warning'", "error" => "WHERE type = 'error'", "httpd" => "WHERE type = 'httpd'", "actions" => "WHERE link != ''"); $result = pager_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY w.timestamp DESC", 100); $output .= "<table>"; - $output .= " <tr><th>" . t("date") . "</th><th>" . t("message") . "</th><th>" . t("user") . "</th><th>" . t("operations") . "</th></tr>"; + $output .= " <tr><th>" . t("date") . "</th><th>" . t("event") . "</th><th>" . t("user") . "</th><th colspan=\"2\">" . t("operations") . "</th></tr>"; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $output .= " <tr bgcolor=\"$background\"><td nowrap=\"nowrap\">". format_date($watchdog->timestamp, "small") ."</td><td>". substr(strip_tags($watchdog->message), 0, 64) ."</td><td align=\"center\">". format_name($watchdog) ."</a></td><td align=\"center\">". la(t("details"), array("mod" => "watchdog", "op" => "view", "id" => $watchdog->wid)) ."</td></tr>"; + $output .= " <tr bgcolor=\"$background\"><td nowrap=\"nowrap\">". format_date($watchdog->timestamp, "small") ."</td><td>". substr(strip_tags($watchdog->message), 0, 64) ."</td><td align=\"center\">". format_name($watchdog) ."</a></td><td align=\"center\">$watchdog->link</td><td align=\"center\">". la(t("view details"), array("mod" => "watchdog", "op" => "view", "id" => $watchdog->wid)) ."</td></tr>"; } } diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 396351953..eeabdd453 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -43,16 +43,16 @@ function watchdog_cron() { } function watchdog_overview($type) { - $color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); - $query = array(user => "WHERE type = 'user'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'"); + $color = array("user" => "#FFEEAA", "message" => "#FFFFFF", "special" => "#A49FFF", "warning" => "#FFAA22", "httpd" => "#99DD99", "error" => "#EE4C4C"); + $query = array("user" => "WHERE type = 'user'", "regular" => "WHERE type = 'message'", "special" => "WHERE type = 'special'", "warning" => "WHERE type = 'warning'", "error" => "WHERE type = 'error'", "httpd" => "WHERE type = 'httpd'", "actions" => "WHERE link != ''"); $result = pager_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY w.timestamp DESC", 100); $output .= "<table>"; - $output .= " <tr><th>" . t("date") . "</th><th>" . t("message") . "</th><th>" . t("user") . "</th><th>" . t("operations") . "</th></tr>"; + $output .= " <tr><th>" . t("date") . "</th><th>" . t("event") . "</th><th>" . t("user") . "</th><th colspan=\"2\">" . t("operations") . "</th></tr>"; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $output .= " <tr bgcolor=\"$background\"><td nowrap=\"nowrap\">". format_date($watchdog->timestamp, "small") ."</td><td>". substr(strip_tags($watchdog->message), 0, 64) ."</td><td align=\"center\">". format_name($watchdog) ."</a></td><td align=\"center\">". la(t("details"), array("mod" => "watchdog", "op" => "view", "id" => $watchdog->wid)) ."</td></tr>"; + $output .= " <tr bgcolor=\"$background\"><td nowrap=\"nowrap\">". format_date($watchdog->timestamp, "small") ."</td><td>". substr(strip_tags($watchdog->message), 0, 64) ."</td><td align=\"center\">". format_name($watchdog) ."</a></td><td align=\"center\">$watchdog->link</td><td align=\"center\">". la(t("view details"), array("mod" => "watchdog", "op" => "view", "id" => $watchdog->wid)) ."</td></tr>"; } } diff --git a/update.php b/update.php index 8b5362c5d..a07f641a7 100644 --- a/update.php +++ b/update.php @@ -60,7 +60,8 @@ $mysql_updates = array( "2002-11-20" => "update_45", "2002-12-10" => "update_46", "2002-12-22" => "update_47", - "2002-12-29" => "update_48" + "2002-12-29" => "update_48", + "2003-01-03" => "update_49" ); // Update functions @@ -662,6 +663,10 @@ function update_48() { } } +function update_49() { + update_sql("ALTER TABLE watchdog ADD link varchar(255) DEFAULT '' NULL"); +} + function update_upgrade3() { update_sql("INSERT INTO system VALUES ('archive.module','archive','module','',1)"); update_sql("INSERT INTO system VALUES ('block.module','block','module','',1)"); |