Rev 148 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 148 | Rev 150 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
63 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
64 | if ($nonjs) { |
64 | if ($nonjs) { |
65 | $json[] = array('id' => 'oidplus:system', 'icon' => 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/system.png', 'text' => 'System'); |
65 | $json[] = array('id' => 'oidplus:system', 'icon' => 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/system.png', 'text' => 'System'); |
66 | 66 | ||
67 | $parent = ''; |
67 | $parent = ''; |
68 | $res = OIDplus::db()->query("select parent from ".OIDPLUS_TABLENAME_PREFIX."objects where id = '".OIDplus::db()->real_escape_string($req_goto)."'"); |
68 | $res = OIDplus::db()->query("select parent from ".OIDPLUS_TABLENAME_PREFIX."objects where id = ?", array($req_goto)); |
69 | while ($row = OIDplus::db()->fetch_object($res)) { |
69 | while ($row = OIDplus::db()->fetch_object($res)) { |
70 | $parent = $row->parent; |
70 | $parent = $row->parent; |
71 | } |
71 | } |
72 | 72 | ||
73 | $objTypesChildren = array(); |
73 | $objTypesChildren = array(); |
Line 81... | Line 81... | ||
81 | $tmp = null; |
81 | $tmp = null; |
82 | } |
82 | } |
83 | if (!is_null($tmp) && ($ot == get_class($tmp))) { |
83 | if (!is_null($tmp) && ($ot == get_class($tmp))) { |
84 | // TODO: Instead of just having 3 levels (parent, this and children), it would be better if we'd had a full tree of all parents |
84 | // TODO: Instead of just having 3 levels (parent, this and children), it would be better if we'd had a full tree of all parents |
85 | // on the other hand, for giving search engines content, this is good enough |
85 | // on the other hand, for giving search engines content, this is good enough |
- | 86 | if (empty($parent)) { |
|
86 | $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where " . |
87 | $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where " . |
87 | "parent = '".OIDplus::db()->real_escape_string($req_goto)."' or " . |
88 | "parent = ? or " . |
- | 89 | "id = ? " . |
|
88 | "id = '".OIDplus::db()->real_escape_string($req_goto)."' " . |
90 | "order by ".OIDplus::db()->natOrder('id'), array($req_goto, $req_goto)); |
- | 91 | } else { |
|
89 | ((!empty($parent)) ? " or id = '".OIDplus::db()->real_escape_string($parent)."' " : "") . |
92 | $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where " . |
- | 93 | "parent = ? or " . |
|
- | 94 | "id = ? or " . |
|
- | 95 | "id = ? ". |
|
90 | "order by ".OIDplus::db()->natOrder('id')); |
96 | "order by ".OIDplus::db()->natOrder('id'), array($req_goto, $req_goto, $parent)); |
- | 97 | } |
|
- | 98 | ||
91 | $z_used = 0; |
99 | $z_used = 0; |
92 | $y_used = 0; |
100 | $y_used = 0; |
93 | $x_used = 0; |
101 | $x_used = 0; |
94 | $stufe = 0; |
102 | $stufe = 0; |
95 | $menu_entries = array(); |
103 | $menu_entries = array(); |
Line 120... | Line 128... | ||
120 | if (isset($req_goto)) { |
128 | if (isset($req_goto)) { |
121 | $goto = $req_goto; |
129 | $goto = $req_goto; |
122 | $path = array(); |
130 | $path = array(); |
123 | while (true) { |
131 | while (true) { |
124 | $path[] = $goto; |
132 | $path[] = $goto; |
125 | $res = OIDplus::db()->query("select parent from ".OIDPLUS_TABLENAME_PREFIX."objects where id = '".OIDplus::db()->real_escape_string($goto)."'"); |
133 | $res = OIDplus::db()->query("select parent from ".OIDPLUS_TABLENAME_PREFIX."objects where id = ?", array($goto)); |
126 | if (OIDplus::db()->num_rows($res) == 0) break; |
134 | if (OIDplus::db()->num_rows($res) == 0) break; |
127 | $row = OIDplus::db()->fetch_array($res); |
135 | $row = OIDplus::db()->fetch_array($res); |
128 | $goto = $row['parent']; |
136 | $goto = $row['parent']; |
- | 137 | if ($goto == '') continue; |
|
129 | } |
138 | } |
130 | 139 | ||
131 | $goto_path = array_reverse($path); |
140 | $goto_path = array_reverse($path); |
132 | } else { |
141 | } else { |
133 | $goto_path = null; |
142 | $goto_path = null; |