r1553 + completed buildLBConfig() and renderLVSConfig()
[racktables] / inc / navigation.php
CommitLineData
b325120a 1<?php
e673ee24
DO
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();
81bab70c 13$tabhandler = array();
83dd1b15 14
eebf9145 15$page['index']['title'] = 'Main page';
e673ee24
DO
16$page['index']['handler'] = 'renderIndex';
17
eebf9145 18$page['rackspace']['title'] = 'Rackspace';
e673ee24
DO
19$page['rackspace']['parent'] = 'index';
20$tab['rackspace']['default'] = 'Browse';
21$tab['rackspace']['history'] = 'History';
9b0cf84f
DO
22$tab['rackspace']['firstrow'] = 'Click me!';
23$trigger['rackspace']['firstrow'] = 'trigger_emptyRackspace';
8b6ffe9c
DO
24$tabhandler['rackspace']['default'] = 'renderRackspace';
25$tabhandler['rackspace']['history'] = 'renderRackspaceHistory';
26$tabhandler['rackspace']['firstrow'] = 'renderFirstRowForm';
e673ee24 27
eebf9145 28$page['objects']['title'] = 'Objects';
e673ee24
DO
29$page['objects']['parent'] = 'index';
30$tab['objects']['default'] = 'View';
31$tab['objects']['newobj'] = 'Add an object';
32$tab['objects']['newmulti'] = 'Add multiple objects';
8b6ffe9c
DO
33$tabhandler['objects']['default'] = 'renderObjectGroupSummary';
34$tabhandler['objects']['newobj'] = 'renderNewObjectForm';
35$tabhandler['objects']['newmulti'] = 'renderAddMultipleObjectsForm';
e673ee24 36
eebf9145 37$page['row']['title_handler'] = 'dynamic_title_row';
e673ee24 38$page['row']['bypass'] = 'row_id';
8b6ffe9c 39$page['row']['bypass_type'] = 'uint';
e673ee24
DO
40$page['row']['parent'] = 'rackspace';
41$tab['row']['default'] = 'View';
42$tab['row']['newrack'] = 'Add new rack';
8b6ffe9c
DO
43$tabhandler['row']['default'] = 'renderRow';
44$tabhandler['row']['newrack'] = 'renderNewRackForm';
e673ee24 45
eebf9145 46$page['rack']['title_handler'] = 'dynamic_title_rack';
e673ee24 47$page['rack']['bypass'] = 'rack_id';
8b6ffe9c 48$page['rack']['bypass_type'] = 'uint';
e673ee24
DO
49$page['rack']['parent'] = 'row';
50$tab['rack']['default'] = 'View';
51$tab['rack']['edit'] = 'Properties';
52$tab['rack']['design'] = 'Design';
53$tab['rack']['problems'] = 'Problems';
8b6ffe9c
DO
54$tabhandler['rack']['default'] = 'renderRackPage';
55$tabhandler['rack']['edit'] = 'renderEditRackForm';
56$tabhandler['rack']['design'] = 'renderRackDesign';
57$tabhandler['rack']['problems'] = 'renderRackProblems';
beee6141
DO
58$helptab['rack']['design'] = 'rackspace';
59$helptab['rack']['problems'] = 'rackspace';
e673ee24 60
eebf9145 61$page['objgroup']['title_handler'] = 'dynamic_title_objgroup';
e673ee24
DO
62$page['objgroup']['handler'] = 'handler_objgroup';
63$page['objgroup']['bypass'] = 'group_id';
64$page['objgroup']['parent'] = 'objects';
65
eebf9145 66$page['object']['title_handler'] = 'dynamic_title_object';
e673ee24 67$page['object']['bypass'] = 'object_id';
3bebaebd 68$page['object']['bypass_type'] = 'uint';
e673ee24
DO
69$page['object']['parent'] = 'objgroup';
70$tab['object']['default'] = 'View';
71$tab['object']['edit'] = 'Properties';
72$tab['object']['rackspace'] = 'Rackspace';
73$tab['object']['ports'] = 'Ports';
74$tab['object']['network'] = 'IPv4';
737f9ac1 75$tab['object']['portfwrd'] = 'NATv4';
a684aa6f 76$tab['object']['switchvlans'] = 'Live VLANs';
9c67f713 77$tab['object']['snmpportfinder'] = 'SNMP port finder';
3ee1252b 78$tab['object']['lvsconfig'] = 'LVS configuration';
e45a78d7
DO
79$tabhandler['object']['default'] = 'renderRackObject';
80$tabhandler['object']['edit'] = 'renderEditObjectForm';
81$tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
82$tabhandler['object']['ports'] = 'renderPortsForObject';
83$tabhandler['object']['network'] = 'renderNetworkForObject';
84$tabhandler['object']['portfwrd'] = 'renderIPAddressPortForwarding';
85$tabhandler['object']['switchvlans'] = 'renderVLANMembership';
86$tabhandler['object']['snmpportfinder'] = 'renderSNMPPortFinder';
3ee1252b 87$tabhandler['object']['lvsconfig'] = 'renderLVSConfig';
bdd05c5d 88$helptab['object']['network'] = 'nets';
150fdd66 89$helptab['object']['ports'] = 'ports';
bdd05c5d
DO
90$helptab['object']['portfwrd'] = 'nets';
91$helptab['object']['rackspace'] = 'rackspace';
6dbdc7c7
DO
92$trigger['object']['network'] = 'trigger_ipv4';
93$trigger['object']['portfwrd'] = 'trigger_natv4';
641fe9b0 94$trigger['object']['switchvlans'] = 'trigger_switchvlans';
9c67f713 95$trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
094bb33c 96$trigger['object']['lvsconfig'] = 'trigger_lvsconfig';
e673ee24
DO
97$ophandler['object']['ports']['addPort'] = 'addPortForObject';
98$ophandler['object']['ports']['delPort'] = 'delPortFromObject';
99$ophandler['object']['ports']['editPort'] = 'editPortForObject';
100$ophandler['object']['ports']['linkPort'] = 'linkPortForObject';
101$ophandler['object']['ports']['unlinkPort'] = 'unlinkPortForObject';
102$ophandler['object']['ports']['addMultiPorts'] = 'addMultiPorts';
103$ophandler['object']['ports']['useup'] = 'useupPort';
104$ophandler['object']['network']['editAddressFromObject'] = 'editAddressFromObject';
105$ophandler['object']['network']['addAddrFObj'] = 'addAddressToObject';
106$ophandler['object']['network']['delAddrFObj'] = 'delAddressFromObject';
107$ophandler['object']['edit']['del'] = 'resetAttrValue';
0dfb8a2a 108$ophandler['object']['edit']['upd'] = 'updateAttrValues';
e673ee24
DO
109$ophandler['object']['portfwrd']['forwardPorts'] = 'addPortForwarding';
110$ophandler['object']['portfwrd']['delPortForwarding'] = 'delPortForwarding';
111$ophandler['object']['portfwrd']['updPortForwarding'] = 'updPortForwarding';
641fe9b0 112$ophandler['object']['switchvlans']['submit'] = 'updateVLANMembership';
e673ee24 113
eebf9145 114$page['ipv4space']['title'] = 'IPv4 space';
e673ee24
DO
115$page['ipv4space']['parent'] = 'index';
116$tab['ipv4space']['default'] = 'Browse';
a7fe7729 117$tab['ipv4space']['newrange'] = 'Subnets';
bdd05c5d
DO
118$helptab['ipv4space']['default'] = 'nets';
119$helptab['ipv4space']['newrange'] = 'nets';
8b6ffe9c
DO
120$tabhandler['ipv4space']['default'] = 'renderAddressspace';
121$tabhandler['ipv4space']['newrange'] = 'renderAddNewRange';
e673ee24
DO
122$ophandler['ipv4space']['newrange']['addRange'] = 'addNewrange';
123$ophandler['ipv4space']['newrange']['delRange'] = 'delRange';
124
eebf9145 125$page['iprange']['title_handler'] = 'dynamic_title_iprange';
e673ee24
DO
126$page['iprange']['parent'] = 'ipv4space';
127$page['iprange']['bypass'] = 'id';
128$tab['iprange']['default'] = 'Browse';
129$tab['iprange']['properties'] = 'Properties';
bdd05c5d
DO
130$helptab['iprange']['default'] = 'nets';
131$helptab['iprange']['properties'] = 'nets';
8b6ffe9c
DO
132$tabhandler['iprange']['default'] = 'renderIPRange';
133$tabhandler['iprange']['properties'] = 'renderIPRangeProperties';
e673ee24
DO
134$ophandler['iprange']['properties']['editRange'] = 'editRange';
135
eebf9145 136$page['ipaddress']['title_handler'] = 'dynamic_title_ipaddress';
e673ee24
DO
137$page['ipaddress']['parent'] = 'iprange';
138$page['ipaddress']['bypass'] = 'ip';
139$tab['ipaddress']['default'] = 'Browse';
140$tab['ipaddress']['properties'] = 'Properties';
141$tab['ipaddress']['assignment'] = 'Allocation';
bdd05c5d
DO
142$helptab['ipaddress']['default'] = 'nets';
143$helptab['ipaddress']['properties'] = 'nets';
144$helptab['ipaddress']['assignment'] = 'nets';
8b6ffe9c
DO
145$tabhandler['ipaddress']['default'] = 'renderIPAddress';
146$tabhandler['ipaddress']['properties'] = 'renderIPAddressProperties';
147$tabhandler['ipaddress']['assignment'] = 'renderIPAddressAssignment';
e673ee24
DO
148$ophandler['ipaddress']['properties']['editAddress'] = 'editAddress';
149$ophandler['ipaddress']['assignment']['delIpAssignment'] = 'delIpAssignment';
150$ophandler['ipaddress']['assignment']['editBondForAddress'] = 'editIpAssignment';
151$ophandler['ipaddress']['assignment']['bindObjectToIp'] = 'addIpAssignment';
152
b3c50e6c
DO
153$page['vservices']['title'] = 'Virtual services';
154$page['vservices']['parent'] = 'ipv4space';
e57dca7f 155$tab['vservices']['default'] = 'View';
1183c73f 156$tab['vservices']['edit'] = 'Edit';
e57dca7f 157$tabhandler['vservices']['default'] = 'renderVSList';
1183c73f
DO
158$tabhandler['vservices']['edit'] = 'renderVSListEditForm';
159$ophandler['vservices']['edit']['add'] = 'addVService';
160$ophandler['vservices']['edit']['del'] = 'deleteVService';
161$ophandler['vservices']['edit']['upd'] = 'updateVService';
b3c50e6c 162
eebf9145 163$page['vservice']['title_handler'] = 'dynamic_title_vservice';
b3c50e6c 164$page['vservice']['parent'] = 'vservices';
c9b4588f
DO
165$page['vservice']['bypass'] = 'id';
166$page['vservice']['bypass_type'] = 'uint';
83be0198 167$page['vservice']['handler'] = 'renderVirtualService';
c9b4588f 168
9a81d416 169$page['rspools']['title'] = 'RS pools';
b3c50e6c 170$page['rspools']['parent'] = 'ipv4space';
9a81d416 171$tab['rspools']['default'] = 'View';
5ad76f01 172$tab['rspools']['edit'] = 'Edit';
9a81d416 173$tabhandler['rspools']['default'] = 'renderRSPoolList';
5ad76f01
DO
174$tabhandler['rspools']['edit'] = 'editRSPools';
175$ophandler['rspools']['edit']['add'] = 'addRSPool';
176$ophandler['rspools']['edit']['del'] = 'deleteRSPool';
177$ophandler['rspools']['edit']['upd'] = 'updateRSPool';
b3c50e6c 178
30aaee5a 179$page['rspool']['title_handler'] = 'dynamic_title_rspool';
b3c50e6c 180$page['rspool']['parent'] = 'rspools';
71b8bda1
DO
181$page['rspool']['bypass'] = 'id';
182$page['rspool']['bypass_type'] = 'uint';
183$tab['rspool']['default'] = 'View';
ca461127 184$tab['rspool']['editrslist'] = 'Real Servers';
3241551e 185$tab['rspool']['editlblist'] = 'Load Balancers';
71b8bda1 186$tabhandler['rspool']['default'] = 'renderRSPool';
ca461127 187$tabhandler['rspool']['editrslist'] = 'renderRSPoolServerForm';
3241551e 188$tabhandler['rspool']['editlblist'] = 'renderRSPoolLBForm';
ca461127 189$ophandler['rspool']['editrslist']['addRS'] = 'addRealServer';
fb1c4a54
DO
190$ophandler['rspool']['editrslist']['delRS'] = 'deleteRealServer';
191$ophandler['rspool']['editrslist']['updRS'] = 'updateRealServer';
3241551e
DO
192$ophandler['rspool']['editlblist']['addLB'] = 'addLoadBalancer';
193$ophandler['rspool']['editlblist']['delLB'] = 'deleteLoadBalancer';
194$ophandler['rspool']['editlblist']['updLB'] = 'updateLoadBalancer';
71b8bda1 195
8253d9f0 196$page['rservers']['title'] = 'Real servers';
b3c50e6c 197$page['rservers']['parent'] = 'ipv4space';
8253d9f0 198$page['rservers']['handler'] = 'renderRealServerList';
b3c50e6c 199
4b0932b6 200$page['lbs']['title'] = 'Load balancers';
b3c50e6c 201$page['lbs']['parent'] = 'ipv4space';
4b0932b6 202$page['lbs']['handler'] = 'renderLBList';
b3c50e6c 203
eebf9145 204$page['search']['title_handler'] = 'dynamic_title_search';
e673ee24
DO
205$page['search']['handler'] = 'handler_search';
206$page['search']['parent'] = 'index';
207$page['search']['bypass'] = 'q';
208
eebf9145 209$page['config']['title'] = 'Configuration';
e673ee24
DO
210$page['config']['handler'] = 'handler_config';
211$page['config']['parent'] = 'index';
212
eebf9145 213$page['accounts']['title'] = 'Accounts';
e673ee24
DO
214$page['accounts']['parent'] = 'config';
215$tab['accounts']['default'] = 'View';
216$tab['accounts']['edit'] = 'Change';
8b6ffe9c
DO
217$tabhandler['accounts']['default'] = 'renderAccounts';
218$tabhandler['accounts']['edit'] = 'renderAccountsEditForm';
e673ee24
DO
219$ophandler['accounts']['edit']['updateAccount'] = 'updateUserAccount';
220$ophandler['accounts']['edit']['createAccount'] = 'createUserAccount';
221$ophandler['accounts']['edit']['disableAccount'] = 'disableUserAccount';
222$ophandler['accounts']['edit']['enableAccount'] = 'enableUserAccount';
223
eebf9145 224$page['perms']['title'] = 'Permissions';
e673ee24
DO
225$page['perms']['parent'] = 'config';
226$tab['perms']['default'] = 'View';
227$tab['perms']['edit'] = 'Change';
8b6ffe9c
DO
228$tabhandler['perms']['default'] = 'renderPermissions';
229$tabhandler['perms']['edit'] = 'renderPermissionsEditForm';
e673ee24
DO
230$ophandler['perms']['edit']['revoke'] = 'revokePermission';
231$ophandler['perms']['edit']['grant'] = 'grantPermission';
232
eebf9145 233$page['portmap']['title'] = 'Port compatibility map';
e673ee24
DO
234$page['portmap']['handler'] = 'handler_portmap';
235$page['portmap']['parent'] = 'config';
236$tab['portmap']['default'] = 'View';
237$tab['portmap']['edit'] = 'Change';
238$ophandler['portmap']['edit']['save'] = 'savePortMap';
239
eebf9145 240$page['attrs']['title'] = 'Attributes';
e673ee24
DO
241$page['attrs']['parent'] = 'config';
242$tab['attrs']['default'] = 'View';
243$tab['attrs']['editattrs'] = 'Edit attributes';
244$tab['attrs']['editmap'] = 'Edit map';
8b6ffe9c
DO
245$tabhandler['attrs']['default'] = 'renderAttributes';
246$tabhandler['attrs']['editattrs'] = 'renderEditAttributesForm';
247$tabhandler['attrs']['editmap'] = 'renderEditAttrMapForm';
e673ee24
DO
248$ophandler['attrs']['editattrs']['add'] = 'createAttribute';
249$ophandler['attrs']['editattrs']['upd'] = 'changeAttribute';
250$ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
251$ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
252$ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
253
eebf9145 254$page['dict']['title'] = 'Dictionary';
e673ee24
DO
255$page['dict']['parent'] = 'config';
256$tab['dict']['default'] = 'View';
257$tab['dict']['edit'] = 'Edit words';
258$tab['dict']['chapters'] = 'Manage chapters';
8b6ffe9c
DO
259$tabhandler['dict']['default'] = 'renderDictionary';
260$tabhandler['dict']['edit'] = 'renderDictionaryEditor';
261$tabhandler['dict']['chapters'] = 'renderChaptersEditor';
e673ee24
DO
262$ophandler['dict']['edit']['del'] = 'reduceDictionary';
263$ophandler['dict']['edit']['upd'] = 'updateDictionary';
264$ophandler['dict']['edit']['add'] = 'supplementDictionary';
265$ophandler['dict']['chapters']['del'] = 'delChapter';
266$ophandler['dict']['chapters']['upd'] = 'updateChapter';
267$ophandler['dict']['chapters']['add'] = 'addChapter';
268
eebf9145 269$page['ui']['title'] = 'User interface';
e673ee24 270$page['ui']['parent'] = 'config';
0a1b1268 271$tab['ui']['default'] = 'View';
4fe32e78 272$tab['ui']['edit'] = 'Change';
b07f617c 273$tab['ui']['reset'] = 'Reset';
8b6ffe9c
DO
274$tabhandler['ui']['default'] = 'renderUIConfig';
275$tabhandler['ui']['edit'] = 'renderUIConfigEditForm';
276$tabhandler['ui']['reset'] = 'renderUIResetForm';
4fe32e78 277$ophandler['ui']['edit']['upd'] = 'updateUI';
b07f617c 278$ophandler['ui']['reset']['go'] = 'resetUIConfig';
e673ee24 279
eebf9145 280$page['reports']['title'] = 'Reports';
e673ee24
DO
281$page['reports']['parent'] = 'index';
282$tab['reports']['default'] = 'View';
8b6ffe9c 283$tabhandler['reports']['default'] = 'renderReportSummary';
e673ee24 284
eebf9145 285$page['help']['title'] = 'Help';
8b6ffe9c 286$page['help']['handler'] = 'renderHelpTab';
ae545907 287$page['help']['parent'] = 'index';
beee6141 288$tab['help']['default'] = 'Welcome';
51ef5041 289$tab['help']['quickstart'] = 'Quick start';
beee6141
DO
290$tab['help']['workflow'] = 'Workflow';
291$tab['help']['rackspace'] = 'Rackspace';
292$tab['help']['objects'] = 'Objects';
bdd05c5d 293$tab['help']['nets'] = 'Networking';
0a1b1268
DO
294$tab['help']['auth'] = '[ User accounts & permissions ]';
295$tab['help']['dict'] = '[ Dictionary ]';
beee6141 296$tab['help']['ports'] = 'Ports and links';
0a1b1268 297$tab['help']['hacking'] = '[ Hacker\'s guide ]';
ae545907 298
e673ee24
DO
299// This function returns array if page numbers leading to the target page
300// plus page number of target page itself. The first element is the target
301// page number and the last element is the index page number.
302function getPath ($targetno)
303{
304 global $page;
305 $path = array();
306 // Recursion breaks at first parentless page.
307 if (!isset ($page[$targetno]['parent']))
308 $path = array ($targetno);
309 else
310 {
311 $path = getPath ($page[$targetno]['parent']);
312 $path[] = $targetno;
313 }
314 return $path;
315}
316
317function showPathAndSearch ($pageno)
318{
9c0b0016 319 global $root, $page;
e673ee24 320 // Path.
73635d32 321 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
eebf9145
DO
322 $path = getPath ($pageno);
323 foreach ($path as $no)
e673ee24 324 {
eebf9145
DO
325 $title['params'] = array();
326 if (isset ($page[$no]['title']))
327 $title['name'] = $page[$no]['title'];
328 elseif (isset ($page[$no]['title_handler']))
329 $title = $page[$no]['title_handler']($no);
330 else
331 $title['name'] = '[N/A]';
332 echo ": <a href='${root}?page=${no}";
333 foreach ($title['params'] as $param_name => $param_value)
334 echo "&${param_name}=${param_value}";
335 echo "'>" . $title['name'] . "</a>";
e673ee24
DO
336 }
337 echo "</td>";
338 // Search form.
339 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
340 echo "<form method=get action='${root}'><td>";
341 echo '<input type=hidden name=page value=search>';
342 // This input will be the first, if we don't add ports or addresses.
343 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
344}
345
346function getTitle ($pageno, $tabno)
347{
9c0b0016 348 global $page;
eebf9145
DO
349 if (isset ($page[$pageno]['title']))
350 return $page[$pageno]['title'];
351 elseif (isset ($page[$pageno]['title_handler']))
352 {
353 $tmp = $page[$pageno]['title_handler']($pageno);
354 return $tmp['name'];
355 }
356 else
9c0b0016 357 return getConfigVar ('enterprise');
e673ee24
DO
358}
359
360function showTabs ($pageno, $tabno)
361{
641fe9b0 362 global $tab, $root, $page, $remote_username, $trigger;
e673ee24
DO
363 if (!isset ($tab[$pageno]['default']))
364 return;
365 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
366 foreach ($tab[$pageno] as $tabidx => $tabtitle)
367 {
368 // Hide forbidden tabs.
369 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
370 continue;
641fe9b0
DO
371 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
372 if
373 (
374 isset ($trigger[$pageno][$tabidx]) &&
375 $trigger[$pageno][$tabidx] () != TRUE
376 )
377 continue;
e673ee24
DO
378 echo '<li><a' . (($tabidx == $tabno) ? ' class=current' : '');
379 echo " href='${root}?page=${pageno}&tab=${tabidx}";
380 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
381 {
382 $bpname = $page[$pageno]['bypass'];
383 $bpval = $_REQUEST[$bpname];
384 echo "&${bpname}=${bpval}";
385 }
386 echo "'>${tabtitle}</a></li>\n";
387 }
ae9a3784 388 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
389 echo "</ul></div></td>\n";
390}
391
392// This function returns pages, which are direct children of the requested
393// page and are accessible by the current user.
394function getDirectChildPages ($pageno)
395{
396 global $page, $remote_username;
397 $children = array();
398 foreach ($page as $cpageno => $cpage)
399 if
400 (
401 isset ($cpage['parent']) and
402 $cpage['parent'] == $pageno and
403 authorized ($remote_username, $cpageno, 'default') == TRUE
404 )
405 $children[$cpageno] = $cpage;
406 return $children;
407}
408
409function getAllChildPages ($parent)
410{
411 global $page;
412 // Array pointer is global, so if we don't create local copies of
413 // the global array, we can't advance any more after nested call
414 // of getAllChildPages returns.
415 $mypage = $page;
416 $mykids = array();
417 foreach ($mypage as $ctitle => $cpage)
418 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
419 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
420 return $mykids;
421}
422
423?>