You are here

function nodehierarchy_node_can_be_child_of in Node Hierarchy 5

Same name and namespace in other branches
  1. 6.3 nodehierarchy.module \nodehierarchy_node_can_be_child_of()
  2. 6 nodehierarchy.module \nodehierarchy_node_can_be_child_of()
  3. 6.2 nodehierarchy.module \nodehierarchy_node_can_be_child_of()
  4. 7.4 nodehierarchy.admin.inc \nodehierarchy_node_can_be_child_of()
  5. 7.2 nodehierarchy.module \nodehierarchy_node_can_be_child_of()

Determine if a given node can be a child of another given node.

Parameters

$parent: The potentential parent node (can be null for any node).

$child: The potential child node (can be null for any node).

Return value

Boolean. Whether second node can be a child of the first. If parent is null, returns whether the child can be a child of any node. If child is null returns whether the parent can be parent of any node. If both are null, results undefined. (Returns TRUE but that could to change).

2 calls to nodehierarchy_node_can_be_child_of()
nodehierarchy_node_can_be_child in ./nodehierarchy.module
Wrapper for nodehierarchy_node_can_be_child_of.
nodehierarchy_node_can_be_parent in ./nodehierarchy.module
Wrapper for nodehierarchy_node_can_be_child_of.

File

./nodehierarchy.module, line 500
A module to make nodes hierarchical.

Code

function nodehierarchy_node_can_be_child_of($parent = NULL, $child = NULL) {
  $out = TRUE;
  if ($parent) {
    $out = $out && variable_get('nh_parent_' . $parent->type, FALSE);
  }
  if ($child) {
    $out = $out && variable_get('nh_child_' . $child->type, FALSE);
  }

  // TODO: Implement settings system where certain node types can only be
  // children of certain other node types.
  return $out;
}