r1427 + fix missing trigger reference
[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 $tabhandler = array();
14
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';
23 $tab['rackspace']['firstrow'] = 'Click me!';
24 $trigger['rackspace']['firstrow'] = 'trigger_emptyRackspace';
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';
48 $helptab['rack']['design'] = 'rackspace';
49 $helptab['rack']['problems'] = 'rackspace';
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';
57 $page['object']['bypass'] = 'object_id';
58 $page['object']['bypass_type'] = 'uint';
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';
65 $tab['object']['portfwrd'] = 'NATv4';
66 $tab['object']['switchvlans'] = 'Live VLANs';
67 $tab['object']['snmpportfinder'] = 'SNMP port finder';
68 $tab['object']['lvsconfig'] = 'LVS configuration';
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';
77 $tabhandler['object']['lvsconfig'] = 'renderLVSConfig';
78 $helptab['object']['network'] = 'nets';
79 $helptab['object']['ports'] = 'ports';
80 $helptab['object']['portfwrd'] = 'nets';
81 $helptab['object']['rackspace'] = 'rackspace';
82 $trigger['object']['switchvlans'] = 'trigger_switchvlans';
83 $trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
84 $trigger['object']['lvsconfig'] = 'trigger_lvsconfig';
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';
96 $ophandler['object']['edit']['upd'] = 'updateAttrValues';
97 $ophandler['object']['portfwrd']['forwardPorts'] = 'addPortForwarding';
98 $ophandler['object']['portfwrd']['delPortForwarding'] = 'delPortForwarding';
99 $ophandler['object']['portfwrd']['updPortForwarding'] = 'updPortForwarding';
100 $ophandler['object']['switchvlans']['submit'] = 'updateVLANMembership';
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';
107 $helptab['ipv4space']['default'] = 'nets';
108 $helptab['ipv4space']['newrange'] = 'nets';
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';
118 $helptab['iprange']['default'] = 'nets';
119 $helptab['iprange']['properties'] = 'nets';
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';
129 $helptab['ipaddress']['default'] = 'nets';
130 $helptab['ipaddress']['properties'] = 'nets';
131 $helptab['ipaddress']['assignment'] = 'nets';
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';
199 $tab['ui']['default'] = 'View';
200 $tab['ui']['edit'] = 'Change';
201 $tab['ui']['reset'] = 'Reset';
202 $ophandler['ui']['edit']['upd'] = 'updateUI';
203 $ophandler['ui']['reset']['go'] = 'resetUIConfig';
204
205 $page['reports']['title'] = 'static_title';
206 $page['reports']['handler'] = 'handler_reports';
207 $page['reports']['parent'] = 'index';
208 $tab['reports']['default'] = 'View';
209
210 $page['help']['title'] = 'static_title';
211 $page['help']['handler'] = 'handler_help';
212 $page['help']['parent'] = 'index';
213 $tab['help']['default'] = 'Welcome';
214 $tab['help']['quickstart'] = 'Quick start';
215 $tab['help']['workflow'] = 'Workflow';
216 $tab['help']['rackspace'] = 'Rackspace';
217 $tab['help']['objects'] = 'Objects';
218 $tab['help']['nets'] = 'Networking';
219 $tab['help']['auth'] = '[ User accounts & permissions ]';
220 $tab['help']['dict'] = '[ Dictionary ]';
221 $tab['help']['ports'] = 'Ports and links';
222 $tab['help']['hacking'] = '[ Hacker\'s guide ]';
223
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.
227 function 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
242 function showPathAndSearch ($pageno)
243 {
244 global $root, $page;
245 // Path.
246 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
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
268 function getTitle ($pageno, $tabno)
269 {
270 global $page;
271 if (!isset ($page[$pageno]['title']))
272 return getConfigVar ('enterprise');
273 $tmp = $page[$pageno]['title']($pageno);
274 return $tmp['name'];
275 }
276
277 function showTabs ($pageno, $tabno)
278 {
279 global $tab, $root, $page, $remote_username, $trigger;
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;
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;
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 }
305 lookupHelpTopic ($pageno, $tabno);
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.
311 function 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
326 function 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 ?>