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