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