From 871d0619aab39c6460d6d9261b2395d1ddb24069 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 31 Mar 2001 18:38:01 +0000 Subject: - fixed another bug --- includes/node.inc | 11 +++++++---- modules/book.module | 22 +++++++++++++++------- modules/book/book.module | 22 +++++++++++++++------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/includes/node.inc b/includes/node.inc index 4c9ad18a1..dbed92315 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -54,6 +54,10 @@ function node_save($node) { db_query("UPDATE node SET $u1 WHERE nid = '$node[nid]'"); db_query("UPDATE $node[type] SET $u2 WHERE nid = '$node[nid]'"); + if (($node[pid]) && ($node[status] == $status[posted])) { + db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'"); + } + watchdog("message", "node: modified '$node[title]'"); } else { @@ -95,8 +99,10 @@ function node_save($node) { if ($result && $lid = db_insert_id()) { $result = db_query("UPDATE node SET lid = '$lid' WHERE nid = '$nid'"); if ($result) { + if (($node[pid]) && ($node[status] == $status[posted])) { + db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'"); + } watchdog("message", "node: added '$node[title]'"); - return db_insert_id(); } else { watchdog("warning", "node: added '$node[title]' - failed"); @@ -113,9 +119,6 @@ function node_save($node) { } } - if (($node[pid]) && ($node[status] == $status[posted])) { - db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'"); - } } function node_view($node, $page) { diff --git a/modules/book.module b/modules/book.module index 6c42604a2..1b975695b 100644 --- a/modules/book.module +++ b/modules/book.module @@ -95,7 +95,6 @@ function book_form($edit = array()) { $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

\n"; if ($edit[pid]) { - print "parent: $edit[parent]
"; $node = node_get_object("nid", $edit[pid]); $output .= "". t("Parent") .":
\n"; $output .= "id\">". check_output($node->title) ."

\n"; @@ -157,7 +156,7 @@ function book_form($edit = array()) { } function book_save($edit) { - $id = node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "book")), array(userid => $edit[userid]))); + node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "book")), array(userid => $edit[userid]))); } function book_delete($id) { @@ -167,16 +166,25 @@ function book_delete($id) { function book_overview($parent = "", $offset = "") { global $PHP_SELF, $status; - $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); + $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND (n.status = '$status[posted]' OR n.status = '$status[expired]') AND b.parent = '$parent' ORDER BY b.weight"); $output .= "

"; + + $nodes = array(); while ($node = db_fetch_object($result)) { - $number++; - if ($offset) $output .= "
$offset$number. nid\">". check_output($node->title) ."\n"; - else $output .= "

$number. nid\">". check_output($node->title) ."\n"; - if ($PHP_SELF == "/admin.php") $output .= " (weight: $node->weight, status: $node->status) (nid\">edit, nid\">delete)"; + if ($node->status == $status[posted]) { + $number++; + if ($offset) $output .= "

$offset$number. nid\">". check_output($node->title) ."\n"; + else $output .= "

$number. nid\">". check_output($node->title) ."\n"; + if ($PHP_SELF == "/admin.php") $output .= " (weight: $node->weight, status: $node->status) (nid\">edit, nid\">delete)"; + } + array_push($nodes, $node); + } + + foreach ($nodes as $node) { $output .= book_overview($node->nid, "$offset$number."); } + $output .= "

"; return $output; } diff --git a/modules/book/book.module b/modules/book/book.module index 6c42604a2..1b975695b 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -95,7 +95,6 @@ function book_form($edit = array()) { $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

\n"; if ($edit[pid]) { - print "parent: $edit[parent]
"; $node = node_get_object("nid", $edit[pid]); $output .= "". t("Parent") .":
\n"; $output .= "id\">". check_output($node->title) ."

\n"; @@ -157,7 +156,7 @@ function book_form($edit = array()) { } function book_save($edit) { - $id = node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "book")), array(userid => $edit[userid]))); + node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "book")), array(userid => $edit[userid]))); } function book_delete($id) { @@ -167,16 +166,25 @@ function book_delete($id) { function book_overview($parent = "", $offset = "") { global $PHP_SELF, $status; - $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); + $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND (n.status = '$status[posted]' OR n.status = '$status[expired]') AND b.parent = '$parent' ORDER BY b.weight"); $output .= "

"; + + $nodes = array(); while ($node = db_fetch_object($result)) { - $number++; - if ($offset) $output .= "
$offset$number. nid\">". check_output($node->title) ."\n"; - else $output .= "

$number. nid\">". check_output($node->title) ."\n"; - if ($PHP_SELF == "/admin.php") $output .= " (weight: $node->weight, status: $node->status) (nid\">edit, nid\">delete)"; + if ($node->status == $status[posted]) { + $number++; + if ($offset) $output .= "

$offset$number. nid\">". check_output($node->title) ."\n"; + else $output .= "

$number. nid\">". check_output($node->title) ."\n"; + if ($PHP_SELF == "/admin.php") $output .= " (weight: $node->weight, status: $node->status) (nid\">edit, nid\">delete)"; + } + array_push($nodes, $node); + } + + foreach ($nodes as $node) { $output .= book_overview($node->nid, "$offset$number."); } + $output .= "

"; return $output; } -- cgit v1.2.3