summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/module.inc14
-rw-r--r--modules/blog.module9
-rw-r--r--modules/blog/blog.module9
-rw-r--r--modules/queue.module2
-rw-r--r--modules/tracker.module2
-rw-r--r--modules/tracker/tracker.module2
-rw-r--r--modules/user.module26
-rw-r--r--modules/user/user.module26
8 files changed, 51 insertions, 39 deletions
diff --git a/includes/module.inc b/includes/module.inc
index 2e8476572..8f53e8591 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -19,6 +19,20 @@ function module_invoke($name, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = N
}
}
+// invoke $hook for all appropriate modules:
+function module_invoke_all($hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
+ $return = array();
+ foreach (module_list() as $name) {
+ if (module_hook($name, $hook)) {
+ if ($result = module_invoke($name, $hook, $a1, $a2, $a3, $a4)) {
+ $return = array_merge($return, $result);
+ }
+ }
+ }
+
+ return $return;
+}
+
// return array of module names (includes lazy module loading):
function module_list() {
static $list;
diff --git a/modules/blog.module b/modules/blog.module
index 04dcea472..1674394a1 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -314,9 +314,12 @@ function blog_link($type, $node = 0) {
$links[] = "<a href=\"module.php?mod=blog\" title=\"". t("Read the latest blog entries.") ."\">". t("user blogs") ."</a>";
}
- if ($type == "menu") {
- $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\" title=\"". t("Post a new entry to your personal blog.") ."\">". t("add blog entry") ."</a>";
- $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\" title=\"". t("Read your latest blog entries.") ."\">". t("view your blog") ."</a>";
+ if ($type == "menu.create" && user_access("post content")) {
+ $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\" title=\"". t("Post a new entry to your personal blog.") ."\">". t("create blog entry") ."</a>";
+ }
+
+ if ($type == "menu.view" && user_access("access content")) {
+ $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\" title=\"". t("Read your latest blog entries.") ."\">". t("view personal blog") ."</a>";
}
if ($type == "node" && $node->type == "blog") {
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 04dcea472..1674394a1 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -314,9 +314,12 @@ function blog_link($type, $node = 0) {
$links[] = "<a href=\"module.php?mod=blog\" title=\"". t("Read the latest blog entries.") ."\">". t("user blogs") ."</a>";
}
- if ($type == "menu") {
- $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\" title=\"". t("Post a new entry to your personal blog.") ."\">". t("add blog entry") ."</a>";
- $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\" title=\"". t("Read your latest blog entries.") ."\">". t("view your blog") ."</a>";
+ if ($type == "menu.create" && user_access("post content")) {
+ $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\" title=\"". t("Post a new entry to your personal blog.") ."\">". t("create blog entry") ."</a>";
+ }
+
+ if ($type == "menu.view" && user_access("access content")) {
+ $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\" title=\"". t("Read your latest blog entries.") ."\">". t("view personal blog") ."</a>";
}
if ($type == "node" && $node->type == "blog") {
diff --git a/modules/queue.module b/modules/queue.module
index 8d2fdbfa5..d03ea647b 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -19,7 +19,7 @@ function queue_perm() {
}
function queue_link($type) {
- if ($type == "menu" && user_access("access submission queue")) {
+ if ($type == "menu.view" && user_access("access submission queue")) {
$links[] = "<a href=\"module.php?mod=queue\" title=\"". t("Moderate the content in the submission queue.") ."\">". t("submission queue") ."</a> (<span style=\"color: red;\">". queue_count() ."</span>)";
}
diff --git a/modules/tracker.module b/modules/tracker.module
index 1daf00944..c61f17fac 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -3,7 +3,7 @@
function tracker_link($type) {
- if ($type == "menu") {
+ if ($type == "menu.view") {
$links[] = "<a href=\"module.php?mod=tracker\" title=\"". t("Display an overview of the recent comments.") ."\">". t("recent comments") ."</a>";
}
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index 1daf00944..c61f17fac 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -3,7 +3,7 @@
function tracker_link($type) {
- if ($type == "menu") {
+ if ($type == "menu.view") {
$links[] = "<a href=\"module.php?mod=tracker\" title=\"". t("Display an overview of the recent comments.") ."\">". t("recent comments") ."</a>";
}
diff --git a/modules/user.module b/modules/user.module
index c538b5d09..54e9c1f72 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -458,19 +458,8 @@ function user_block() {
$output .= "<div style=\"width: 125;\">\n";
- foreach (module_list() as $name) {
- if (module_hook($name, "link")) {
- $links = module_invoke($name, "link", "menu");
- foreach ($links as $link) {
- $output .= "$link<br />\n";
- }
- }
- }
-
- if (user_access("access administration pages")) {
- $output .= "<br />\n";
- $output .= "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
- }
+ $links = array_merge(module_invoke_all("link", "menu.create"), array(""), module_invoke_all("link", "menu.view"), array(""), module_invoke_all("link", "menu.settings"), array(""), module_invoke_all("link", "menu.misc"));
+ $output .= @implode("<br />\n", $links);
$output .= "</div>";
}
@@ -499,9 +488,16 @@ function user_link($type) {
$links[] = "<a href=\"module.php?mod=user\" title=\"". t("Create a user account, request a new password or edit your account settings.") ."\">". t("user account") ."</a>";
}
- if ($type == "menu") {
+ if ($type == "menu.settings") {
$links[] = "<a href=\"module.php?mod=user&op=edit\" title=\"". t("View and edit your account information.") ."\">". t("account settings") ."</a>";
- $links[] = "<br /><a href=\"module.php?mod=user&op=logout\" title=\"". t("Logout.") ."\">". t("logout") ."</a>";
+ }
+
+ if ($type == "menu.misc") {
+ if (user_access("access administration pages")) {
+ $links[] = "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a>";
+ }
+
+ $links[] = "<a href=\"module.php?mod=user&op=logout\" title=\"". t("Logout.") ."\">". t("logout") ."</a>";
}
if ($type == "admin" && user_access("administer users")) {
diff --git a/modules/user/user.module b/modules/user/user.module
index c538b5d09..54e9c1f72 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -458,19 +458,8 @@ function user_block() {
$output .= "<div style=\"width: 125;\">\n";
- foreach (module_list() as $name) {
- if (module_hook($name, "link")) {
- $links = module_invoke($name, "link", "menu");
- foreach ($links as $link) {
- $output .= "$link<br />\n";
- }
- }
- }
-
- if (user_access("access administration pages")) {
- $output .= "<br />\n";
- $output .= "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
- }
+ $links = array_merge(module_invoke_all("link", "menu.create"), array(""), module_invoke_all("link", "menu.view"), array(""), module_invoke_all("link", "menu.settings"), array(""), module_invoke_all("link", "menu.misc"));
+ $output .= @implode("<br />\n", $links);
$output .= "</div>";
}
@@ -499,9 +488,16 @@ function user_link($type) {
$links[] = "<a href=\"module.php?mod=user\" title=\"". t("Create a user account, request a new password or edit your account settings.") ."\">". t("user account") ."</a>";
}
- if ($type == "menu") {
+ if ($type == "menu.settings") {
$links[] = "<a href=\"module.php?mod=user&op=edit\" title=\"". t("View and edit your account information.") ."\">". t("account settings") ."</a>";
- $links[] = "<br /><a href=\"module.php?mod=user&op=logout\" title=\"". t("Logout.") ."\">". t("logout") ."</a>";
+ }
+
+ if ($type == "menu.misc") {
+ if (user_access("access administration pages")) {
+ $links[] = "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a>";
+ }
+
+ $links[] = "<a href=\"module.php?mod=user&op=logout\" title=\"". t("Logout.") ."\">". t("logout") ."</a>";
}
if ($type == "admin" && user_access("administer users")) {