From 882c3f6d2d6d82513b94cf6b719e01e803a33cf1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 1 Jun 2003 06:32:55 +0000 Subject: [PATCH] Removed node_get_node_from_nid() and modified node_load() to take an optional 2nd arguments to return a specified revision. Patch be Kjartan. --- modules/node.module | 22 +++++++++------------- modules/node/node.module | 22 +++++++++------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/modules/node.module b/modules/node.module index 4709410c194..5d916d04e7c 100644 --- a/modules/node.module +++ b/modules/node.module @@ -216,7 +216,7 @@ function node_invoke_all(&$node, $hook, $op, $arg = 0) { return $return; } -function node_load($conditions) { +function node_load($conditions, $revision = -1) { /* ** Turn the conditions into a query: @@ -251,6 +251,13 @@ function node_load($conditions) { } } + /* + ** Return the desired revision + */ + if ($revision != -1 && isset($node->revisions[$revision])) { + $node = $node->revisions[$revision]["node"]; + } + return $node; } @@ -373,17 +380,6 @@ function node_view($node, $main = 0) { } } -function node_get_node_from_nid($nid) { - $revision = $_GET["revision"]; - - $node = node_load(array("status" => 1, "nid" => $nid)); - - if (isset($revision)) { - $node = $node->revisions[$revision]["node"]; - } - return $node; -} - function node_show($node, $cid) { if (node_access("view", $node)) { @@ -1403,7 +1399,7 @@ function node_page() { } if ($op == "view") { - $node = node_get_node_from_nid(arg(2)); + $node = node_load(array("nid" => arg(2), "status" => 1), $_GET["revision"]); } theme("header", $node->title); diff --git a/modules/node/node.module b/modules/node/node.module index 4709410c194..5d916d04e7c 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -216,7 +216,7 @@ function node_invoke_all(&$node, $hook, $op, $arg = 0) { return $return; } -function node_load($conditions) { +function node_load($conditions, $revision = -1) { /* ** Turn the conditions into a query: @@ -251,6 +251,13 @@ function node_load($conditions) { } } + /* + ** Return the desired revision + */ + if ($revision != -1 && isset($node->revisions[$revision])) { + $node = $node->revisions[$revision]["node"]; + } + return $node; } @@ -373,17 +380,6 @@ function node_view($node, $main = 0) { } } -function node_get_node_from_nid($nid) { - $revision = $_GET["revision"]; - - $node = node_load(array("status" => 1, "nid" => $nid)); - - if (isset($revision)) { - $node = $node->revisions[$revision]["node"]; - } - return $node; -} - function node_show($node, $cid) { if (node_access("view", $node)) { @@ -1403,7 +1399,7 @@ function node_page() { } if ($op == "view") { - $node = node_get_node_from_nid(arg(2)); + $node = node_load(array("nid" => arg(2), "status" => 1), $_GET["revision"]); } theme("header", $node->title);