From 9c43e8fc7a192dfe768c76a539373915bddaa0aa Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 29 Jun 2001 22:08:57 +0000 Subject: Extremely large commit: - Fixed tiny quote problem in account.php. - Fixed tiny bug in comment.inc. - Fixed tiny bug in comment.module. - Fixed tiny bug in meta.module. - Simplified user_access() API. - Rewrote link system: still needs fine-tuning and testing so don't upgrade if you are running a production site. ;) Updated all modules and themes to reflect this change. All other themes and modules need updating too! --- includes/common.inc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'includes/common.inc') diff --git a/includes/common.inc b/includes/common.inc index a5b82357c..9ef2da44f 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -24,8 +24,7 @@ function watchdog($type, $message) { } function throttle($type, $rate) { - global $user; - if (!user_access($user, "access administration pages")) { + if (!user_access("access administration pages")) { if ($throttle = db_fetch_object(db_query("SELECT * FROM watchdog WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) { watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type"); die(message_throttle()); @@ -135,8 +134,7 @@ function format_date($timestamp, $type = "medium", $format = "") { } function format_username($username) { - global $user; - if ($username) return (user_access($user, "add and edit user accounts") ? "$username" : "$username"); + if ($username) return (user_access("administer accounts") ? "$username" : "$username"); else return variable_get(anonymous, "Anonymous"); } @@ -209,6 +207,27 @@ function field_merge($a, $b) { return $a; } +function link_page() { + + $links[] = "". t("home") .""; + $links[] = "". t("search") .""; + $links[] = "". t("submit") .""; + $links[] = "". t("account") .""; + + foreach (module_list() as $name) { + if (module_hook($name, "link")) { + $links = array_merge($links, module_invoke($name, "link", "page")); + } + } + + + return $links; +} + +function link_node($node) { + return module_invoke("node", "link", array("node", $node)); +} + function timer_start() { global $timer; $timer = explode(" ", microtime()); -- cgit v1.2.3