[gosa.git] / gosa-core / plugins / admin / newConfigManagement / class_ConfigManagementDataModel.inc
1 <?php
3 class ConfigManagementDataModel
4 {
5 private $data = array();
6 private $typeToPath = array();
7 private $idToPath = array();
9 function __construct()
10 {
11 $this->data = array();
12 $this->data['linear'] = array();
13 $this->data['recursive'] = array();
14 $this->addItem('root', '','root', array());
15 }
17 function getDataModel()
18 {
19 return($this->data);
20 }
25 function addItem($type, $path, $name, $values = array(), $status = "")
26 {
27 if($path == ""){
28 $parentItem = &$this->data['recursive'];
29 $parentId = NULL;
30 $parentDn = "";
31 }elseif(isset($this->data['linear'][$path])){
32 $parentItem = &$this->data['linear'][$path]['children'];
33 $parentId = $this->data['linear'][$path]['id'];
34 $parentDn = $this->data['linear'][$path]['dn'];
35 }else{
36 echo "No parent";
37 return(FALSE);
38 }
40 $this->currentID ++;
41 $entryPath = "{$path}/{$name}";
42 $entryDn = rtrim("cn={$name},{$parentDn}",',');
43 $entryId = $this->currentID;
45 $entry['path'] = $entryPath;
46 $entry['dn'] = $entryDn;
47 $entry['id'] = $entryId;
48 $entry['parentId'] = $parentId;
49 $entry['name'] = $name;
50 $entry['path'] = $entryPath;
51 $entry['parentPath'] = $path;
52 $entry['type'] = $type;
53 $entry['status'] = $status;
54 $entry['values'] = $values;
55 $entry['children'] = array();
57 $parentItem[$entryPath] = &$entry;
58 $this->data['linear'][$entryPath] = &$parentItem[$entryPath];
60 $this->idToPath[$entryId] = $entryPath;
61 $this->typeToPath[$type][$name] = $entryPath;
63 return($entryId);
64 }
66 function pathToDn($path)
67 {
69 }
71 function getItemsByType($type)
72 {
73 $res = array();
74 foreach($this->typeToPath[$type] as $path){
75 $res[$path] = $this->data['linear'][$path];
76 }
77 return($res);
78 }
79 }
81 ?>