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