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