Commit 0bac8dad authored by Dries's avatar Dries

- Patch #302207 by John Morahan et al: updated book module to new DB layer.

parent 31e791b9
......@@ -561,7 +561,7 @@ function book_update_bid($book_link) {
if ($mlids) {
db_update('book')
->fields(array('bid', $book_link['bid']))
->fields(array('bid' => $book_link['bid']))
->condition('mlid', $mlids, 'IN')
->execute();
}
......@@ -760,6 +760,10 @@ function book_nodeapi_presave($node) {
// Always save a revision for non-administrators.
if (!empty($node->book['bid']) && !user_access('administer nodes')) {
$node->revision = 1;
// The database schema requires a log message for every revision.
if (!isset($node->log)) {
$node->log = '';
}
}
// Make sure a new node gets a new menu link.
if (empty($node->nid)) {
......
......@@ -21,7 +21,7 @@ class BookTestCase extends DrupalWebTestCase {
*/
function testBook() {
// Create users.
$book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'add content to books'));
$book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
$web_user = $this->drupalCreateUser(array('access printer-friendly version'));
// Create new book.
......@@ -57,6 +57,25 @@ class BookTestCase extends DrupalWebTestCase {
$this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3]);
$this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4]);
$this->checkBookNode($nodes[4], NULL, $nodes[3], $book, false);
$this->drupalLogout();
// Create a second book, and move an existing book page into it.
$this->drupalLogin($book_author);
$other_book = $this->createBookNode('new');
$node = $this->createBookNode($book->nid);
$edit = array('book[bid]' => $other_book->nid);
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->drupalLogout();
$this->drupalLogin($web_user);
// Check that the nodes in the second book are displayed correctly.
// First we must set $this->book to the second book, so that the
// correct regex will be generated for testing the outline.
$this->book = $other_book;
$this->checkBookNode($other_book, array($node), false, false, $node);
$this->checkBookNode($node, NULL, $other_book, $other_book, false);
}
/**
......
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