Commit 871d0619 authored by Dries's avatar Dries

- fixed another bug
parent 6ca6e831
......@@ -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) {
......
......@@ -95,7 +95,6 @@ function book_form($edit = array()) {
$output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>\n";
if ($edit[pid]) {
print "parent: $edit[parent]<BR>";
$node = node_get_object("nid", $edit[pid]);
$output .= "<B>". t("Parent") .":</B><BR>\n";
$output .= "<A HREF=\"node.php?id=$node->id\">". check_output($node->title) ."</A><P>\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 .= "<DL>";
$nodes = array();
while ($node = db_fetch_object($result)) {
$number++;
if ($offset) $output .= "<DT>$offset$number. <A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>\n";
else $output .= "<DT><P>$number. <B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B>\n";
if ($PHP_SELF == "/admin.php") $output .= " <SMALL>(weight: $node->weight, status: $node->status) (<A HREF=\"admin.php?mod=book&op=edit&id=$node->nid\">edit</A>, <A HREF=\"admin.php?mod=book&op=delete&id=$node->nid\">delete</A>)</SMALL>";
if ($node->status == $status[posted]) {
$number++;
if ($offset) $output .= "<DT>$offset$number. <A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>\n";
else $output .= "<DT><P>$number. <B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B>\n";
if ($PHP_SELF == "/admin.php") $output .= " <SMALL>(weight: $node->weight, status: $node->status) (<A HREF=\"admin.php?mod=book&op=edit&id=$node->nid\">edit</A>, <A HREF=\"admin.php?mod=book&op=delete&id=$node->nid\">delete</A>)</SMALL>";
}
array_push($nodes, $node);
}
foreach ($nodes as $node) {
$output .= book_overview($node->nid, "$offset$number.");
}
$output .= "</DL>";
return $output;
}
......
......@@ -95,7 +95,6 @@ function book_form($edit = array()) {
$output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>\n";
if ($edit[pid]) {
print "parent: $edit[parent]<BR>";
$node = node_get_object("nid", $edit[pid]);
$output .= "<B>". t("Parent") .":</B><BR>\n";
$output .= "<A HREF=\"node.php?id=$node->id\">". check_output($node->title) ."</A><P>\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 .= "<DL>";
$nodes = array();
while ($node = db_fetch_object($result)) {
$number++;
if ($offset) $output .= "<DT>$offset$number. <A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>\n";
else $output .= "<DT><P>$number. <B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B>\n";
if ($PHP_SELF == "/admin.php") $output .= " <SMALL>(weight: $node->weight, status: $node->status) (<A HREF=\"admin.php?mod=book&op=edit&id=$node->nid\">edit</A>, <A HREF=\"admin.php?mod=book&op=delete&id=$node->nid\">delete</A>)</SMALL>";
if ($node->status == $status[posted]) {
$number++;
if ($offset) $output .= "<DT>$offset$number. <A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>\n";
else $output .= "<DT><P>$number. <B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B>\n";
if ($PHP_SELF == "/admin.php") $output .= " <SMALL>(weight: $node->weight, status: $node->status) (<A HREF=\"admin.php?mod=book&op=edit&id=$node->nid\">edit</A>, <A HREF=\"admin.php?mod=book&op=delete&id=$node->nid\">delete</A>)</SMALL>";
}
array_push($nodes, $node);
}
foreach ($nodes as $node) {
$output .= book_overview($node->nid, "$offset$number.");
}
$output .= "</DL>";
return $output;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment