Skip to content

Commit

Permalink
- Small improvement to the admin menu based on feedback from Michael.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuytaert committed Jan 14, 2003
1 parent 20e8f9e commit d268783
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 29 deletions.
3 changes: 1 addition & 2 deletions database/database.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ CREATE TABLE menu (
help TEXT default '',
title varchar(255) NOT NULL default '',
parent varchar(255) NOT NULL default '',
weight tinyint(4) DEFAULT '0' NOT NULL,
overview tinyint(1) DEFAULT '0' NOT NULL
weight tinyint(4) DEFAULT '0' NOT NULL
) TYPE=MyISAM;

--
Expand Down
3 changes: 1 addition & 2 deletions database/database.pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ CREATE TABLE menu (
help TEXT default '',
title varchar(255) NOT NULL default '',
parent varchar(255) NOT NULL default '',
weight tinyint(4) DEFAULT '0' NOT NULL,
overview tinyint(1) DEFAULT '0' NOT NULL
weight tinyint(4) DEFAULT '0' NOT NULL
);

--
Expand Down
26 changes: 20 additions & 6 deletions includes/menu.inc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ function menu_trail() {
return $trail;
}

function menu_in_trail($item) {
$trail = menu_trail();

foreach ($trail as $menu) {
if ($menu->link == $item->link) {
return 1;
}
}
return 0;
}

function menu_item($item) {

/*
Expand Down Expand Up @@ -99,26 +110,29 @@ function menu_help() {
return $output;
}

function menu_tree($parent = "", $overview = 0) {
function menu_tree($parent = "", $all = 1) {

$result = db_query("SELECT * FROM menu WHERE parent = '%s' AND overview = '%d' ORDER BY weight, name", $parent, $overview);
if ($all) {
$result = db_query("SELECT * FROM menu WHERE parent = '%s' ORDER BY weight, name", $parent);
}

if (db_num_rows($result)) {
$output = "<ul>";
while ($item = db_fetch_object($result)) {
$all = (stristr(request_uri(), $item->link) == $item->link) ? 1 : 0;
$output .= "<li>". menu_item($item) ."</li>";
$output .= menu_tree($item->name, 1);
$output .= menu_tree($item->name, menu_in_trail($item));
}
$output .= "</ul>";
}

return $output;
}

function menu_add($name, $link, $title = NULL, $help = NULL, $parent = NULL, $weight = 1, $overview = 0) {
function menu_add($name, $link, $title = NULL, $help = NULL, $parent = NULL, $weight = 1) {
if (!db_result(db_query("SELECT name FROM menu WHERE link = '%s'", $link))) {
db_query("INSERT INTO menu (name, link, title, help, parent, weight, overview) VALUES ('%s', '%s', '%s', '%s', '%s', '%d', '%d')", $name, $link, $title, $help, $parent, $weight, $overview);
db_query("INSERT INTO menu (name, link, title, help, parent, weight) VALUES ('%s', '%s', '%s', '%s', '%s', '%d')", $name, $link, $title, $help, $parent, $weight);
}
}

?>
?>
2 changes: 1 addition & 1 deletion modules/comment.module
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ function comment_link($type, $node = 0, $main = 0) {
if ($type == "admin" && user_access("administer comments")) {
$settings = "If you really have a lot of comments, you can enable moderation. You assign moderation permissions to role(s), then setup some 'moderation votes'; these votes will appear to moderators in a dropdown menu near the comment. You also have to assign, for every role and every vote, a value, which can be either positive or negative; use the moderation matrix to do this. This allows for some roles having greater 'weight' in their moderation, if you wish. If you set a value to 0, that vote won't be available to that role. When a user moderates, the value of their vote is added or subtracted to the score of that comment. Finally, you may want to setup the comment thresholds: these are floor/ceiling values which users see in the comment control panel. Threshholds are useful for hiding poorly rated comments while reading your site.";

menu_add("comment management", url("admin/comment"), "Administer comments.", $help["comment"], "content management", 1, 1);
menu_add("comment management", url("admin/comment"), "Administer comments.", $help["comment"], "content management", 1);
menu_add("new or updated comments", url("admin/comment&status=0"), "Display new or updated comments.", NULL, "comment management");
menu_add("comments that await approval", url("admin/comment&status=1"), "Display comments that await approval.", NULL, "comment management");
menu_add("search comment", url("admin/comment/search"), "Search a comment.", NULL, "comment management", 8);
Expand Down
2 changes: 1 addition & 1 deletion modules/comment/comment.module
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ function comment_link($type, $node = 0, $main = 0) {
if ($type == "admin" && user_access("administer comments")) {
$settings = "If you really have a lot of comments, you can enable moderation. You assign moderation permissions to role(s), then setup some 'moderation votes'; these votes will appear to moderators in a dropdown menu near the comment. You also have to assign, for every role and every vote, a value, which can be either positive or negative; use the moderation matrix to do this. This allows for some roles having greater 'weight' in their moderation, if you wish. If you set a value to 0, that vote won't be available to that role. When a user moderates, the value of their vote is added or subtracted to the score of that comment. Finally, you may want to setup the comment thresholds: these are floor/ceiling values which users see in the comment control panel. Threshholds are useful for hiding poorly rated comments while reading your site.";

menu_add("comment management", url("admin/comment"), "Administer comments.", $help["comment"], "content management", 1, 1);
menu_add("comment management", url("admin/comment"), "Administer comments.", $help["comment"], "content management", 1);
menu_add("new or updated comments", url("admin/comment&status=0"), "Display new or updated comments.", NULL, "comment management");
menu_add("comments that await approval", url("admin/comment&status=1"), "Display comments that await approval.", NULL, "comment management");
menu_add("search comment", url("admin/comment/search"), "Search a comment.", NULL, "comment management", 8);
Expand Down
6 changes: 3 additions & 3 deletions modules/node.module
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ function node_link($type, $node = 0, $main = 0) {
$search = "On this page you can search for a post. For example, one may search for 'br' and Drupal might return 'bread brakers', 'our daily bread' and 'brenda'.";

menu_add("content management", url("admin/node"), "Content management.", NULL, NULL);
menu_add("submit new content", url("node/add"), "Submit new content.", NULL, "content management", -1, 1);
menu_add("new or updated posts", url("admin/node/nodes/0"), "Display all new or updated posts.", NULL, "content management", 0, 1);
menu_add("posts that await approval", url("admin/node/nodes/1"), "Display posts that await approval.", NULL, "content management", 0, 1);
menu_add("submit new content", url("node/add"), "Submit new content.", NULL, "content management", -1);
menu_add("new or updated posts", url("admin/node/nodes/0"), "Display all new or updated posts.", NULL, "content management", 0);
menu_add("posts that await approval", url("admin/node/nodes/1"), "Display posts that await approval.", NULL, "content management", 0);
menu_add("search content", url("admin/node/search"), "Search a post.", $search, "content management", 5);
menu_add("help", url("admin/node/help"), "More information about content management.", NULL, "content management", 7);
}
Expand Down
6 changes: 3 additions & 3 deletions modules/node/node.module
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ function node_link($type, $node = 0, $main = 0) {
$search = "On this page you can search for a post. For example, one may search for 'br' and Drupal might return 'bread brakers', 'our daily bread' and 'brenda'.";

menu_add("content management", url("admin/node"), "Content management.", NULL, NULL);
menu_add("submit new content", url("node/add"), "Submit new content.", NULL, "content management", -1, 1);
menu_add("new or updated posts", url("admin/node/nodes/0"), "Display all new or updated posts.", NULL, "content management", 0, 1);
menu_add("posts that await approval", url("admin/node/nodes/1"), "Display posts that await approval.", NULL, "content management", 0, 1);
menu_add("submit new content", url("node/add"), "Submit new content.", NULL, "content management", -1);
menu_add("new or updated posts", url("admin/node/nodes/0"), "Display all new or updated posts.", NULL, "content management", 0);
menu_add("posts that await approval", url("admin/node/nodes/1"), "Display posts that await approval.", NULL, "content management", 0);
menu_add("search content", url("admin/node/search"), "Search a post.", $search, "content management", 5);
menu_add("help", url("admin/node/help"), "More information about content management.", NULL, "content management", 7);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/taxonomy.module
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function taxonomy_link($type) {
$help["taxonomy"] = "The taxonomy module allows you to classify post into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically).";
$help["vocabulary"] = "When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node of content (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.";

menu_add("taxonomy", url("admin/taxonomy"), "Administer taxonomies.", $help["taxonomy"], "content management", 1, 1);
menu_add("taxonomy", url("admin/taxonomy"), "Administer taxonomies.", $help["taxonomy"], "content management", 1);
menu_add("add new vocabulary", url("admin/taxonomy/add/vocabulary"), "Add a new vocabulary.", $help["vocabulary"], "taxonomy");
menu_add("help", url("admin/taxonomy/help"), "More information about taxonomies.", NULL, "taxonomy", 9);
}
Expand Down Expand Up @@ -785,4 +785,4 @@ function taxonomy_help() {
<p>Every term, or collection of terms, provides an <a href="http://backend.userland.com/stories/rss091">RSS</a> feed to which interested users may subscribe. The URL format for an sample RSS feed is <a href="<?php print path_uri() . url("node/feed", "or=1,2"); ?>"><?php print path_uri() . url("node/feed", "or=1,2"); ?></a>.</p>
<?php
}
?>
?>
4 changes: 2 additions & 2 deletions modules/taxonomy/taxonomy.module
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function taxonomy_link($type) {
$help["taxonomy"] = "The taxonomy module allows you to classify post into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically).";
$help["vocabulary"] = "When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node of content (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.";

menu_add("taxonomy", url("admin/taxonomy"), "Administer taxonomies.", $help["taxonomy"], "content management", 1, 1);
menu_add("taxonomy", url("admin/taxonomy"), "Administer taxonomies.", $help["taxonomy"], "content management", 1);
menu_add("add new vocabulary", url("admin/taxonomy/add/vocabulary"), "Add a new vocabulary.", $help["vocabulary"], "taxonomy");
menu_add("help", url("admin/taxonomy/help"), "More information about taxonomies.", NULL, "taxonomy", 9);
}
Expand Down Expand Up @@ -785,4 +785,4 @@ function taxonomy_help() {
<p>Every term, or collection of terms, provides an <a href="http://backend.userland.com/stories/rss091">RSS</a> feed to which interested users may subscribe. The URL format for an sample RSS feed is <a href="<?php print path_uri() . url("node/feed", "or=1,2"); ?>"><?php print path_uri() . url("node/feed", "or=1,2"); ?></a>.</p>
<?php
}
?>
?>
2 changes: 1 addition & 1 deletion modules/user.module
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function user_link($type) {

menu_add("user management", url("admin/user"), "User management", $help["user"]);
menu_add("create new account", url("admin/user/create"), "Create a new user account.", $help["create"], "user management", 1);
menu_add("view user accounts", url("admin/user/account"), "Display user account listings.", $help["view"], "user management", 2, 1);
menu_add("view user accounts", url("admin/user/account"), "Display user account listings.", $help["view"], "user management", 2);
menu_add("access rules", url("admin/user/access"), "Configure access rules.", $help["access"], "user management", 3);
menu_add("e-mail rules", url("admin/user/access/mail"), "Allow or deny certain e-mail addresses.", $help["access"], "access rules");
menu_add("username rules", url("admin/user/access/user"), "Allow or deny certain usernames.", $help["access"], "access rules");
Expand Down
2 changes: 1 addition & 1 deletion modules/user/user.module
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function user_link($type) {

menu_add("user management", url("admin/user"), "User management", $help["user"]);
menu_add("create new account", url("admin/user/create"), "Create a new user account.", $help["create"], "user management", 1);
menu_add("view user accounts", url("admin/user/account"), "Display user account listings.", $help["view"], "user management", 2, 1);
menu_add("view user accounts", url("admin/user/account"), "Display user account listings.", $help["view"], "user management", 2);
menu_add("access rules", url("admin/user/access"), "Configure access rules.", $help["access"], "user management", 3);
menu_add("e-mail rules", url("admin/user/access/mail"), "Allow or deny certain e-mail addresses.", $help["access"], "access rules");
menu_add("username rules", url("admin/user/access/user"), "Allow or deny certain usernames.", $help["access"], "access rules");
Expand Down
2 changes: 1 addition & 1 deletion modules/watchdog.module
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function watchdog_link($type) {
$help = "The watchdog module monitors your website, captures system events in a log and records them to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of events recorded during operation and contains usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.";

menu_add("site monitoring", url("admin/watchdog"), "Monitor your site.", NULL, NULL, 2);
menu_add("watchdog", url("admin/watchdog/list/all"), "Display system events.", $help, "site monitoring", 1, 1);
menu_add("watchdog", url("admin/watchdog/list/all"), "Display system events.", $help, "site monitoring", 1);
menu_add("user messages", url("admin/watchdog/list/user"), "Display system events", $help, "watchdog");
menu_add("regular messages", url("admin/watchdog/list/regular"), "Display system events", $help, "watchdog");
menu_add("special messages", url("admin/watchdog/list/special"), "Display system events", $help, "watchdog");
Expand Down
2 changes: 1 addition & 1 deletion modules/watchdog/watchdog.module
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function watchdog_link($type) {
$help = "The watchdog module monitors your website, captures system events in a log and records them to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of events recorded during operation and contains usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.";

menu_add("site monitoring", url("admin/watchdog"), "Monitor your site.", NULL, NULL, 2);
menu_add("watchdog", url("admin/watchdog/list/all"), "Display system events.", $help, "site monitoring", 1, 1);
menu_add("watchdog", url("admin/watchdog/list/all"), "Display system events.", $help, "site monitoring", 1);
menu_add("user messages", url("admin/watchdog/list/user"), "Display system events", $help, "watchdog");
menu_add("regular messages", url("admin/watchdog/list/regular"), "Display system events", $help, "watchdog");
menu_add("special messages", url("admin/watchdog/list/special"), "Display system events", $help, "watchdog");
Expand Down
5 changes: 2 additions & 3 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,7 @@ function update_47() {
help TEXT default '',
title varchar(255) NOT NULL default '',
parent varchar(255) NOT NULL default '',
weight tinyint(4) DEFAULT '0' NOT NULL,
overview tinyint(1) DEFAULT '0' NOT NULL
weight tinyint(4) DEFAULT '0' NOT NULL
);");
}

Expand Down Expand Up @@ -856,4 +855,4 @@ function update_info() {
else {
update_info();
}
?>
?>

0 comments on commit d268783

Please sign in to comment.