Example #1
0
$defaults = (array_key_exists('defaults', $options)) ? $options['defaults'] : array();
$allowables = (array_key_exists('allowables', $options) && is_array($options['allowables']) && $options['allowables'] != null) ? $options['allowables'] : array();
$allow_only_defaults = (array_key_exists('allow_only_defaults', $options) && $options['allow_only_defaults'] === 'true');
$mark_allow_user = (strstr($where, 'allow_user') !== false);
$mark_allow_course = (strstr($where, 'allow_course') !== false);

// preload all nodes
$allnodes = array();
Database::get()->queryFunc("select * from hierarchy order by lft", function($row) use (&$allnodes) {
    $allnodes[] = $row;
});

// preload all user's nodes
$usernodes = array();
if ($uid) {
    $usernodes = $user->getDepartmentNodes($uid);
}

// initialize vars
$defs = (is_array($defaults)) ? $defaults : array(intval($defaults));
$subdefs = ($allow_only_defaults) ? $tree->buildSubtrees($defs, $allnodes) : array();
$suballowed = ($allowables != null) ? $tree->buildSubtrees($allowables, $allnodes) : null;
$excludeLft = 0;
$excludeRgt = 0;
$fetchNodeById = "select * from hierarchy where id = ?d";

if ($requestId <= 0) {
    $nodes = $tree->buildRootsArray();
    
    foreach ($tree_array as $key => $value) {
        $data[] = array(