diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-06-29 22:08:57 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-06-29 22:08:57 +0000 |
commit | 9c43e8fc7a192dfe768c76a539373915bddaa0aa (patch) | |
tree | 32dfe7f04171c2600be4164ca529d7f42766ec32 /includes/common.inc | |
parent | 124694ee4dbcc1df5dfc2d419ed2393619883071 (diff) | |
download | brdo-9c43e8fc7a192dfe768c76a539373915bddaa0aa.tar.gz brdo-9c43e8fc7a192dfe768c76a539373915bddaa0aa.tar.bz2 |
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!
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 27 |
1 files changed, 23 insertions, 4 deletions
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") ? "<A HREF=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">$username</A>" : "<A HREF=\"account.php?op=view&name=". urlencode($username) ."\">$username</A>"); + if ($username) return (user_access("administer accounts") ? "<A HREF=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">$username</A>" : "<A HREF=\"account.php?op=view&name=". urlencode($username) ."\">$username</A>"); else return variable_get(anonymous, "Anonymous"); } @@ -209,6 +207,27 @@ function field_merge($a, $b) { return $a; } +function link_page() { + + $links[] = "<a href=\"index.php\">". t("home") ."</a>"; + $links[] = "<a href=\"search.php\">". t("search") ."</a>"; + $links[] = "<a href=\"submit.php\">". t("submit") ."</a>"; + $links[] = "<a href=\"account.php\">". t("account") ."</a>"; + + 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()); |