Index: database/database.mysql =================================================================== RCS file: /cvs/drupal/drupal/database/database.mysql,v retrieving revision 1.188 diff -u -F^f -r1.188 database.mysql --- database/database.mysql 14 May 2005 20:59:01 -0000 1.188 +++ database/database.mysql 1 Jun 2005 04:05:22 -0000 @@ -438,6 +438,7 @@ grant_view tinyint(1) unsigned NOT NULL default '0', grant_update tinyint(1) unsigned NOT NULL default '0', grant_delete tinyint(1) unsigned NOT NULL default '0', + grant_create_child tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (nid,gid,realm) ) TYPE=MyISAM; @@ -808,7 +809,7 @@ INSERT INTO sequences (name, id) VALUES ('menu_mid', 1); -INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0); +INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0, 1); INSERT INTO filter_formats VALUES (1,'Filtered HTML',',1,2,',1); INSERT INTO filter_formats VALUES (2,'PHP code','',0); Index: modules/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book.module,v retrieving revision 1.298 diff -u -F^f -r1.298 book.module --- modules/book.module 21 May 2005 09:59:15 -0000 1.298 +++ modules/book.module 1 Jun 2005 04:05:23 -0000 @@ -514,7 +514,7 @@ function book_toc_recurse($nid, $indent, } function book_toc($exclude = 0) { - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 ORDER BY b.weight, n.title')); + $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 ORDER BY b.weight, n.title', 'n', 'nid', array('op' => 'create_child'))); while ($node = db_fetch_object($result)) { if (!$children[$node->parent]) { Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.495 diff -u -F^f -r1.495 node.module --- modules/node.module 1 Jun 2005 03:42:47 -0000 1.495 +++ modules/node.module 1 Jun 2005 04:05:26 -0000 @@ -1941,34 +1941,36 @@ function node_access_grants($op, $uid = } /** - * Determine whether the user has a global viewing grant for all nodes. + * Determine whether the user has a global grant for all nodes. */ -function node_access_view_all_nodes() { +function node_access_all_nodes($op = 'view') { static $access; - if (!isset($access)) { + if (!isset($access[$op])) { $sql = 'SELECT COUNT(*) FROM {node_access} WHERE nid = 0 AND CONCAT(realm, gid) IN ('; $grants = array(); - foreach (node_access_grants('view') as $realm => $gids) { + foreach (node_access_grants($op) as $realm => $gids) { foreach ($gids as $gid) { $grants[] = "'". $realm . $gid ."'"; } } - $sql .= implode(',', $grants) .') AND grant_view = 1'; + $sql .= implode(',', $grants) .') AND grant_'. $op .' = 1'; $result = db_query($sql, $node->nid); - $access = db_result($result); + $access[$op] = db_result($result); } - return $access; + return $access[$op]; } /** * Implementation of hook_db_rewrite_sql */ -function node_db_rewrite_sql($query, $primary_table, $primary_field) { - if ($primary_field == 'nid' && !node_access_view_all_nodes()) { +function node_db_rewrite_sql($query, $primary_table, $primary_field, $args) { + $op = $args['op'] ? $args['op'] : 'view'; + + if ($primary_field == 'nid' && !node_access_all_nodes($op)) { $return['join'] = _node_access_join_sql($primary_table); - $return['where'] = _node_access_where_sql(); + $return['where'] = _node_access_where_sql($op); $return['distinct'] = 1; return $return; }