-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure.php
More file actions
129 lines (111 loc) · 2.74 KB
/
structure.php
File metadata and controls
129 lines (111 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
require_once('common.php');
class Structure {
public $tree;
public $tasks;
private $name;
private $structureid;
public function __get($name)
{
switch($name)
{
default:
trace("error","cannot access property ".$name);
}
}
function PrintSubTask($level,$task)
{
$level = $level+1;
for($i=0;$i<$level;$i++)
echo " ";
echo $task['key']."\n";
foreach($task['children'] as $stask)
$this->PrintSubTask($level,$stask);
}
function __construct($structureid)
{
if(!ctype_digit($structureid))
trace("error","Invalid Structure Id");
$rows = Jira::GetStructure($structureid);
$this->structureid = $structureid;
$result = Jira::GETStructureInfo($structureid);
if(isset($result->error))
{
trace('error',$result->error.EOL);
exit(-1);
}
//print_r($result);
//makedir("uploads\\".$structureid);
$this->name = $result->name;
DebugLog("Found structure ".$this->name);
// $level0 = array();
// $level1 = array();
// $level2 = array();
// $level3 = array();
// $root = array();
// $root['children'] = array();
//$parent = $root;
foreach($rows as $row)
{
$query="id=".$row->taskid;
$tasks = Jira::Search($query,1,"key");
$tasks[0]['level'] = $row->level;
$tasks[0]['children'] = array();
$this->tasks[] = &$tasks[0];
if($row->level == 1)
{
$level0[] = &$tasks[0];
}
else
{
$level = 'level'.(string)($row->level-2);
$lastindex = count($$level)-1;
$arr = &$$level;
$arr[$lastindex]['children'][] = &$tasks[0];
$level = 'level'.(string)($row->level-1);
$arr = &$$level;
$arr[] = &$tasks[0];
}
//else if($row->level == 2)
//{
// $level0[count($level0)-1]['children'][] = &$tasks[0];
// $level1[] = &$tasks[0];
//
//}
//else if($row->level == 3)
//{
//echo $level1[count($level1)-1]['key'];
// $level1[count($level1)-1]['children'][] = &$tasks[0];
// $level2[] = &$tasks[0];
//}
//if($tasks[0]['level'] == 1)
//{
// $root['children'][] = $tasks[0];
//}
//else
//$this->PlugTask($root,$tasks[0],$tasks[0]['level']);
//if($tasks[0]['level'] == 2)
//{
// $root['children'][count($root['children'])-1]['children'][] = $tasks[0];
//}
//if($tasks[0]['level'] == 2)
//{
// $root['children'][count($root['children'])-1]['children'][] = $tasks[0];
//}
//$parent = $$parent_array[count($$parent_array)-1];
//echo $parent;
}
$this->tree = &$level0;
//print_r($this->tree);
for($i=0;$i<count($this->tasks);$i++)
{
//print_r($task);
//echo count($task['children']);
//echo "\n";
if(count($this->tasks[$i]['children'])>0)
$this->tasks[$i]['isparent'] = 1;
else
$this->tasks[$i]['isparent'] = 0;
}
}
}