From f8e2be5fe797314ac04c9730b63efd6e8dadf125 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 29 Sep 2005 21:56:12 +0000 Subject: - Patch #32584 by Gerhard: removed reference to node_revision_load() and fixed input validation error.. --- modules/book.module | 123 +++++++++++++++++------------------------------ modules/book/book.module | 123 +++++++++++++++++------------------------------ 2 files changed, 86 insertions(+), 160 deletions(-) diff --git a/modules/book.module b/modules/book.module index 1a9d9022c..b950268f8 100644 --- a/modules/book.module +++ b/modules/book.module @@ -310,34 +310,6 @@ function book_outline() { } } - -/** - * Return the most recent revision that matches the specified conditions. - */ -function book_revision_load($page, $conditions = array()) { - - $revisions = array_reverse(node_revision_list($page)); - - foreach ($revisions as $revision) { - - // Extract the specified revision: - $node = node_revision_load($page, $revision); - - // Check to see if the conditions are met: - $status = TRUE; - - foreach ($conditions as $key => $value) { - if ($node->$key != $value) { - $status = FALSE; - } - } - - if ($status) { - return $node; - } - } -} - /** * Return the path (call stack) to a certain book page. */ @@ -416,17 +388,6 @@ function book_next($node) { function book_content($node, $teaser = FALSE) { $op = $_POST['op']; - // Always display the most recently approved revision of a node - // (if any) unless we have to display this page in the context of - // the moderation queue. - if ($op != t('Preview') && $node->moderate && arg(0) != 'queue') { - $revision = book_revision_load($node, array('moderate' => 0, 'status' => 1)); - - if ($revision) { - $node = $revision; - } - } - // Extract the page body. $node = node_prepare($node, $teaser); @@ -676,42 +637,49 @@ function book_render() { function book_export($type = 'html', $nid = 0) { global $base_url; $type = drupal_strtolower($type); - $depth = _book_get_depth($nid); - $node = node_load($nid); - switch ($type) { - case 'docbook': - $xml = "\n"; - $xml .= "\n"; - $xml .= book_recurse($nid, $depth, 'book_node_visitor_xml_pre', 'book_node_visitor_xml_post'); - drupal_set_header('Content-Type: text/xml; charset=utf-8'); - print $xml; - break; - case 'html': - for ($i = 1; $i < $depth; $i++) { - $output .= "
\n"; - } - $output .= book_recurse($nid, $depth, 'book_node_visitor_html_pre', 'book_node_visitor_html_post'); - for ($i = 1; $i < $depth; $i++) { - $output .= "
\n"; - } - $html = "\n"; - $html .= ''; - $html .= "\n". check_plain($node->title) ."\n"; - $html .= ''; - $html .= '' . "\n"; - $html .= "\n"; - $html .= "\n\n". $output . "\n\n\n"; - print $html; - break; - case 'opml': - $output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post'); - $ompl = "\n"; - $opml .= "\n"; - $opml .= "\n". check_plain($node->title) ."\n"; - $opml .= "\n\n". $output . "\n\n\n"; - drupal_set_header('Content-Type: text/xml; charset=utf-8'); - print $opml; - break; + if ($nid) { + $depth = _book_get_depth($nid); + $node = node_load($nid); + switch ($type) { + case 'docbook': + $xml = "\n"; + $xml .= "\n"; + $xml .= book_recurse($nid, $depth, 'book_node_visitor_xml_pre', 'book_node_visitor_xml_post'); + drupal_set_header('Content-Type: text/xml; charset=utf-8'); + print $xml; + break; + case 'html': + for ($i = 1; $i < $depth; $i++) { + $output .= "
\n"; + } + $output .= book_recurse($nid, $depth, 'book_node_visitor_html_pre', 'book_node_visitor_html_post'); + for ($i = 1; $i < $depth; $i++) { + $output .= "
\n"; + } + $html = "\n"; + $html .= ''; + $html .= "\n". check_plain($node->title) ."\n"; + $html .= ''; + $html .= '' . "\n"; + $html .= "\n"; + $html .= "\n\n". $output . "\n\n\n"; + print $html; + break; + case 'opml': + $output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post'); + $ompl = "\n"; + $opml .= "\n"; + $opml .= "\n". check_plain($node->title) ."\n"; + $opml .= "\n\n". $output . "\n\n\n"; + drupal_set_header('Content-Type: text/xml; charset=utf-8'); + print $opml; + break; + default: + drupal_not_found(); + } + } + else { + drupal_not_found(); } } @@ -771,11 +739,6 @@ function book_recurse($nid = 0, $depth = 1, $visit_pre, $visit_post) { // Load the node: $node = node_load($page->nid); - // Take the most recent approved revision: - if ($node->moderate) { - $node = book_revision_load($node, array('moderate' => 0, 'status' => 1)); - } - if ($node) { if (function_exists($visit_pre)) { $output .= call_user_func($visit_pre, $node, $depth, $nid); diff --git a/modules/book/book.module b/modules/book/book.module index 1a9d9022c..b950268f8 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -310,34 +310,6 @@ function book_outline() { } } - -/** - * Return the most recent revision that matches the specified conditions. - */ -function book_revision_load($page, $conditions = array()) { - - $revisions = array_reverse(node_revision_list($page)); - - foreach ($revisions as $revision) { - - // Extract the specified revision: - $node = node_revision_load($page, $revision); - - // Check to see if the conditions are met: - $status = TRUE; - - foreach ($conditions as $key => $value) { - if ($node->$key != $value) { - $status = FALSE; - } - } - - if ($status) { - return $node; - } - } -} - /** * Return the path (call stack) to a certain book page. */ @@ -416,17 +388,6 @@ function book_next($node) { function book_content($node, $teaser = FALSE) { $op = $_POST['op']; - // Always display the most recently approved revision of a node - // (if any) unless we have to display this page in the context of - // the moderation queue. - if ($op != t('Preview') && $node->moderate && arg(0) != 'queue') { - $revision = book_revision_load($node, array('moderate' => 0, 'status' => 1)); - - if ($revision) { - $node = $revision; - } - } - // Extract the page body. $node = node_prepare($node, $teaser); @@ -676,42 +637,49 @@ function book_render() { function book_export($type = 'html', $nid = 0) { global $base_url; $type = drupal_strtolower($type); - $depth = _book_get_depth($nid); - $node = node_load($nid); - switch ($type) { - case 'docbook': - $xml = "\n"; - $xml .= "\n"; - $xml .= book_recurse($nid, $depth, 'book_node_visitor_xml_pre', 'book_node_visitor_xml_post'); - drupal_set_header('Content-Type: text/xml; charset=utf-8'); - print $xml; - break; - case 'html': - for ($i = 1; $i < $depth; $i++) { - $output .= "
\n"; - } - $output .= book_recurse($nid, $depth, 'book_node_visitor_html_pre', 'book_node_visitor_html_post'); - for ($i = 1; $i < $depth; $i++) { - $output .= "
\n"; - } - $html = "\n"; - $html .= ''; - $html .= "\n". check_plain($node->title) ."\n"; - $html .= ''; - $html .= '' . "\n"; - $html .= "\n"; - $html .= "\n\n". $output . "\n\n\n"; - print $html; - break; - case 'opml': - $output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post'); - $ompl = "\n"; - $opml .= "\n"; - $opml .= "\n". check_plain($node->title) ."\n"; - $opml .= "\n\n". $output . "\n\n\n"; - drupal_set_header('Content-Type: text/xml; charset=utf-8'); - print $opml; - break; + if ($nid) { + $depth = _book_get_depth($nid); + $node = node_load($nid); + switch ($type) { + case 'docbook': + $xml = "\n"; + $xml .= "\n"; + $xml .= book_recurse($nid, $depth, 'book_node_visitor_xml_pre', 'book_node_visitor_xml_post'); + drupal_set_header('Content-Type: text/xml; charset=utf-8'); + print $xml; + break; + case 'html': + for ($i = 1; $i < $depth; $i++) { + $output .= "
\n"; + } + $output .= book_recurse($nid, $depth, 'book_node_visitor_html_pre', 'book_node_visitor_html_post'); + for ($i = 1; $i < $depth; $i++) { + $output .= "
\n"; + } + $html = "\n"; + $html .= ''; + $html .= "\n". check_plain($node->title) ."\n"; + $html .= ''; + $html .= '' . "\n"; + $html .= "\n"; + $html .= "\n\n". $output . "\n\n\n"; + print $html; + break; + case 'opml': + $output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post'); + $ompl = "\n"; + $opml .= "\n"; + $opml .= "\n". check_plain($node->title) ."\n"; + $opml .= "\n\n". $output . "\n\n\n"; + drupal_set_header('Content-Type: text/xml; charset=utf-8'); + print $opml; + break; + default: + drupal_not_found(); + } + } + else { + drupal_not_found(); } } @@ -771,11 +739,6 @@ function book_recurse($nid = 0, $depth = 1, $visit_pre, $visit_post) { // Load the node: $node = node_load($page->nid); - // Take the most recent approved revision: - if ($node->moderate) { - $node = book_revision_load($node, array('moderate' => 0, 'status' => 1)); - } - if ($node) { if (function_exists($visit_pre)) { $output .= call_user_func($visit_pre, $node, $depth, $nid); -- cgit v1.2.3