All pastes #334729 Raw Edit

Anonymous

public text v1 · immutable
#334729 ·published 2007-01-31 20:52 UTC
rendered paste body
function getOrganizationalUnits($node=0, $depthMax=0, $includeArchived=0, $currentDepth=1,$safety=0)
    {
        // Assign node children to node array
        $nodeKids = $this->getOrganizationalNodeUnits($node);

        // Check for recursive nature
        while ( $nodeKids && ($currentDepth < $depthMax || $depthMax == 0) )
        {
        	for ($i = 0; $i < count($nodeKids); $i++)
            {
                $nextLevel = 1 + $currentDepth;
            	$nodeKids[$i]['subOrgs'] = $this->getOrganizationalUnits($i['organizational_units_id'],$depthMax,$includeArchived,$nextLevel,$safety+1);
            }
        }
        return $nodeKids;
    }

function getOrganizationalNodeUnits($node=0, $includeArchived=0)
    {
        $where = ($includeArchived) ? '' : "AND archived != '1' " ;
    	$rs_orgUnits = $this->fingerprint->db->select(
            // SELECT
            'organizational_units_id, name, description, parent_id, archived',
            // FROM
            'organizational_units',
            // WHERE
            "parent_id = '$node'
            $where"
        );
        if ( $this->fingerprint->db->getRecordCount($rs_orgUnits) )
        {
        	$orgUnits = $this->db->makeArray($rs_orgUnits);
        }
        else
        {
        	$orgUnits = NULL;
        }

        return $orgUnits;
    }