Index: book_access.module
===================================================================
--- book_access.module	(revision 8)
+++ book_access.module	(working copy)
@@ -313,7 +313,7 @@
   global $user;
   $permitted_bids = NULL;
 
-  if ($user->uid == 0 || user_access('administer nodes')) {
+  if ($user->uid == 1 || user_access('administer nodes')) {
     return;
   }
 
@@ -360,3 +360,42 @@
   }
 }
 
+
+/**
+ * Implementation of hook_nodeapi().
+ */
+function book_access_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  global $user;
+  switch ($op) {
+      case 'alter':
+
+        if ($user->uid == 1 || user_access('administer nodes') ){
+	  break; //show Add Child Page link
+	}
+
+        $sql = "
+          SELECT nid
+          FROM {node_access}
+          WHERE realm = 'book_access'
+          AND gid IN (%s)
+          AND grant_update > 0
+        ";
+
+	$permitted_bids = array();
+        $results = db_query($sql, implode(',', array_keys($user->roles)));
+
+        while ($result = db_fetch_array($results)) {
+          $permitted_bids[] = $result['nid'];
+        }
+	$book_permitted = in_array( $node->book['bid'], $permitted_bids);
+
+	
+        $child_type = variable_get('book_child_type', 'book');
+	if($book_permitted && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) {
+	  break; //show Add Child Page link
+	}
+        unset($node->links['book_add_child']); //remove Add Child Page link
+        break;
+  }
+
+}

