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