r1249 + another minor bugfix
[racktables] / inc / navigation.php
CommitLineData
e673ee24
DO
1<?
2/*
3*
4* This file implements generic navigation for RackTables.
5*
6*/
7
83dd1b15
DO
8$page = array();
9$tab = array();
10$helptab = array();
11$trigger = array();
12$ophandler = array();
13
e673ee24
DO
14$page['index']['title'] = 'static_title';
15$page['index']['handler'] = 'renderIndex';
16
17$page['rackspace']['title'] = 'static_title';
18$page['rackspace']['handler'] = 'handler_rackspace';
19$page['rackspace']['parent'] = 'index';
20$tab['rackspace']['default'] = 'Browse';
21$tab['rackspace']['history'] = 'History';
22
23$page['objects']['title'] = 'static_title';
24$page['objects']['handler'] = 'handler_objects';
25$page['objects']['parent'] = 'index';
26$tab['objects']['default'] = 'View';
27$tab['objects']['newobj'] = 'Add an object';
28$tab['objects']['newmulti'] = 'Add multiple objects';
29
30$page['row']['title'] = 'dynamic_title_row';
31$page['row']['handler'] = 'handler_row';
32$page['row']['bypass'] = 'row_id';
33$page['row']['parent'] = 'rackspace';
34$tab['row']['default'] = 'View';
35$tab['row']['newrack'] = 'Add new rack';
36
37$page['rack']['title'] = 'dynamic_title_rack';
38$page['rack']['handler'] = 'handler_rack';
39$page['rack']['bypass'] = 'rack_id';
40$page['rack']['parent'] = 'row';
41$tab['rack']['default'] = 'View';
42$tab['rack']['edit'] = 'Properties';
43$tab['rack']['design'] = 'Design';
44$tab['rack']['problems'] = 'Problems';
beee6141
DO
45$helptab['rack']['design'] = 'rackspace';
46$helptab['rack']['problems'] = 'rackspace';
e673ee24
DO
47
48$page['objgroup']['title'] = 'dynamic_title_objgroup';
49$page['objgroup']['handler'] = 'handler_objgroup';
50$page['objgroup']['bypass'] = 'group_id';
51$page['objgroup']['parent'] = 'objects';
52
53$page['object']['title'] = 'dynamic_title_object';
54$page['object']['handler'] = 'handler_object';
55$page['object']['bypass'] = 'object_id';
56$page['object']['parent'] = 'objgroup';
57$tab['object']['default'] = 'View';
58$tab['object']['edit'] = 'Properties';
59$tab['object']['rackspace'] = 'Rackspace';
60$tab['object']['ports'] = 'Ports';
61$tab['object']['network'] = 'IPv4';
737f9ac1 62$tab['object']['portfwrd'] = 'NATv4';
641fe9b0 63$tab['object']['switchvlans'] = 'VLANs';
9c67f713 64$tab['object']['snmpportfinder'] = 'SNMP port finder';
bdd05c5d 65$helptab['object']['network'] = 'nets';
150fdd66 66$helptab['object']['ports'] = 'ports';
bdd05c5d
DO
67$helptab['object']['portfwrd'] = 'nets';
68$helptab['object']['rackspace'] = 'rackspace';
641fe9b0 69$trigger['object']['switchvlans'] = 'trigger_switchvlans';
9c67f713 70$trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
e673ee24
DO
71$ophandler['object']['ports']['addPort'] = 'addPortForObject';
72$ophandler['object']['ports']['delPort'] = 'delPortFromObject';
73$ophandler['object']['ports']['editPort'] = 'editPortForObject';
74$ophandler['object']['ports']['linkPort'] = 'linkPortForObject';
75$ophandler['object']['ports']['unlinkPort'] = 'unlinkPortForObject';
76$ophandler['object']['ports']['addMultiPorts'] = 'addMultiPorts';
77$ophandler['object']['ports']['useup'] = 'useupPort';
78$ophandler['object']['network']['editAddressFromObject'] = 'editAddressFromObject';
79$ophandler['object']['network']['addAddrFObj'] = 'addAddressToObject';
80$ophandler['object']['network']['delAddrFObj'] = 'delAddressFromObject';
81$ophandler['object']['edit']['del'] = 'resetAttrValue';
0dfb8a2a 82$ophandler['object']['edit']['upd'] = 'updateAttrValues';
e673ee24
DO
83$ophandler['object']['portfwrd']['forwardPorts'] = 'addPortForwarding';
84$ophandler['object']['portfwrd']['delPortForwarding'] = 'delPortForwarding';
85$ophandler['object']['portfwrd']['updPortForwarding'] = 'updPortForwarding';
641fe9b0 86$ophandler['object']['switchvlans']['submit'] = 'updateVLANMembership';
e673ee24
DO
87
88$page['ipv4space']['title'] = 'static_title';
89$page['ipv4space']['handler'] = 'handler_ipv4space';
90$page['ipv4space']['parent'] = 'index';
91$tab['ipv4space']['default'] = 'Browse';
92$tab['ipv4space']['newrange'] = 'Manage ranges';
bdd05c5d
DO
93$helptab['ipv4space']['default'] = 'nets';
94$helptab['ipv4space']['newrange'] = 'nets';
e673ee24
DO
95$ophandler['ipv4space']['newrange']['addRange'] = 'addNewrange';
96$ophandler['ipv4space']['newrange']['delRange'] = 'delRange';
97
98$page['iprange']['title'] = 'dynamic_title_iprange';
99$page['iprange']['handler'] = 'handler_iprange';
100$page['iprange']['parent'] = 'ipv4space';
101$page['iprange']['bypass'] = 'id';
102$tab['iprange']['default'] = 'Browse';
103$tab['iprange']['properties'] = 'Properties';
bdd05c5d
DO
104$helptab['iprange']['default'] = 'nets';
105$helptab['iprange']['properties'] = 'nets';
e673ee24
DO
106$ophandler['iprange']['properties']['editRange'] = 'editRange';
107
108$page['ipaddress']['title'] = 'dynamic_title_ipaddress';
109$page['ipaddress']['handler'] = 'handler_ipaddress';
110$page['ipaddress']['parent'] = 'iprange';
111$page['ipaddress']['bypass'] = 'ip';
112$tab['ipaddress']['default'] = 'Browse';
113$tab['ipaddress']['properties'] = 'Properties';
114$tab['ipaddress']['assignment'] = 'Allocation';
bdd05c5d
DO
115$helptab['ipaddress']['default'] = 'nets';
116$helptab['ipaddress']['properties'] = 'nets';
117$helptab['ipaddress']['assignment'] = 'nets';
e673ee24
DO
118$ophandler['ipaddress']['properties']['editAddress'] = 'editAddress';
119$ophandler['ipaddress']['assignment']['delIpAssignment'] = 'delIpAssignment';
120$ophandler['ipaddress']['assignment']['editBondForAddress'] = 'editIpAssignment';
121$ophandler['ipaddress']['assignment']['bindObjectToIp'] = 'addIpAssignment';
122
123$page['search']['title'] = 'dynamic_title_search';
124$page['search']['handler'] = 'handler_search';
125$page['search']['parent'] = 'index';
126$page['search']['bypass'] = 'q';
127
128$page['config']['title'] = 'static_title';
129$page['config']['handler'] = 'handler_config';
130$page['config']['parent'] = 'index';
131
132$page['accounts']['title'] = 'static_title';
133$page['accounts']['handler'] = 'handler_accounts';
134$page['accounts']['parent'] = 'config';
135$tab['accounts']['default'] = 'View';
136$tab['accounts']['edit'] = 'Change';
137$ophandler['accounts']['edit']['updateAccount'] = 'updateUserAccount';
138$ophandler['accounts']['edit']['createAccount'] = 'createUserAccount';
139$ophandler['accounts']['edit']['disableAccount'] = 'disableUserAccount';
140$ophandler['accounts']['edit']['enableAccount'] = 'enableUserAccount';
141
142$page['perms']['title'] = 'static_title';
143$page['perms']['handler'] = 'handler_perms';
144$page['perms']['parent'] = 'config';
145$tab['perms']['default'] = 'View';
146$tab['perms']['edit'] = 'Change';
147$ophandler['perms']['edit']['revoke'] = 'revokePermission';
148$ophandler['perms']['edit']['grant'] = 'grantPermission';
149
150$page['portmap']['title'] = 'static_title';
151$page['portmap']['handler'] = 'handler_portmap';
152$page['portmap']['parent'] = 'config';
153$tab['portmap']['default'] = 'View';
154$tab['portmap']['edit'] = 'Change';
155$ophandler['portmap']['edit']['save'] = 'savePortMap';
156
157$page['attrs']['title'] = 'static_title';
158$page['attrs']['handler'] = 'handler_attrs';
159$page['attrs']['parent'] = 'config';
160$tab['attrs']['default'] = 'View';
161$tab['attrs']['editattrs'] = 'Edit attributes';
162$tab['attrs']['editmap'] = 'Edit map';
163$ophandler['attrs']['editattrs']['add'] = 'createAttribute';
164$ophandler['attrs']['editattrs']['upd'] = 'changeAttribute';
165$ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
166$ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
167$ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
168
169$page['dict']['title'] = 'static_title';
170$page['dict']['handler'] = 'handler_dict';
171$page['dict']['parent'] = 'config';
172$tab['dict']['default'] = 'View';
173$tab['dict']['edit'] = 'Edit words';
174$tab['dict']['chapters'] = 'Manage chapters';
175$ophandler['dict']['edit']['del'] = 'reduceDictionary';
176$ophandler['dict']['edit']['upd'] = 'updateDictionary';
177$ophandler['dict']['edit']['add'] = 'supplementDictionary';
178$ophandler['dict']['chapters']['del'] = 'delChapter';
179$ophandler['dict']['chapters']['upd'] = 'updateChapter';
180$ophandler['dict']['chapters']['add'] = 'addChapter';
181
182$page['ui']['title'] = 'static_title';
183$page['ui']['handler'] = 'handler_ui';
184$page['ui']['parent'] = 'config';
0a1b1268 185$tab['ui']['default'] = 'View';
4fe32e78
DY
186$tab['ui']['edit'] = 'Change';
187$ophandler['ui']['edit']['upd'] = 'updateUI';
e673ee24
DO
188
189$page['reports']['title'] = 'static_title';
190$page['reports']['handler'] = 'handler_reports';
191$page['reports']['parent'] = 'index';
192$tab['reports']['default'] = 'View';
193
ae545907
DO
194$page['help']['title'] = 'static_title';
195$page['help']['handler'] = 'handler_help';
196$page['help']['parent'] = 'index';
beee6141 197$tab['help']['default'] = 'Welcome';
51ef5041 198$tab['help']['quickstart'] = 'Quick start';
beee6141
DO
199$tab['help']['workflow'] = 'Workflow';
200$tab['help']['rackspace'] = 'Rackspace';
201$tab['help']['objects'] = 'Objects';
bdd05c5d 202$tab['help']['nets'] = 'Networking';
0a1b1268
DO
203$tab['help']['auth'] = '[ User accounts & permissions ]';
204$tab['help']['dict'] = '[ Dictionary ]';
beee6141 205$tab['help']['ports'] = 'Ports and links';
0a1b1268 206$tab['help']['hacking'] = '[ Hacker\'s guide ]';
ae545907 207
e673ee24
DO
208// This function returns array if page numbers leading to the target page
209// plus page number of target page itself. The first element is the target
210// page number and the last element is the index page number.
211function getPath ($targetno)
212{
213 global $page;
214 $path = array();
215 // Recursion breaks at first parentless page.
216 if (!isset ($page[$targetno]['parent']))
217 $path = array ($targetno);
218 else
219 {
220 $path = getPath ($page[$targetno]['parent']);
221 $path[] = $targetno;
222 }
223 return $path;
224}
225
226function showPathAndSearch ($pageno)
227{
9c0b0016 228 global $root, $page;
e673ee24 229 // Path.
9c0b0016 230 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise') . " RackTables";
e673ee24
DO
231 if (isset ($page[$pageno]['title']))
232 {
233 $path = getPath ($pageno);
234 foreach ($path as $dummy => $no)
235 {
236 $title = $page[$no]['title']($no);
237 echo ": <a href='${root}?page=${no}";
238 foreach ($title['params'] as $param_name => $param_value)
239 echo "&${param_name}=${param_value}";
240 echo "'>" .$title['name'] . "</a>";
241 }
242 }
243 echo "</td>";
244 // Search form.
245 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
246 echo "<form method=get action='${root}'><td>";
247 echo '<input type=hidden name=page value=search>';
248 // This input will be the first, if we don't add ports or addresses.
249 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
250}
251
252function getTitle ($pageno, $tabno)
253{
9c0b0016
DO
254 global $page;
255 if (!isset ($page[$pageno]['title']))
256 return getConfigVar ('enterprise');
257 $tmp = $page[$pageno]['title']($pageno);
258 return $tmp['name'];
e673ee24
DO
259}
260
261function showTabs ($pageno, $tabno)
262{
641fe9b0 263 global $tab, $root, $page, $remote_username, $trigger;
e673ee24
DO
264 if (!isset ($tab[$pageno]['default']))
265 return;
266 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
267 foreach ($tab[$pageno] as $tabidx => $tabtitle)
268 {
269 // Hide forbidden tabs.
270 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
271 continue;
641fe9b0
DO
272 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
273 if
274 (
275 isset ($trigger[$pageno][$tabidx]) &&
276 $trigger[$pageno][$tabidx] () != TRUE
277 )
278 continue;
e673ee24
DO
279 echo '<li><a' . (($tabidx == $tabno) ? ' class=current' : '');
280 echo " href='${root}?page=${pageno}&tab=${tabidx}";
281 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
282 {
283 $bpname = $page[$pageno]['bypass'];
284 $bpval = $_REQUEST[$bpname];
285 echo "&${bpname}=${bpval}";
286 }
287 echo "'>${tabtitle}</a></li>\n";
288 }
ae9a3784 289 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
290 echo "</ul></div></td>\n";
291}
292
293// This function returns pages, which are direct children of the requested
294// page and are accessible by the current user.
295function getDirectChildPages ($pageno)
296{
297 global $page, $remote_username;
298 $children = array();
299 foreach ($page as $cpageno => $cpage)
300 if
301 (
302 isset ($cpage['parent']) and
303 $cpage['parent'] == $pageno and
304 authorized ($remote_username, $cpageno, 'default') == TRUE
305 )
306 $children[$cpageno] = $cpage;
307 return $children;
308}
309
310function getAllChildPages ($parent)
311{
312 global $page;
313 // Array pointer is global, so if we don't create local copies of
314 // the global array, we can't advance any more after nested call
315 // of getAllChildPages returns.
316 $mypage = $page;
317 $mykids = array();
318 foreach ($mypage as $ctitle => $cpage)
319 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
320 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
321 return $mykids;
322}
323
324?>