/
read.php
58 lines (49 loc) · 1006 Bytes
/
read.php
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
<?php
/*
Copyright 2014 Mhd Sulhan
Authors:
- mhd.sulhan (m.shulhan@gmail.com)
*/
function get_group ($pid, $depth)
{
$q ="
select A._profile_id
, A.id
, A.pid
, A.name
, A.name as text
from _group A
where A._profile_id = ?
and A.pid = ?
order by A.id
";
$ps = Jaring::$_db->prepare ($q);
$ps->execute (array (Jaring::$_c_profile_id, $pid));
$rs = $ps->fetchAll (PDO::FETCH_ASSOC);
$ps->closeCursor ();
$index = 0;
foreach ($rs as &$m) {
$id = $m["id"];
if ($index === 0) {
$m["isFirst"] = true;
} else {
$m["isFirst"] = false;
}
$m["iconCls"] = "group";
$m["index"] = $index++;
$m["depth"] = $depth;
$c = get_group ($id, $depth + 1);
if (count ($c) <= 0) {
$m["leaf"] = true;
} else {
$m["children"] = $c;
$m["expandable"] = true;
$m["expanded"] = true;
$m["loaded"] = true;
}
}
return $rs;
}
$data = get_group (0, 0);
Jaring::$_out["success"] = true;
Jaring::$_out["children"] = $data;