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