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 /modules/node/node.module | |
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 'modules/node/node.module')
-rw-r--r-- | modules/node/node.module | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index 7bc148177..01642e76e 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -27,7 +27,7 @@ function node_help() { } function node_perm() { - return array("add and edit nodes"); + return array("administer nodes"); } function node_conf_options() { @@ -69,7 +69,26 @@ function node_cron() { db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_hidden = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time()); } -function node_link($nid, $type) { +function node_link($context) { + + if ($context == "admin" && user_access("administer nodes")) { + $links[] = "<a href=\"admin.php?mod=node\">content</a>"; + } + + if ($context[0] && $context[1]) { + $node = $context[1]; + if ($node->body) { + $links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>"; + } + if ($node->comment) { + $links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>"; + } + } + + return $links ? $links : array(); +} + +function node_links($nid, $type) { global $op; $link[] = ($op == "view") ? "view node" : "<A HREF=\"node.php?id=$nid\">view node</A>"; @@ -97,7 +116,7 @@ function node_overview($query) { $bg = $color[$i++ % sizeof($color)]; $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; - $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_link($node->nid, $node->type)) ."</SMALL></TD>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_links($node->nid, $node->type)) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -110,7 +129,7 @@ function node_edit_option($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node."); $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page."); $form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of the moderators their usernames.")); @@ -126,7 +145,7 @@ function node_edit_attribute($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_textfield("Attributes", "attributes", $node->attributes, 64, 128, "A comma-seperated list of attributes. Example: 'Software, Webserver, Apache'."); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); @@ -140,7 +159,7 @@ function node_edit_status($id) { $node = node_get_object(array("nid" => $id)); $form .= form_item("Title", check_output($node->title)); - $form .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Current status", "status", $node->status, node_status($node->type)); $form .= form_textfield("Automatically post document", "timestamp_posted", ($node->timestamp_posted ? format_date($node->timestamp_posted) : ""), 30, 55, "The date at which your document will be automatically posted. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); $form .= form_textfield("Automatically queue document", "timestamp_queued", ($node->timestamp_queued ? format_date($node->timestamp_queued) : ""), 30, 55, "The date at which your document will be automatically queued. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); @@ -259,14 +278,14 @@ function node_module_find() { function node_edit($node) { $output .= form_item("Title", $node->title); - $output .= form_item("Operations", implode("<br />", node_link($node->nid, $node->type))); + $output .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); return $output; } function node_admin() { - global $user, $op, $id, $edit, $query, $type, $keys; + global $op, $id, $edit, $query, $type, $keys; - if (user_access($user, "add and edit nodes")) { + if (user_access("administer nodes")) { foreach (module_list() as $name) { if (module_hook($name, "status") && $name != "node") { |