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! --- modules/node/node.module | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'modules/node/node.module') 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[] = "content"; + } + + if ($context[0] && $context[1]) { + $node = $context[1]; + if ($node->body) { + $links[] = "nid ."\">". t("read more") .""; + } + if ($node->comment) { + $links[] = "nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") .""; + } + } + + return $links ? $links : array(); +} + +function node_links($nid, $type) { global $op; $link[] = ($op == "view") ? "view node" : "view node"; @@ -97,7 +116,7 @@ function node_overview($query) { $bg = $color[$i++ % sizeof($color)]; $output .= " nid\">". check_output($node->title) ."$node->type". node_status($node->status) ."". check_output($node->attributes) ."". format_username($node->userid) ."". format_date($node->timestamp, "small") ."\n"; - $output .= " ". implode(", ", node_link($node->nid, $node->type)) ."\n"; + $output .= " ". implode(", ", node_links($node->nid, $node->type)) ."\n"; } $output .= "\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("
", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("
", 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("
", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("
", 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("
", node_link($node->nid, $node->type))); + $form .= form_item("Operations", implode("
", 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("
", node_link($node->nid, $node->type))); + $output .= form_item("Operations", implode("
", 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") { -- cgit v1.2.3