r1429 + print comments for real servers, if they are known
[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
e673ee24
DO
15$page['index']['title'] = 'static_title';
16$page['index']['handler'] = 'renderIndex';
17
18$page['rackspace']['title'] = 'static_title';
19$page['rackspace']['handler'] = 'handler_rackspace';
20$page['rackspace']['parent'] = 'index';
21$tab['rackspace']['default'] = 'Browse';
22$tab['rackspace']['history'] = 'History';
9b0cf84f
DO
23$tab['rackspace']['firstrow'] = 'Click me!';
24$trigger['rackspace']['firstrow'] = 'trigger_emptyRackspace';
e673ee24
DO
25
26$page['objects']['title'] = 'static_title';
27$page['objects']['handler'] = 'handler_objects';
28$page['objects']['parent'] = 'index';
29$tab['objects']['default'] = 'View';
30$tab['objects']['newobj'] = 'Add an object';
31$tab['objects']['newmulti'] = 'Add multiple objects';
32
33$page['row']['title'] = 'dynamic_title_row';
34$page['row']['handler'] = 'handler_row';
35$page['row']['bypass'] = 'row_id';
36$page['row']['parent'] = 'rackspace';
37$tab['row']['default'] = 'View';
38$tab['row']['newrack'] = 'Add new rack';
39
40$page['rack']['title'] = 'dynamic_title_rack';
41$page['rack']['handler'] = 'handler_rack';
42$page['rack']['bypass'] = 'rack_id';
43$page['rack']['parent'] = 'row';
44$tab['rack']['default'] = 'View';
45$tab['rack']['edit'] = 'Properties';
46$tab['rack']['design'] = 'Design';
47$tab['rack']['problems'] = 'Problems';
beee6141
DO
48$helptab['rack']['design'] = 'rackspace';
49$helptab['rack']['problems'] = 'rackspace';
e673ee24
DO
50
51$page['objgroup']['title'] = 'dynamic_title_objgroup';
52$page['objgroup']['handler'] = 'handler_objgroup';
53$page['objgroup']['bypass'] = 'group_id';
54$page['objgroup']['parent'] = 'objects';
55
56$page['object']['title'] = 'dynamic_title_object';
e673ee24 57$page['object']['bypass'] = 'object_id';
3bebaebd 58$page['object']['bypass_type'] = 'uint';
e673ee24
DO
59$page['object']['parent'] = 'objgroup';
60$tab['object']['default'] = 'View';
61$tab['object']['edit'] = 'Properties';
62$tab['object']['rackspace'] = 'Rackspace';
63$tab['object']['ports'] = 'Ports';
64$tab['object']['network'] = 'IPv4';
737f9ac1 65$tab['object']['portfwrd'] = 'NATv4';
a684aa6f 66$tab['object']['switchvlans'] = 'Live VLANs';
9c67f713 67$tab['object']['snmpportfinder'] = 'SNMP port finder';
3ee1252b 68$tab['object']['lvsconfig'] = 'LVS configuration';
e45a78d7
DO
69$tabhandler['object']['default'] = 'renderRackObject';
70$tabhandler['object']['edit'] = 'renderEditObjectForm';
71$tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
72$tabhandler['object']['ports'] = 'renderPortsForObject';
73$tabhandler['object']['network'] = 'renderNetworkForObject';
74$tabhandler['object']['portfwrd'] = 'renderIPAddressPortForwarding';
75$tabhandler['object']['switchvlans'] = 'renderVLANMembership';
76$tabhandler['object']['snmpportfinder'] = 'renderSNMPPortFinder';
3ee1252b 77$tabhandler['object']['lvsconfig'] = 'renderLVSConfig';
bdd05c5d 78$helptab['object']['network'] = 'nets';
150fdd66 79$helptab['object']['ports'] = 'ports';
bdd05c5d
DO
80$helptab['object']['portfwrd'] = 'nets';
81$helptab['object']['rackspace'] = 'rackspace';
641fe9b0 82$trigger['object']['switchvlans'] = 'trigger_switchvlans';
9c67f713 83$trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
094bb33c 84$trigger['object']['lvsconfig'] = 'trigger_lvsconfig';
e673ee24
DO
85$ophandler['object']['ports']['addPort'] = 'addPortForObject';
86$ophandler['object']['ports']['delPort'] = 'delPortFromObject';
87$ophandler['object']['ports']['editPort'] = 'editPortForObject';
88$ophandler['object']['ports']['linkPort'] = 'linkPortForObject';
89$ophandler['object']['ports']['unlinkPort'] = 'unlinkPortForObject';
90$ophandler['object']['ports']['addMultiPorts'] = 'addMultiPorts';
91$ophandler['object']['ports']['useup'] = 'useupPort';
92$ophandler['object']['network']['editAddressFromObject'] = 'editAddressFromObject';
93$ophandler['object']['network']['addAddrFObj'] = 'addAddressToObject';
94$ophandler['object']['network']['delAddrFObj'] = 'delAddressFromObject';
95$ophandler['object']['edit']['del'] = 'resetAttrValue';
0dfb8a2a 96$ophandler['object']['edit']['upd'] = 'updateAttrValues';
e673ee24
DO
97$ophandler['object']['portfwrd']['forwardPorts'] = 'addPortForwarding';
98$ophandler['object']['portfwrd']['delPortForwarding'] = 'delPortForwarding';
99$ophandler['object']['portfwrd']['updPortForwarding'] = 'updPortForwarding';
641fe9b0 100$ophandler['object']['switchvlans']['submit'] = 'updateVLANMembership';
e673ee24
DO
101
102$page['ipv4space']['title'] = 'static_title';
103$page['ipv4space']['handler'] = 'handler_ipv4space';
104$page['ipv4space']['parent'] = 'index';
105$tab['ipv4space']['default'] = 'Browse';
106$tab['ipv4space']['newrange'] = 'Manage ranges';
bdd05c5d
DO
107$helptab['ipv4space']['default'] = 'nets';
108$helptab['ipv4space']['newrange'] = 'nets';
e673ee24
DO
109$ophandler['ipv4space']['newrange']['addRange'] = 'addNewrange';
110$ophandler['ipv4space']['newrange']['delRange'] = 'delRange';
111
112$page['iprange']['title'] = 'dynamic_title_iprange';
113$page['iprange']['handler'] = 'handler_iprange';
114$page['iprange']['parent'] = 'ipv4space';
115$page['iprange']['bypass'] = 'id';
116$tab['iprange']['default'] = 'Browse';
117$tab['iprange']['properties'] = 'Properties';
bdd05c5d
DO
118$helptab['iprange']['default'] = 'nets';
119$helptab['iprange']['properties'] = 'nets';
e673ee24
DO
120$ophandler['iprange']['properties']['editRange'] = 'editRange';
121
122$page['ipaddress']['title'] = 'dynamic_title_ipaddress';
123$page['ipaddress']['handler'] = 'handler_ipaddress';
124$page['ipaddress']['parent'] = 'iprange';
125$page['ipaddress']['bypass'] = 'ip';
126$tab['ipaddress']['default'] = 'Browse';
127$tab['ipaddress']['properties'] = 'Properties';
128$tab['ipaddress']['assignment'] = 'Allocation';
bdd05c5d
DO
129$helptab['ipaddress']['default'] = 'nets';
130$helptab['ipaddress']['properties'] = 'nets';
131$helptab['ipaddress']['assignment'] = 'nets';
e673ee24
DO
132$ophandler['ipaddress']['properties']['editAddress'] = 'editAddress';
133$ophandler['ipaddress']['assignment']['delIpAssignment'] = 'delIpAssignment';
134$ophandler['ipaddress']['assignment']['editBondForAddress'] = 'editIpAssignment';
135$ophandler['ipaddress']['assignment']['bindObjectToIp'] = 'addIpAssignment';
136
137$page['search']['title'] = 'dynamic_title_search';
138$page['search']['handler'] = 'handler_search';
139$page['search']['parent'] = 'index';
140$page['search']['bypass'] = 'q';
141
142$page['config']['title'] = 'static_title';
143$page['config']['handler'] = 'handler_config';
144$page['config']['parent'] = 'index';
145
146$page['accounts']['title'] = 'static_title';
147$page['accounts']['handler'] = 'handler_accounts';
148$page['accounts']['parent'] = 'config';
149$tab['accounts']['default'] = 'View';
150$tab['accounts']['edit'] = 'Change';
151$ophandler['accounts']['edit']['updateAccount'] = 'updateUserAccount';
152$ophandler['accounts']['edit']['createAccount'] = 'createUserAccount';
153$ophandler['accounts']['edit']['disableAccount'] = 'disableUserAccount';
154$ophandler['accounts']['edit']['enableAccount'] = 'enableUserAccount';
155
156$page['perms']['title'] = 'static_title';
157$page['perms']['handler'] = 'handler_perms';
158$page['perms']['parent'] = 'config';
159$tab['perms']['default'] = 'View';
160$tab['perms']['edit'] = 'Change';
161$ophandler['perms']['edit']['revoke'] = 'revokePermission';
162$ophandler['perms']['edit']['grant'] = 'grantPermission';
163
164$page['portmap']['title'] = 'static_title';
165$page['portmap']['handler'] = 'handler_portmap';
166$page['portmap']['parent'] = 'config';
167$tab['portmap']['default'] = 'View';
168$tab['portmap']['edit'] = 'Change';
169$ophandler['portmap']['edit']['save'] = 'savePortMap';
170
171$page['attrs']['title'] = 'static_title';
172$page['attrs']['handler'] = 'handler_attrs';
173$page['attrs']['parent'] = 'config';
174$tab['attrs']['default'] = 'View';
175$tab['attrs']['editattrs'] = 'Edit attributes';
176$tab['attrs']['editmap'] = 'Edit map';
177$ophandler['attrs']['editattrs']['add'] = 'createAttribute';
178$ophandler['attrs']['editattrs']['upd'] = 'changeAttribute';
179$ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
180$ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
181$ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
182
183$page['dict']['title'] = 'static_title';
184$page['dict']['handler'] = 'handler_dict';
185$page['dict']['parent'] = 'config';
186$tab['dict']['default'] = 'View';
187$tab['dict']['edit'] = 'Edit words';
188$tab['dict']['chapters'] = 'Manage chapters';
189$ophandler['dict']['edit']['del'] = 'reduceDictionary';
190$ophandler['dict']['edit']['upd'] = 'updateDictionary';
191$ophandler['dict']['edit']['add'] = 'supplementDictionary';
192$ophandler['dict']['chapters']['del'] = 'delChapter';
193$ophandler['dict']['chapters']['upd'] = 'updateChapter';
194$ophandler['dict']['chapters']['add'] = 'addChapter';
195
196$page['ui']['title'] = 'static_title';
197$page['ui']['handler'] = 'handler_ui';
198$page['ui']['parent'] = 'config';
0a1b1268 199$tab['ui']['default'] = 'View';
4fe32e78 200$tab['ui']['edit'] = 'Change';
b07f617c 201$tab['ui']['reset'] = 'Reset';
4fe32e78 202$ophandler['ui']['edit']['upd'] = 'updateUI';
b07f617c 203$ophandler['ui']['reset']['go'] = 'resetUIConfig';
e673ee24
DO
204
205$page['reports']['title'] = 'static_title';
206$page['reports']['handler'] = 'handler_reports';
207$page['reports']['parent'] = 'index';
208$tab['reports']['default'] = 'View';
209
ae545907
DO
210$page['help']['title'] = 'static_title';
211$page['help']['handler'] = 'handler_help';
212$page['help']['parent'] = 'index';
beee6141 213$tab['help']['default'] = 'Welcome';
51ef5041 214$tab['help']['quickstart'] = 'Quick start';
beee6141
DO
215$tab['help']['workflow'] = 'Workflow';
216$tab['help']['rackspace'] = 'Rackspace';
217$tab['help']['objects'] = 'Objects';
bdd05c5d 218$tab['help']['nets'] = 'Networking';
0a1b1268
DO
219$tab['help']['auth'] = '[ User accounts & permissions ]';
220$tab['help']['dict'] = '[ Dictionary ]';
beee6141 221$tab['help']['ports'] = 'Ports and links';
0a1b1268 222$tab['help']['hacking'] = '[ Hacker\'s guide ]';
ae545907 223
e673ee24
DO
224// This function returns array if page numbers leading to the target page
225// plus page number of target page itself. The first element is the target
226// page number and the last element is the index page number.
227function getPath ($targetno)
228{
229 global $page;
230 $path = array();
231 // Recursion breaks at first parentless page.
232 if (!isset ($page[$targetno]['parent']))
233 $path = array ($targetno);
234 else
235 {
236 $path = getPath ($page[$targetno]['parent']);
237 $path[] = $targetno;
238 }
239 return $path;
240}
241
242function showPathAndSearch ($pageno)
243{
9c0b0016 244 global $root, $page;
e673ee24 245 // Path.
73635d32 246 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
e673ee24
DO
247 if (isset ($page[$pageno]['title']))
248 {
249 $path = getPath ($pageno);
250 foreach ($path as $dummy => $no)
251 {
252 $title = $page[$no]['title']($no);
253 echo ": <a href='${root}?page=${no}";
254 foreach ($title['params'] as $param_name => $param_value)
255 echo "&${param_name}=${param_value}";
256 echo "'>" .$title['name'] . "</a>";
257 }
258 }
259 echo "</td>";
260 // Search form.
261 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
262 echo "<form method=get action='${root}'><td>";
263 echo '<input type=hidden name=page value=search>';
264 // This input will be the first, if we don't add ports or addresses.
265 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
266}
267
268function getTitle ($pageno, $tabno)
269{
9c0b0016
DO
270 global $page;
271 if (!isset ($page[$pageno]['title']))
272 return getConfigVar ('enterprise');
273 $tmp = $page[$pageno]['title']($pageno);
274 return $tmp['name'];
e673ee24
DO
275}
276
277function showTabs ($pageno, $tabno)
278{
641fe9b0 279 global $tab, $root, $page, $remote_username, $trigger;
e673ee24
DO
280 if (!isset ($tab[$pageno]['default']))
281 return;
282 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
283 foreach ($tab[$pageno] as $tabidx => $tabtitle)
284 {
285 // Hide forbidden tabs.
286 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
287 continue;
641fe9b0
DO
288 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
289 if
290 (
291 isset ($trigger[$pageno][$tabidx]) &&
292 $trigger[$pageno][$tabidx] () != TRUE
293 )
294 continue;
e673ee24
DO
295 echo '<li><a' . (($tabidx == $tabno) ? ' class=current' : '');
296 echo " href='${root}?page=${pageno}&tab=${tabidx}";
297 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
298 {
299 $bpname = $page[$pageno]['bypass'];
300 $bpval = $_REQUEST[$bpname];
301 echo "&${bpname}=${bpval}";
302 }
303 echo "'>${tabtitle}</a></li>\n";
304 }
ae9a3784 305 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
306 echo "</ul></div></td>\n";
307}
308
309// This function returns pages, which are direct children of the requested
310// page and are accessible by the current user.
311function getDirectChildPages ($pageno)
312{
313 global $page, $remote_username;
314 $children = array();
315 foreach ($page as $cpageno => $cpage)
316 if
317 (
318 isset ($cpage['parent']) and
319 $cpage['parent'] == $pageno and
320 authorized ($remote_username, $cpageno, 'default') == TRUE
321 )
322 $children[$cpageno] = $cpage;
323 return $children;
324}
325
326function getAllChildPages ($parent)
327{
328 global $page;
329 // Array pointer is global, so if we don't create local copies of
330 // the global array, we can't advance any more after nested call
331 // of getAllChildPages returns.
332 $mypage = $page;
333 $mykids = array();
334 foreach ($mypage as $ctitle => $cpage)
335 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
336 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
337 return $mykids;
338}
339
340?>