You are here

function _outline_designer_tree_recurse in Outline Designer 5

This is a helper function for pulling all the data about a tree together to be rendered, recursively traversing the tree to get all the nodes, it is a helper function for the load_tree ajax function

2 calls to _outline_designer_tree_recurse()
ajax.php in ./ajax.php
_outline_designer_ajax in ./outline_designer.module
Implementation of the ajax menu hook

File

./outline_designer.module, line 323

Code

function _outline_designer_tree_recurse($nid, $tree = array()) {
  global $user;
  $result = db_query("SELECT n.uid,n.nid,parent,title,type FROM {book} as b JOIN {node} as n ON n.vid=b.vid WHERE b.parent=%d ORDER BY weight", $nid);
  while ($value = db_fetch_array($result)) {
    if (user_access(_outline_designer_get_pstr('edit', $value['type']))) {
      $allow_edit = 1;
    }
    elseif ($user->uid == $value['uid'] && user_access(_outline_designer_get_pstr('edit own', $value['type']))) {
      $allow_edit = 1;
    }
    else {
      $allow_edit = 0;
    }
    array_push($tree, array(
      $value['nid'],
      $value['parent'],
      $value['title'],
      variable_get("outline_designer_" . $value['type'] . "_icon", drupal_get_path('module', 'outline_designer') . "/images/node.png"),
      $allow_edit,
    ));
    $tree = _outline_designer_tree_recurse($value['nid'], $tree);
  }
  return $tree;
}