r1202 + all options have moved into the database
[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';
80$ophandler['object']['edit']['upd'] = 'updateAttrValue';
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';
183
184$page['ro']['title'] = 'static_title';
185$page['ro']['handler'] = 'handler_ro';
186$page['ro']['parent'] = 'config';
187
188$page['reports']['title'] = 'static_title';
189$page['reports']['handler'] = 'handler_reports';
190$page['reports']['parent'] = 'index';
191$tab['reports']['default'] = 'View';
192
ae545907
DO
193$page['help']['title'] = 'static_title';
194$page['help']['handler'] = 'handler_help';
195$page['help']['parent'] = 'index';
beee6141 196$tab['help']['default'] = 'Welcome';
51ef5041 197$tab['help']['quickstart'] = 'Quick start';
beee6141
DO
198$tab['help']['workflow'] = 'Workflow';
199$tab['help']['rackspace'] = 'Rackspace';
200$tab['help']['objects'] = 'Objects';
bdd05c5d 201$tab['help']['nets'] = 'Networking';
beee6141
DO
202$tab['help']['auth'] = 'User accounts & permissions';
203$tab['help']['dict'] = 'Dictionary';
204$tab['help']['ports'] = 'Ports and links';
beee6141 205$tab['help']['hacking'] = 'Hacker\'s guide';
ae545907 206
e673ee24
DO
207// This function returns array if page numbers leading to the target page
208// plus page number of target page itself. The first element is the target
209// page number and the last element is the index page number.
210function getPath ($targetno)
211{
212 global $page;
213 $path = array();
214 // Recursion breaks at first parentless page.
215 if (!isset ($page[$targetno]['parent']))
216 $path = array ($targetno);
217 else
218 {
219 $path = getPath ($page[$targetno]['parent']);
220 $path[] = $targetno;
221 }
222 return $path;
223}
224
225function showPathAndSearch ($pageno)
226{
9c0b0016 227 global $root, $page;
e673ee24 228 // Path.
9c0b0016 229 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise') . " RackTables";
e673ee24
DO
230 if (isset ($page[$pageno]['title']))
231 {
232 $path = getPath ($pageno);
233 foreach ($path as $dummy => $no)
234 {
235 $title = $page[$no]['title']($no);
236 echo ": <a href='${root}?page=${no}";
237 foreach ($title['params'] as $param_name => $param_value)
238 echo "&${param_name}=${param_value}";
239 echo "'>" .$title['name'] . "</a>";
240 }
241 }
242 echo "</td>";
243 // Search form.
244 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
245 echo "<form method=get action='${root}'><td>";
246 echo '<input type=hidden name=page value=search>';
247 // This input will be the first, if we don't add ports or addresses.
248 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
249}
250
251function getTitle ($pageno, $tabno)
252{
9c0b0016
DO
253 global $page;
254 if (!isset ($page[$pageno]['title']))
255 return getConfigVar ('enterprise');
256 $tmp = $page[$pageno]['title']($pageno);
257 return $tmp['name'];
e673ee24
DO
258}
259
260function showTabs ($pageno, $tabno)
261{
641fe9b0 262 global $tab, $root, $page, $remote_username, $trigger;
e673ee24
DO
263 if (!isset ($tab[$pageno]['default']))
264 return;
265 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
266 foreach ($tab[$pageno] as $tabidx => $tabtitle)
267 {
268 // Hide forbidden tabs.
269 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
270 continue;
641fe9b0
DO
271 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
272 if
273 (
274 isset ($trigger[$pageno][$tabidx]) &&
275 $trigger[$pageno][$tabidx] () != TRUE
276 )
277 continue;
e673ee24
DO
278 echo '<li><a' . (($tabidx == $tabno) ? ' class=current' : '');
279 echo " href='${root}?page=${pageno}&tab=${tabidx}";
280 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
281 {
282 $bpname = $page[$pageno]['bypass'];
283 $bpval = $_REQUEST[$bpname];
284 echo "&${bpname}=${bpval}";
285 }
286 echo "'>${tabtitle}</a></li>\n";
287 }
ae9a3784 288 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
289 echo "</ul></div></td>\n";
290}
291
292// This function returns pages, which are direct children of the requested
293// page and are accessible by the current user.
294function getDirectChildPages ($pageno)
295{
296 global $page, $remote_username;
297 $children = array();
298 foreach ($page as $cpageno => $cpage)
299 if
300 (
301 isset ($cpage['parent']) and
302 $cpage['parent'] == $pageno and
303 authorized ($remote_username, $cpageno, 'default') == TRUE
304 )
305 $children[$cpageno] = $cpage;
306 return $children;
307}
308
309function getAllChildPages ($parent)
310{
311 global $page;
312 // Array pointer is global, so if we don't create local copies of
313 // the global array, we can't advance any more after nested call
314 // of getAllChildPages returns.
315 $mypage = $page;
316 $mykids = array();
317 foreach ($mypage as $ctitle => $cpage)
318 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
319 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
320 return $mykids;
321}
322
323?>