You are here

function _nodehierarchy_get_parent_pulldown_items in Node Hierarchy 6

Same name and namespace in other branches
  1. 5 nodehierarchy.module \_nodehierarchy_get_parent_pulldown_items()

Get the items for the parent selector pulldown.

1 call to _nodehierarchy_get_parent_pulldown_items()
_nodehierarchy_get_parent_pulldown in ./nodehierarchy.module
Get the parent selector pulldown.

File

./nodehierarchy.module, line 1122

Code

function _nodehierarchy_get_parent_pulldown_items($parent_id, $types, $child_node = null, $depth = 0) {
  $out = array();
  $query = "SELECT n.*, h.* FROM {node} n INNER JOIN {nodehierarchy} h ON h.nid = n.nid WHERE h.parent = %d AND n.type IN (" . implode(",", $types) . ") ORDER BY h.order_by ASC";
  $result = db_query(db_rewrite_sql($query), $parent_id);
  while ($hierarchylist = db_fetch_object($result)) {
    if ($hierarchylist->nid != $child_node && node_access('update', $hierarchylist)) {
      $out[$hierarchylist->nid] = str_repeat('--', $depth) . ' ' . $hierarchylist->title;
      $children = _nodehierarchy_get_parent_pulldown_items($hierarchylist->nid, $types, $child_node, $depth + 1);
      $out += $children;
    }
  }
  return $out;
}