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