r1724 + generateAutoPorts(): welcome new ophandler
[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';
e673ee24 58
eebf9145 59$page['objgroup']['title_handler'] = 'dynamic_title_objgroup';
3aeb15f3 60$page['objgroup']['handler'] = 'renderObjectGroup';
e673ee24 61$page['objgroup']['bypass'] = 'group_id';
3aeb15f3 62$page['objgroup']['bypass_type'] = 'uint';
e673ee24
DO
63$page['objgroup']['parent'] = 'objects';
64
eebf9145 65$page['object']['title_handler'] = 'dynamic_title_object';
e673ee24 66$page['object']['bypass'] = 'object_id';
3bebaebd 67$page['object']['bypass_type'] = 'uint';
e673ee24
DO
68$page['object']['parent'] = 'objgroup';
69$tab['object']['default'] = 'View';
70$tab['object']['edit'] = 'Properties';
71$tab['object']['rackspace'] = 'Rackspace';
72$tab['object']['ports'] = 'Ports';
73$tab['object']['network'] = 'IPv4';
737f9ac1 74$tab['object']['portfwrd'] = 'NATv4';
a684aa6f 75$tab['object']['switchvlans'] = 'Live VLANs';
9c67f713 76$tab['object']['snmpportfinder'] = 'SNMP port finder';
7e13adfe 77$tab['object']['slb'] = '[SLB]';
3ee1252b 78$tab['object']['lvsconfig'] = 'LVS configuration';
118e4c38 79$tab['object']['autoports'] = 'AutoPorts';
e45a78d7
DO
80$tabhandler['object']['default'] = 'renderRackObject';
81$tabhandler['object']['edit'] = 'renderEditObjectForm';
82$tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
83$tabhandler['object']['ports'] = 'renderPortsForObject';
84$tabhandler['object']['network'] = 'renderNetworkForObject';
85$tabhandler['object']['portfwrd'] = 'renderIPAddressPortForwarding';
86$tabhandler['object']['switchvlans'] = 'renderVLANMembership';
87$tabhandler['object']['snmpportfinder'] = 'renderSNMPPortFinder';
3ee1252b 88$tabhandler['object']['lvsconfig'] = 'renderLVSConfig';
118e4c38 89$tabhandler['object']['autoports'] = 'renderAutoPortsForm';
6dbdc7c7
DO
90$trigger['object']['network'] = 'trigger_ipv4';
91$trigger['object']['portfwrd'] = 'trigger_natv4';
641fe9b0 92$trigger['object']['switchvlans'] = 'trigger_switchvlans';
9c67f713 93$trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
7e13adfe 94$trigger['object']['slb'] = 'trigger_natv4';
094bb33c 95$trigger['object']['lvsconfig'] = 'trigger_lvsconfig';
118e4c38 96$trigger['object']['autoports'] = 'trigger_autoports';
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';
f3f0161f 112$ophandler['object']['autoports']['generate'] = 'generateAutoPorts';
e673ee24 113
eebf9145 114$page['ipv4space']['title'] = 'IPv4 space';
e673ee24
DO
115$page['ipv4space']['parent'] = 'index';
116$tab['ipv4space']['default'] = 'Browse';
0bcdc163 117$tab['ipv4space']['newrange'] = 'Manage';
8b6ffe9c
DO
118$tabhandler['ipv4space']['default'] = 'renderAddressspace';
119$tabhandler['ipv4space']['newrange'] = 'renderAddNewRange';
e673ee24
DO
120$ophandler['ipv4space']['newrange']['addRange'] = 'addNewrange';
121$ophandler['ipv4space']['newrange']['delRange'] = 'delRange';
122
eebf9145 123$page['iprange']['title_handler'] = 'dynamic_title_iprange';
e673ee24
DO
124$page['iprange']['parent'] = 'ipv4space';
125$page['iprange']['bypass'] = 'id';
2fe5476a 126$page['iprange']['bypass_type'] = 'uint';
e673ee24
DO
127$tab['iprange']['default'] = 'Browse';
128$tab['iprange']['properties'] = 'Properties';
2fe5476a 129$tab['iprange']['liveptr'] = 'Live PTR';
8b6ffe9c
DO
130$tabhandler['iprange']['default'] = 'renderIPRange';
131$tabhandler['iprange']['properties'] = 'renderIPRangeProperties';
2fe5476a 132$tabhandler['iprange']['liveptr'] = 'renderLivePTR';
e673ee24 133$ophandler['iprange']['properties']['editRange'] = 'editRange';
3f3bd41e 134$ophandler['iprange']['liveptr']['import'] = 'importPTRData';
e673ee24 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';
7e13adfe 142$tab['ipaddress']['editrslist'] = '[SLB real servers]';
8b6ffe9c
DO
143$tabhandler['ipaddress']['default'] = 'renderIPAddress';
144$tabhandler['ipaddress']['properties'] = 'renderIPAddressProperties';
145$tabhandler['ipaddress']['assignment'] = 'renderIPAddressAssignment';
e673ee24
DO
146$ophandler['ipaddress']['properties']['editAddress'] = 'editAddress';
147$ophandler['ipaddress']['assignment']['delIpAssignment'] = 'delIpAssignment';
148$ophandler['ipaddress']['assignment']['editBondForAddress'] = 'editIpAssignment';
149$ophandler['ipaddress']['assignment']['bindObjectToIp'] = 'addIpAssignment';
150
f973f491
DO
151$page['ipv4slb']['title'] = 'IPv4 SLB';
152$page['ipv4slb']['parent'] = 'index';
153$page['ipv4slb']['handler'] = 'renderIPv4SLB';
154
b3c50e6c 155$page['vservices']['title'] = 'Virtual services';
f973f491 156$page['vservices']['parent'] = 'ipv4slb';
e57dca7f 157$tab['vservices']['default'] = 'View';
1183c73f 158$tab['vservices']['edit'] = 'Edit';
e57dca7f 159$tabhandler['vservices']['default'] = 'renderVSList';
1183c73f
DO
160$tabhandler['vservices']['edit'] = 'renderVSListEditForm';
161$ophandler['vservices']['edit']['add'] = 'addVService';
162$ophandler['vservices']['edit']['del'] = 'deleteVService';
163$ophandler['vservices']['edit']['upd'] = 'updateVService';
b3c50e6c 164
eebf9145 165$page['vservice']['title_handler'] = 'dynamic_title_vservice';
b3c50e6c 166$page['vservice']['parent'] = 'vservices';
c9b4588f
DO
167$page['vservice']['bypass'] = 'id';
168$page['vservice']['bypass_type'] = 'uint';
3bab7445
DO
169$tab['vservice']['default'] = 'View';
170$tab['vservice']['edit'] = '[Edit]';
7e13adfe 171$tab['vservice']['editlblist'] = '[Load balancers]';
0bcdc163 172$tabhandler['vservice']['default'] = 'renderVirtualService';
c9b4588f 173
9a81d416 174$page['rspools']['title'] = 'RS pools';
f973f491 175$page['rspools']['parent'] = 'ipv4slb';
9a81d416 176$tab['rspools']['default'] = 'View';
5ad76f01 177$tab['rspools']['edit'] = 'Edit';
9a81d416 178$tabhandler['rspools']['default'] = 'renderRSPoolList';
5ad76f01
DO
179$tabhandler['rspools']['edit'] = 'editRSPools';
180$ophandler['rspools']['edit']['add'] = 'addRSPool';
181$ophandler['rspools']['edit']['del'] = 'deleteRSPool';
182$ophandler['rspools']['edit']['upd'] = 'updateRSPool';
b3c50e6c 183
30aaee5a 184$page['rspool']['title_handler'] = 'dynamic_title_rspool';
b3c50e6c 185$page['rspool']['parent'] = 'rspools';
71b8bda1
DO
186$page['rspool']['bypass'] = 'id';
187$page['rspool']['bypass_type'] = 'uint';
188$tab['rspool']['default'] = 'View';
0bcdc163 189$tab['rspool']['edit'] = '[Edit]';
3241551e 190$tab['rspool']['editlblist'] = 'Load Balancers';
1f7d18fa
DO
191$tab['rspool']['editrslist'] = 'RS list';
192$tab['rspool']['rsinservice'] = 'RS in service';
a785988f 193$trigger['rspool']['rsinservice'] = 'trigger_poolrscount';
71b8bda1 194$tabhandler['rspool']['default'] = 'renderRSPool';
ca461127 195$tabhandler['rspool']['editrslist'] = 'renderRSPoolServerForm';
3241551e 196$tabhandler['rspool']['editlblist'] = 'renderRSPoolLBForm';
1f7d18fa 197$tabhandler['rspool']['rsinservice'] = 'renderRSPoolRSInServiceForm';
ca461127 198$ophandler['rspool']['editrslist']['addRS'] = 'addRealServer';
fb1c4a54
DO
199$ophandler['rspool']['editrslist']['delRS'] = 'deleteRealServer';
200$ophandler['rspool']['editrslist']['updRS'] = 'updateRealServer';
732e4578 201$ophandler['rspool']['editrslist']['addMany'] = 'addRealServers';
3241551e
DO
202$ophandler['rspool']['editlblist']['addLB'] = 'addLoadBalancer';
203$ophandler['rspool']['editlblist']['delLB'] = 'deleteLoadBalancer';
204$ophandler['rspool']['editlblist']['updLB'] = 'updateLoadBalancer';
1f7d18fa 205$ophandler['rspool']['rsinservice']['upd'] = 'updateRSInService';
71b8bda1 206
8253d9f0 207$page['rservers']['title'] = 'Real servers';
f973f491 208$page['rservers']['parent'] = 'ipv4slb';
8253d9f0 209$page['rservers']['handler'] = 'renderRealServerList';
b3c50e6c 210
4b0932b6 211$page['lbs']['title'] = 'Load balancers';
f973f491 212$page['lbs']['parent'] = 'ipv4slb';
4b0932b6 213$page['lbs']['handler'] = 'renderLBList';
b3c50e6c 214
eebf9145 215$page['search']['title_handler'] = 'dynamic_title_search';
3aeb15f3 216$page['search']['handler'] = 'renderSearchResults';
e673ee24
DO
217$page['search']['parent'] = 'index';
218$page['search']['bypass'] = 'q';
219
eebf9145 220$page['config']['title'] = 'Configuration';
3aeb15f3 221$page['config']['handler'] = 'renderConfigMainpage';
e673ee24
DO
222$page['config']['parent'] = 'index';
223
eebf9145 224$page['accounts']['title'] = 'Accounts';
e673ee24
DO
225$page['accounts']['parent'] = 'config';
226$tab['accounts']['default'] = 'View';
227$tab['accounts']['edit'] = 'Change';
8b6ffe9c
DO
228$tabhandler['accounts']['default'] = 'renderAccounts';
229$tabhandler['accounts']['edit'] = 'renderAccountsEditForm';
e673ee24
DO
230$ophandler['accounts']['edit']['updateAccount'] = 'updateUserAccount';
231$ophandler['accounts']['edit']['createAccount'] = 'createUserAccount';
232$ophandler['accounts']['edit']['disableAccount'] = 'disableUserAccount';
233$ophandler['accounts']['edit']['enableAccount'] = 'enableUserAccount';
234
eebf9145 235$page['perms']['title'] = 'Permissions';
e673ee24
DO
236$page['perms']['parent'] = 'config';
237$tab['perms']['default'] = 'View';
238$tab['perms']['edit'] = 'Change';
8b6ffe9c
DO
239$tabhandler['perms']['default'] = 'renderPermissions';
240$tabhandler['perms']['edit'] = 'renderPermissionsEditForm';
e673ee24
DO
241$ophandler['perms']['edit']['revoke'] = 'revokePermission';
242$ophandler['perms']['edit']['grant'] = 'grantPermission';
243
eebf9145 244$page['portmap']['title'] = 'Port compatibility map';
e673ee24
DO
245$page['portmap']['handler'] = 'handler_portmap';
246$page['portmap']['parent'] = 'config';
247$tab['portmap']['default'] = 'View';
248$tab['portmap']['edit'] = 'Change';
249$ophandler['portmap']['edit']['save'] = 'savePortMap';
250
eebf9145 251$page['attrs']['title'] = 'Attributes';
e673ee24
DO
252$page['attrs']['parent'] = 'config';
253$tab['attrs']['default'] = 'View';
254$tab['attrs']['editattrs'] = 'Edit attributes';
255$tab['attrs']['editmap'] = 'Edit map';
8b6ffe9c
DO
256$tabhandler['attrs']['default'] = 'renderAttributes';
257$tabhandler['attrs']['editattrs'] = 'renderEditAttributesForm';
258$tabhandler['attrs']['editmap'] = 'renderEditAttrMapForm';
e673ee24
DO
259$ophandler['attrs']['editattrs']['add'] = 'createAttribute';
260$ophandler['attrs']['editattrs']['upd'] = 'changeAttribute';
261$ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
262$ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
263$ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
264
eebf9145 265$page['dict']['title'] = 'Dictionary';
e673ee24
DO
266$page['dict']['parent'] = 'config';
267$tab['dict']['default'] = 'View';
268$tab['dict']['edit'] = 'Edit words';
269$tab['dict']['chapters'] = 'Manage chapters';
8b6ffe9c
DO
270$tabhandler['dict']['default'] = 'renderDictionary';
271$tabhandler['dict']['edit'] = 'renderDictionaryEditor';
272$tabhandler['dict']['chapters'] = 'renderChaptersEditor';
e673ee24
DO
273$ophandler['dict']['edit']['del'] = 'reduceDictionary';
274$ophandler['dict']['edit']['upd'] = 'updateDictionary';
275$ophandler['dict']['edit']['add'] = 'supplementDictionary';
276$ophandler['dict']['chapters']['del'] = 'delChapter';
277$ophandler['dict']['chapters']['upd'] = 'updateChapter';
278$ophandler['dict']['chapters']['add'] = 'addChapter';
279
eebf9145 280$page['ui']['title'] = 'User interface';
e673ee24 281$page['ui']['parent'] = 'config';
0a1b1268 282$tab['ui']['default'] = 'View';
4fe32e78 283$tab['ui']['edit'] = 'Change';
b07f617c 284$tab['ui']['reset'] = 'Reset';
8b6ffe9c
DO
285$tabhandler['ui']['default'] = 'renderUIConfig';
286$tabhandler['ui']['edit'] = 'renderUIConfigEditForm';
287$tabhandler['ui']['reset'] = 'renderUIResetForm';
4fe32e78 288$ophandler['ui']['edit']['upd'] = 'updateUI';
b07f617c 289$ophandler['ui']['reset']['go'] = 'resetUIConfig';
e673ee24 290
eebf9145 291$page['reports']['title'] = 'Reports';
e673ee24
DO
292$page['reports']['parent'] = 'index';
293$tab['reports']['default'] = 'View';
8b6ffe9c 294$tabhandler['reports']['default'] = 'renderReportSummary';
e673ee24 295
eebf9145 296$page['help']['title'] = 'Help';
8b6ffe9c 297$page['help']['handler'] = 'renderHelpTab';
ae545907 298$page['help']['parent'] = 'index';
ae545907 299
e673ee24
DO
300// This function returns array if page numbers leading to the target page
301// plus page number of target page itself. The first element is the target
302// page number and the last element is the index page number.
303function getPath ($targetno)
304{
305 global $page;
306 $path = array();
307 // Recursion breaks at first parentless page.
308 if (!isset ($page[$targetno]['parent']))
309 $path = array ($targetno);
310 else
311 {
312 $path = getPath ($page[$targetno]['parent']);
313 $path[] = $targetno;
314 }
315 return $path;
316}
317
318function showPathAndSearch ($pageno)
319{
9c0b0016 320 global $root, $page;
e673ee24 321 // Path.
73635d32 322 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
eebf9145
DO
323 $path = getPath ($pageno);
324 foreach ($path as $no)
e673ee24 325 {
eebf9145
DO
326 $title['params'] = array();
327 if (isset ($page[$no]['title']))
328 $title['name'] = $page[$no]['title'];
329 elseif (isset ($page[$no]['title_handler']))
330 $title = $page[$no]['title_handler']($no);
331 else
332 $title['name'] = '[N/A]';
333 echo ": <a href='${root}?page=${no}";
334 foreach ($title['params'] as $param_name => $param_value)
335 echo "&${param_name}=${param_value}";
336 echo "'>" . $title['name'] . "</a>";
e673ee24
DO
337 }
338 echo "</td>";
339 // Search form.
340 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
341 echo "<form method=get action='${root}'><td>";
342 echo '<input type=hidden name=page value=search>';
343 // This input will be the first, if we don't add ports or addresses.
344 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
345}
346
347function getTitle ($pageno, $tabno)
348{
9c0b0016 349 global $page;
eebf9145
DO
350 if (isset ($page[$pageno]['title']))
351 return $page[$pageno]['title'];
352 elseif (isset ($page[$pageno]['title_handler']))
353 {
354 $tmp = $page[$pageno]['title_handler']($pageno);
355 return $tmp['name'];
356 }
357 else
9c0b0016 358 return getConfigVar ('enterprise');
e673ee24
DO
359}
360
361function showTabs ($pageno, $tabno)
362{
641fe9b0 363 global $tab, $root, $page, $remote_username, $trigger;
e673ee24
DO
364 if (!isset ($tab[$pageno]['default']))
365 return;
366 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
367 foreach ($tab[$pageno] as $tabidx => $tabtitle)
368 {
369 // Hide forbidden tabs.
370 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
371 continue;
641fe9b0
DO
372 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
373 if
374 (
375 isset ($trigger[$pageno][$tabidx]) &&
376 $trigger[$pageno][$tabidx] () != TRUE
377 )
378 continue;
e673ee24
DO
379 echo '<li><a' . (($tabidx == $tabno) ? ' class=current' : '');
380 echo " href='${root}?page=${pageno}&tab=${tabidx}";
381 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
382 {
383 $bpname = $page[$pageno]['bypass'];
384 $bpval = $_REQUEST[$bpname];
385 echo "&${bpname}=${bpval}";
386 }
387 echo "'>${tabtitle}</a></li>\n";
388 }
ae9a3784 389 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
390 echo "</ul></div></td>\n";
391}
392
393// This function returns pages, which are direct children of the requested
394// page and are accessible by the current user.
395function getDirectChildPages ($pageno)
396{
397 global $page, $remote_username;
398 $children = array();
399 foreach ($page as $cpageno => $cpage)
400 if
401 (
402 isset ($cpage['parent']) and
403 $cpage['parent'] == $pageno and
404 authorized ($remote_username, $cpageno, 'default') == TRUE
405 )
406 $children[$cpageno] = $cpage;
407 return $children;
408}
409
410function getAllChildPages ($parent)
411{
412 global $page;
413 // Array pointer is global, so if we don't create local copies of
414 // the global array, we can't advance any more after nested call
415 // of getAllChildPages returns.
416 $mypage = $page;
417 $mykids = array();
418 foreach ($mypage as $ctitle => $cpage)
419 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
420 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
421 return $mykids;
422}
423
424?>