Commit fae651d7 authored by Dries's avatar Dries

- Fixed submission bug in book.module. (reported by Remco)
parent 42081ec0
......@@ -82,10 +82,16 @@ function book_parent_query($parent) {
}
function book_toc($parent = "", $indent = "", $toc = array()) {
global $status;
global $status, $user;
// select all child nodes:
$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 ". book_parent_query($parent) ." ORDER BY b.weight");
// add root node:
if (user_access($user, "book")) {
$toc[0] = " ";
}
// build table of contents:
while ($node = db_fetch_object($result)) {
$toc[$node->nid] = "$indent $node->title";
......@@ -109,7 +115,7 @@ function book_form($edit = array()) {
$form .= form_hidden("parent", $edit[parent]);
}
else {
$form .= form_select(t("Parent"), "parent", $edit[parent], user_access($user, "book") ? array_merge(array(0 => " "), book_toc()) : book_toc(), t("The parent subject or category the page belongs in."));
$form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in."));
}
$form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html));
......
......@@ -82,10 +82,16 @@ function book_parent_query($parent) {
}
function book_toc($parent = "", $indent = "", $toc = array()) {
global $status;
global $status, $user;
// select all child nodes:
$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 ". book_parent_query($parent) ." ORDER BY b.weight");
// add root node:
if (user_access($user, "book")) {
$toc[0] = " ";
}
// build table of contents:
while ($node = db_fetch_object($result)) {
$toc[$node->nid] = "$indent $node->title";
......@@ -109,7 +115,7 @@ function book_form($edit = array()) {
$form .= form_hidden("parent", $edit[parent]);
}
else {
$form .= form_select(t("Parent"), "parent", $edit[parent], user_access($user, "book") ? array_merge(array(0 => " "), book_toc()) : book_toc(), t("The parent subject or category the page belongs in."));
$form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in."));
}
$form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html));
......
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