ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilOrgUnitTree.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once('Services/Tree/classes/class.ilTree.php');
5 require_once('Services/OrgUnit/classes/class.ilOrgUnit.php');
6 
15 class ilOrgUnitTree extends ilTree
16 {
17  const TREE_ID = 1;
18 
19  const ROOT_UNIT_ID = 1;
20 
21  private $recursive_sub_tree = array();
22 
23  public function __construct()
24  {
25  parent::__construct( self::ROOT_UNIT_ID );
26 
27  $this->tree_id = self::TREE_ID;
28 
29  $this->table_tree = 'org_unit_tree';
30  $this->table_obj_data = 'org_unit_data';
31  $this->table_obj_reference = '';
32 
33  $this->tree_pk = 'tree';
34  $this->obj_pk = 'ou_id';
35  $this->ref_pk = '';
36 
37  $this->gap = 0;
38  }
39 
40  public function getRecursiveOrgUnitTree($root_node = self::ROOT_UNIT_ID)
41  {
42  $root_node_data = $this->getNodeData($root_node);
43  $nodes = $this->getSubTree($root_node_data);
44 
45  $root_unit = null;
46  $index = array();
47 
48  foreach($nodes as &$node)
49  {
50  $index[$node['child']] = $unit = ilOrgUnit::getInstance($node['child']);
51 
52  if($node['parent'])
53  {
54  $unit->setParent($index[$node['parent']]);
55  $index[$node['parent']]->addChild($unit);
56  }
57  else $root_unit = $unit;
58  }
59 
60  $root_unit->sortChilds();
61 
62  return $root_unit;
63  }
64 
65 }
66 
67 ?>