View source  
  <?php
function outline_child_pages_permission() {
  return array(
    'outline own pages' => array(
      'title' => t('outline own pages'),
      'description' => t('TODO Add a description for \'outline own pages\''),
    ),
  );
}
function outline_child_pages_menu() {
  $items['node/%node/outline_children'] = array(
    'access callback' => 'outline_child_pages_access',
    'access arguments' => array(
      1,
      'tab',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'book_admin_edit',
      1,
    ),
    'title' => t('Outline child pages'),
    'file' => 'book.admin.inc',
    'file path' => drupal_get_path('module', 'book'),
    'weight' => 5,
    'type' => MENU_LOCAL_TASK,
  );
  $items['node/%node/outline_children_link'] = array(
    'access callback' => 'outline_child_pages_access_link',
    'access arguments' => array(
      1,
      'link',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'book_admin_edit',
      1,
    ),
    'title' => t('Outline child pages'),
    'file' => 'book.admin.inc',
    'file path' => drupal_get_path('module', 'book'),
    'weight' => 5,
    'type' => MENU_NORMAL_ITEM,
  );
  $items['outline_designer/ocp_ajax'] = array(
    'access callback' => '_outline_child_pages_ajax_access',
    'page callback' => '_outline_designer_ajax',
    'page arguments' => array(
      2,
      3,
      4,
      5,
      6,
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}
function _outline_child_pages_ajax_access() {
  global $user;
  return $user->uid == 1 || user_access('administer book outlines') || user_access('outline own pages') && user_access('add content to books') || user_access('add content to personal books');
}
function outline_child_pages_node_access($type, $node) {
  global $user;
  if (function_exists('outline_designer_og_menu')) {
    if (variable_get('outline_child_pages_type', 'tab') == $type && ($user->uid == 1 || og_is_group_admin($node, $user) || user_access('administer book outlines') || user_access('outline own pages') && user_access('add content to books') && node_access('update', $node))) {
      $has_children = db_query('SELECT ml.has_children FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = :b.nid', array(
        ':b.nid' => $node->nid,
      ))
        ->fetchField();
      return $has_children;
    }
    else {
      return 0;
    }
  }
  else {
    if (variable_get('outline_child_pages_type', 'tab') == $type && ($user->uid == 1 || user_access('administer book outlines') || user_access('outline own pages') && user_access('add content to books') && node_access('update', $node))) {
      $has_children = db_query('SELECT ml.has_children FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = :b.nid', array(
        ':b.nid' => $node->nid,
      ))
        ->fetchField();
      return $has_children;
    }
    else {
      return 0;
    }
  }
}
function outline_child_pages_access_link($node, $type) {
  global $user;
  $has_children = db_query('SELECT ml.has_children FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = :b.nid', array(
    ':b.nid' => $node->nid,
  ))
    ->fetchField();
  if (function_exists('outline_designer_og_menu')) {
    if (variable_get('outline_child_pages_type', 'link') == $type && ($user->uid == 1 || og_is_group_admin($node, $user) || user_access('administer book outlines') || user_access('outline own pages') && user_access('add content to books') && node_access('update', $node))) {
      return $has_children;
    }
    else {
      return 0;
    }
  }
  else {
    if (variable_get('outline_child_pages_type', 'link') == $type && ($user->uid == 1 || user_access('administer book outlines') || user_access('outline own pages') && user_access('add content to books') && node_access('update', $node))) {
      return $has_children;
    }
    else {
      return 0;
    }
  }
}
function outline_child_pages_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();
  if ($type == 'node' && isset($node->book)) {
    if (!$teaser) {
      if (outline_child_pages_access($node, 'link')) {
        $links['book_outline_child'] = array(
          'title' => t('Outline child pages'),
          'href' => 'node/' . $node->nid . '/outline_children_link',
        );
      }
    }
  }
  return $links;
}
function outline_child_pages_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == '_outline_designer_settings') {
    $form["ui"]['outline_child_pages_type'] = array(
      '#type' => 'radios',
      '#title' => t('Display "Outline child pages" as a'),
      '#options' => array(
        'tab' => 'Tab',
        'link' => 'Link',
      ),
      '#default_value' => variable_get('outline_child_pages_type', 'tab'),
      '#weight' => 5,
    );
  }
  
  if ($form_id == 'book_admin_edit' && arg(0) == "node" && (arg(2) == 'outline_children' || arg(2) == 'outline_children_link')) {
    _outline_designer_book_admin_form_alter($form, $form_state, $form_id, 'outline_designer/ocp_ajax/');
  }
  elseif ($form_id == 'book_admin_edit' && arg(0) == 'outline_designer' && arg(1) == 'ocp_ajax') {
    _outline_designer_book_admin_form_alter($form, $form_state, $form_id, 'outline_designer/ocp_ajax/');
  }
}