From b86d6a2f8eb0826b3ebf66bf150c4837aec6e206 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 4 Jun 2001 16:19:25 +0000 Subject: [PATCH] - Patched book.module to work with the new node.module (which makes the book.module quite a bit shorter/simpler). --- modules/book.module | 48 +++------------------------------------- modules/book/book.module | 48 +++------------------------------------- 2 files changed, 6 insertions(+), 90 deletions(-) diff --git a/modules/book.module b/modules/book.module index 96dfef936bb..319165c972c 100644 --- a/modules/book.module +++ b/modules/book.module @@ -69,7 +69,7 @@ function book_search($keys) { global $status, $user; $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); + $find[$i++] = array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); } return $find; } @@ -180,7 +180,7 @@ function book_tree($parent = "", $depth = 0) { // render output: while ($node = db_fetch_object($result)) { - $output .= "
  • nid\">". check_output($node->title) ."". ($PHP_SELF == "/admin.php" ? " (weight: $node->weight/$node->parent, status: $node->status) (nid\">edit)" : "") ."
  • \n"; + $output .= "
  • nid\">". check_output($node->title) ."". ($PHP_SELF == "/admin.php" ? " (weight: $node->weight/$node->parent, status: $node->status) (nid\">edit)" : "") ."
  • \n"; $output .= book_tree($node->nid, $depth + 1); } $output = ""; @@ -188,50 +188,8 @@ function book_tree($parent = "", $depth = 0) { return $output; } -function book_list($query = array()) { - return node_overview($query); -} - -function book_query($type = "") { - global $status; - $queries = array(array("recent book pages", "WHERE n.type = 'book' ORDER BY n.timestamp DESC"), array("posted book pages", "WHERE n.type = 'book' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued book pages", "WHERE n.type = 'book' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped book pages", "WHERE n.type = 'book' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC")); - return ($queries[$type] ? $queries[$type] : $queries); -} - function book_admin() { - global $op, $id, $edit, $mod, $keys, $type, $user; - - print "add new page | book listing | search book | list overview | tree overview
    \n"; - - $type = $type ? $type : 0; - - switch ($op) { - case "add": - print book_form(); - break; - case "edit": - print book_form(node_get_array(array(nid => $id))); - break; - case "listing": - print node_listing(book_query()); - break; - case "search": - print search_form($keys); - print search_data($keys, $mod); - break; - case "tree": - print book_tree(); - break; - case t("Preview"): - book_view(new Book(node_preview($edit))); - print book_form($edit); - break; - case t("Submit"): - book_save($edit); - // fall through: - default: - print book_list(book_query($type)); - } + print book_tree(); } function book_page() { diff --git a/modules/book/book.module b/modules/book/book.module index 96dfef936bb..319165c972c 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -69,7 +69,7 @@ function book_search($keys) { global $status, $user; $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); + $find[$i++] = array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); } return $find; } @@ -180,7 +180,7 @@ function book_tree($parent = "", $depth = 0) { // render output: while ($node = db_fetch_object($result)) { - $output .= "
  • nid\">". check_output($node->title) ."". ($PHP_SELF == "/admin.php" ? " (weight: $node->weight/$node->parent, status: $node->status) (nid\">edit)" : "") ."
  • \n"; + $output .= "
  • nid\">". check_output($node->title) ."". ($PHP_SELF == "/admin.php" ? " (weight: $node->weight/$node->parent, status: $node->status) (nid\">edit)" : "") ."
  • \n"; $output .= book_tree($node->nid, $depth + 1); } $output = ""; @@ -188,50 +188,8 @@ function book_tree($parent = "", $depth = 0) { return $output; } -function book_list($query = array()) { - return node_overview($query); -} - -function book_query($type = "") { - global $status; - $queries = array(array("recent book pages", "WHERE n.type = 'book' ORDER BY n.timestamp DESC"), array("posted book pages", "WHERE n.type = 'book' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued book pages", "WHERE n.type = 'book' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped book pages", "WHERE n.type = 'book' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC")); - return ($queries[$type] ? $queries[$type] : $queries); -} - function book_admin() { - global $op, $id, $edit, $mod, $keys, $type, $user; - - print "add new page | book listing | search book | list overview | tree overview
    \n"; - - $type = $type ? $type : 0; - - switch ($op) { - case "add": - print book_form(); - break; - case "edit": - print book_form(node_get_array(array(nid => $id))); - break; - case "listing": - print node_listing(book_query()); - break; - case "search": - print search_form($keys); - print search_data($keys, $mod); - break; - case "tree": - print book_tree(); - break; - case t("Preview"): - book_view(new Book(node_preview($edit))); - print book_form($edit); - break; - case t("Submit"): - book_save($edit); - // fall through: - default: - print book_list(book_query($type)); - } + print book_tree(); } function book_page() {