r1766 + initial working implementation of explicit, implicit and automatic tags
[racktables] / inc / navigation.php
CommitLineData
b325120a 1<?php
e673ee24
DO
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();
81bab70c 13$tabhandler = array();
83dd1b15 14
eebf9145 15$page['index']['title'] = 'Main page';
e673ee24
DO
16$page['index']['handler'] = 'renderIndex';
17
eebf9145 18$page['rackspace']['title'] = 'Rackspace';
e673ee24
DO
19$page['rackspace']['parent'] = 'index';
20$tab['rackspace']['default'] = 'Browse';
21$tab['rackspace']['history'] = 'History';
9b0cf84f
DO
22$tab['rackspace']['firstrow'] = 'Click me!';
23$trigger['rackspace']['firstrow'] = 'trigger_emptyRackspace';
8b6ffe9c
DO
24$tabhandler['rackspace']['default'] = 'renderRackspace';
25$tabhandler['rackspace']['history'] = 'renderRackspaceHistory';
26$tabhandler['rackspace']['firstrow'] = 'renderFirstRowForm';
08b16bf5 27$tabextraclass['rackspace']['firstrow'] = 'attn';
e673ee24 28
eebf9145 29$page['objects']['title'] = 'Objects';
e673ee24
DO
30$page['objects']['parent'] = 'index';
31$tab['objects']['default'] = 'View';
32$tab['objects']['newobj'] = 'Add an object';
33$tab['objects']['newmulti'] = 'Add multiple objects';
8b6ffe9c
DO
34$tabhandler['objects']['default'] = 'renderObjectGroupSummary';
35$tabhandler['objects']['newobj'] = 'renderNewObjectForm';
36$tabhandler['objects']['newmulti'] = 'renderAddMultipleObjectsForm';
e673ee24 37
eebf9145 38$page['row']['title_handler'] = 'dynamic_title_row';
e673ee24 39$page['row']['bypass'] = 'row_id';
8b6ffe9c 40$page['row']['bypass_type'] = 'uint';
e673ee24
DO
41$page['row']['parent'] = 'rackspace';
42$tab['row']['default'] = 'View';
43$tab['row']['newrack'] = 'Add new rack';
8b6ffe9c
DO
44$tabhandler['row']['default'] = 'renderRow';
45$tabhandler['row']['newrack'] = 'renderNewRackForm';
e673ee24 46
eebf9145 47$page['rack']['title_handler'] = 'dynamic_title_rack';
e673ee24 48$page['rack']['bypass'] = 'rack_id';
8b6ffe9c 49$page['rack']['bypass_type'] = 'uint';
e673ee24
DO
50$page['rack']['parent'] = 'row';
51$tab['rack']['default'] = 'View';
52$tab['rack']['edit'] = 'Properties';
53$tab['rack']['design'] = 'Design';
54$tab['rack']['problems'] = 'Problems';
8b6ffe9c
DO
55$tabhandler['rack']['default'] = 'renderRackPage';
56$tabhandler['rack']['edit'] = 'renderEditRackForm';
57$tabhandler['rack']['design'] = 'renderRackDesign';
58$tabhandler['rack']['problems'] = 'renderRackProblems';
e673ee24 59
eebf9145 60$page['objgroup']['title_handler'] = 'dynamic_title_objgroup';
3aeb15f3 61$page['objgroup']['handler'] = 'renderObjectGroup';
e673ee24 62$page['objgroup']['bypass'] = 'group_id';
3aeb15f3 63$page['objgroup']['bypass_type'] = 'uint';
e673ee24
DO
64$page['objgroup']['parent'] = 'objects';
65
eebf9145 66$page['object']['title_handler'] = 'dynamic_title_object';
e673ee24 67$page['object']['bypass'] = 'object_id';
3bebaebd 68$page['object']['bypass_type'] = 'uint';
e673ee24 69$page['object']['parent'] = 'objgroup';
2fb24351
DO
70$page['object']['tagloader'] = 'loadRackObjectTags';
71$page['object']['autotagloader'] = 'loadRackObjectAutoTags';
e673ee24
DO
72$tab['object']['default'] = 'View';
73$tab['object']['edit'] = 'Properties';
74$tab['object']['rackspace'] = 'Rackspace';
75$tab['object']['ports'] = 'Ports';
76$tab['object']['network'] = 'IPv4';
737f9ac1 77$tab['object']['portfwrd'] = 'NATv4';
a684aa6f 78$tab['object']['switchvlans'] = 'Live VLANs';
9c67f713 79$tab['object']['snmpportfinder'] = 'SNMP port finder';
7e13adfe 80$tab['object']['slb'] = '[SLB]';
3ee1252b 81$tab['object']['lvsconfig'] = 'LVS configuration';
118e4c38 82$tab['object']['autoports'] = 'AutoPorts';
2fb24351 83$tab['object']['tags'] = 'Tags';
e45a78d7
DO
84$tabhandler['object']['default'] = 'renderRackObject';
85$tabhandler['object']['edit'] = 'renderEditObjectForm';
86$tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
87$tabhandler['object']['ports'] = 'renderPortsForObject';
88$tabhandler['object']['network'] = 'renderNetworkForObject';
89$tabhandler['object']['portfwrd'] = 'renderIPAddressPortForwarding';
90$tabhandler['object']['switchvlans'] = 'renderVLANMembership';
91$tabhandler['object']['snmpportfinder'] = 'renderSNMPPortFinder';
3ee1252b 92$tabhandler['object']['lvsconfig'] = 'renderLVSConfig';
118e4c38 93$tabhandler['object']['autoports'] = 'renderAutoPortsForm';
2fb24351 94$tabhandler['object']['tags'] = 'renderObjectTags';
08b16bf5
DO
95$tabextraclass['object']['snmpportfinder'] = 'attn';
96$tabextraclass['object']['autoports'] = 'attn';
6dbdc7c7
DO
97$trigger['object']['network'] = 'trigger_ipv4';
98$trigger['object']['portfwrd'] = 'trigger_natv4';
641fe9b0 99$trigger['object']['switchvlans'] = 'trigger_switchvlans';
9c67f713 100$trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
7e13adfe 101$trigger['object']['slb'] = 'trigger_natv4';
094bb33c 102$trigger['object']['lvsconfig'] = 'trigger_lvsconfig';
118e4c38 103$trigger['object']['autoports'] = 'trigger_autoports';
e673ee24
DO
104$ophandler['object']['ports']['addPort'] = 'addPortForObject';
105$ophandler['object']['ports']['delPort'] = 'delPortFromObject';
106$ophandler['object']['ports']['editPort'] = 'editPortForObject';
107$ophandler['object']['ports']['linkPort'] = 'linkPortForObject';
108$ophandler['object']['ports']['unlinkPort'] = 'unlinkPortForObject';
109$ophandler['object']['ports']['addMultiPorts'] = 'addMultiPorts';
110$ophandler['object']['ports']['useup'] = 'useupPort';
111$ophandler['object']['network']['editAddressFromObject'] = 'editAddressFromObject';
112$ophandler['object']['network']['addAddrFObj'] = 'addAddressToObject';
113$ophandler['object']['network']['delAddrFObj'] = 'delAddressFromObject';
114$ophandler['object']['edit']['del'] = 'resetAttrValue';
0dfb8a2a 115$ophandler['object']['edit']['upd'] = 'updateAttrValues';
e673ee24
DO
116$ophandler['object']['portfwrd']['forwardPorts'] = 'addPortForwarding';
117$ophandler['object']['portfwrd']['delPortForwarding'] = 'delPortForwarding';
118$ophandler['object']['portfwrd']['updPortForwarding'] = 'updPortForwarding';
f3f0161f 119$ophandler['object']['autoports']['generate'] = 'generateAutoPorts';
e673ee24 120
eebf9145 121$page['ipv4space']['title'] = 'IPv4 space';
e673ee24
DO
122$page['ipv4space']['parent'] = 'index';
123$tab['ipv4space']['default'] = 'Browse';
0bcdc163 124$tab['ipv4space']['newrange'] = 'Manage';
8b6ffe9c
DO
125$tabhandler['ipv4space']['default'] = 'renderAddressspace';
126$tabhandler['ipv4space']['newrange'] = 'renderAddNewRange';
e673ee24
DO
127$ophandler['ipv4space']['newrange']['addRange'] = 'addNewrange';
128$ophandler['ipv4space']['newrange']['delRange'] = 'delRange';
129
eebf9145 130$page['iprange']['title_handler'] = 'dynamic_title_iprange';
e673ee24
DO
131$page['iprange']['parent'] = 'ipv4space';
132$page['iprange']['bypass'] = 'id';
2fe5476a 133$page['iprange']['bypass_type'] = 'uint';
e673ee24
DO
134$tab['iprange']['default'] = 'Browse';
135$tab['iprange']['properties'] = 'Properties';
2fe5476a 136$tab['iprange']['liveptr'] = 'Live PTR';
8b6ffe9c
DO
137$tabhandler['iprange']['default'] = 'renderIPRange';
138$tabhandler['iprange']['properties'] = 'renderIPRangeProperties';
2fe5476a 139$tabhandler['iprange']['liveptr'] = 'renderLivePTR';
e673ee24 140$ophandler['iprange']['properties']['editRange'] = 'editRange';
3f3bd41e 141$ophandler['iprange']['liveptr']['import'] = 'importPTRData';
e673ee24 142
eebf9145 143$page['ipaddress']['title_handler'] = 'dynamic_title_ipaddress';
e673ee24
DO
144$page['ipaddress']['parent'] = 'iprange';
145$page['ipaddress']['bypass'] = 'ip';
146$tab['ipaddress']['default'] = 'Browse';
147$tab['ipaddress']['properties'] = 'Properties';
148$tab['ipaddress']['assignment'] = 'Allocation';
7e13adfe 149$tab['ipaddress']['editrslist'] = '[SLB real servers]';
8b6ffe9c
DO
150$tabhandler['ipaddress']['default'] = 'renderIPAddress';
151$tabhandler['ipaddress']['properties'] = 'renderIPAddressProperties';
152$tabhandler['ipaddress']['assignment'] = 'renderIPAddressAssignment';
e673ee24
DO
153$ophandler['ipaddress']['properties']['editAddress'] = 'editAddress';
154$ophandler['ipaddress']['assignment']['delIpAssignment'] = 'delIpAssignment';
155$ophandler['ipaddress']['assignment']['editBondForAddress'] = 'editIpAssignment';
156$ophandler['ipaddress']['assignment']['bindObjectToIp'] = 'addIpAssignment';
157
f973f491
DO
158$page['ipv4slb']['title'] = 'IPv4 SLB';
159$page['ipv4slb']['parent'] = 'index';
160$page['ipv4slb']['handler'] = 'renderIPv4SLB';
161
b3c50e6c 162$page['vservices']['title'] = 'Virtual services';
f973f491 163$page['vservices']['parent'] = 'ipv4slb';
e57dca7f 164$tab['vservices']['default'] = 'View';
1183c73f 165$tab['vservices']['edit'] = 'Edit';
e57dca7f 166$tabhandler['vservices']['default'] = 'renderVSList';
1183c73f
DO
167$tabhandler['vservices']['edit'] = 'renderVSListEditForm';
168$ophandler['vservices']['edit']['add'] = 'addVService';
169$ophandler['vservices']['edit']['del'] = 'deleteVService';
170$ophandler['vservices']['edit']['upd'] = 'updateVService';
b3c50e6c 171
eebf9145 172$page['vservice']['title_handler'] = 'dynamic_title_vservice';
b3c50e6c 173$page['vservice']['parent'] = 'vservices';
c9b4588f
DO
174$page['vservice']['bypass'] = 'id';
175$page['vservice']['bypass_type'] = 'uint';
3bab7445
DO
176$tab['vservice']['default'] = 'View';
177$tab['vservice']['edit'] = '[Edit]';
7e13adfe 178$tab['vservice']['editlblist'] = '[Load balancers]';
0bcdc163 179$tabhandler['vservice']['default'] = 'renderVirtualService';
c9b4588f 180
9a81d416 181$page['rspools']['title'] = 'RS pools';
f973f491 182$page['rspools']['parent'] = 'ipv4slb';
9a81d416 183$tab['rspools']['default'] = 'View';
5ad76f01 184$tab['rspools']['edit'] = 'Edit';
9a81d416 185$tabhandler['rspools']['default'] = 'renderRSPoolList';
5ad76f01
DO
186$tabhandler['rspools']['edit'] = 'editRSPools';
187$ophandler['rspools']['edit']['add'] = 'addRSPool';
188$ophandler['rspools']['edit']['del'] = 'deleteRSPool';
189$ophandler['rspools']['edit']['upd'] = 'updateRSPool';
b3c50e6c 190
30aaee5a 191$page['rspool']['title_handler'] = 'dynamic_title_rspool';
b3c50e6c 192$page['rspool']['parent'] = 'rspools';
71b8bda1
DO
193$page['rspool']['bypass'] = 'id';
194$page['rspool']['bypass_type'] = 'uint';
195$tab['rspool']['default'] = 'View';
0bcdc163 196$tab['rspool']['edit'] = '[Edit]';
3241551e 197$tab['rspool']['editlblist'] = 'Load Balancers';
1f7d18fa
DO
198$tab['rspool']['editrslist'] = 'RS list';
199$tab['rspool']['rsinservice'] = 'RS in service';
a785988f 200$trigger['rspool']['rsinservice'] = 'trigger_poolrscount';
71b8bda1 201$tabhandler['rspool']['default'] = 'renderRSPool';
ca461127 202$tabhandler['rspool']['editrslist'] = 'renderRSPoolServerForm';
3241551e 203$tabhandler['rspool']['editlblist'] = 'renderRSPoolLBForm';
1f7d18fa 204$tabhandler['rspool']['rsinservice'] = 'renderRSPoolRSInServiceForm';
ca461127 205$ophandler['rspool']['editrslist']['addRS'] = 'addRealServer';
fb1c4a54
DO
206$ophandler['rspool']['editrslist']['delRS'] = 'deleteRealServer';
207$ophandler['rspool']['editrslist']['updRS'] = 'updateRealServer';
732e4578 208$ophandler['rspool']['editrslist']['addMany'] = 'addRealServers';
3241551e
DO
209$ophandler['rspool']['editlblist']['addLB'] = 'addLoadBalancer';
210$ophandler['rspool']['editlblist']['delLB'] = 'deleteLoadBalancer';
211$ophandler['rspool']['editlblist']['updLB'] = 'updateLoadBalancer';
1f7d18fa 212$ophandler['rspool']['rsinservice']['upd'] = 'updateRSInService';
71b8bda1 213
8253d9f0 214$page['rservers']['title'] = 'Real servers';
f973f491 215$page['rservers']['parent'] = 'ipv4slb';
8253d9f0 216$page['rservers']['handler'] = 'renderRealServerList';
b3c50e6c 217
4b0932b6 218$page['lbs']['title'] = 'Load balancers';
f973f491 219$page['lbs']['parent'] = 'ipv4slb';
4b0932b6 220$page['lbs']['handler'] = 'renderLBList';
b3c50e6c 221
eebf9145 222$page['search']['title_handler'] = 'dynamic_title_search';
3aeb15f3 223$page['search']['handler'] = 'renderSearchResults';
e673ee24
DO
224$page['search']['parent'] = 'index';
225$page['search']['bypass'] = 'q';
226
eebf9145 227$page['config']['title'] = 'Configuration';
3aeb15f3 228$page['config']['handler'] = 'renderConfigMainpage';
e673ee24
DO
229$page['config']['parent'] = 'index';
230
eebf9145 231$page['accounts']['title'] = 'Accounts';
e673ee24
DO
232$page['accounts']['parent'] = 'config';
233$tab['accounts']['default'] = 'View';
234$tab['accounts']['edit'] = 'Change';
8b6ffe9c
DO
235$tabhandler['accounts']['default'] = 'renderAccounts';
236$tabhandler['accounts']['edit'] = 'renderAccountsEditForm';
e673ee24
DO
237$ophandler['accounts']['edit']['updateAccount'] = 'updateUserAccount';
238$ophandler['accounts']['edit']['createAccount'] = 'createUserAccount';
239$ophandler['accounts']['edit']['disableAccount'] = 'disableUserAccount';
240$ophandler['accounts']['edit']['enableAccount'] = 'enableUserAccount';
241
eebf9145 242$page['perms']['title'] = 'Permissions';
e673ee24
DO
243$page['perms']['parent'] = 'config';
244$tab['perms']['default'] = 'View';
245$tab['perms']['edit'] = 'Change';
8b6ffe9c
DO
246$tabhandler['perms']['default'] = 'renderPermissions';
247$tabhandler['perms']['edit'] = 'renderPermissionsEditForm';
e673ee24
DO
248$ophandler['perms']['edit']['revoke'] = 'revokePermission';
249$ophandler['perms']['edit']['grant'] = 'grantPermission';
250
eebf9145 251$page['portmap']['title'] = 'Port compatibility map';
e673ee24
DO
252$page['portmap']['handler'] = 'handler_portmap';
253$page['portmap']['parent'] = 'config';
254$tab['portmap']['default'] = 'View';
255$tab['portmap']['edit'] = 'Change';
256$ophandler['portmap']['edit']['save'] = 'savePortMap';
257
eebf9145 258$page['attrs']['title'] = 'Attributes';
e673ee24
DO
259$page['attrs']['parent'] = 'config';
260$tab['attrs']['default'] = 'View';
261$tab['attrs']['editattrs'] = 'Edit attributes';
262$tab['attrs']['editmap'] = 'Edit map';
8b6ffe9c
DO
263$tabhandler['attrs']['default'] = 'renderAttributes';
264$tabhandler['attrs']['editattrs'] = 'renderEditAttributesForm';
265$tabhandler['attrs']['editmap'] = 'renderEditAttrMapForm';
e673ee24
DO
266$ophandler['attrs']['editattrs']['add'] = 'createAttribute';
267$ophandler['attrs']['editattrs']['upd'] = 'changeAttribute';
268$ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
269$ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
270$ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
271
eebf9145 272$page['dict']['title'] = 'Dictionary';
e673ee24
DO
273$page['dict']['parent'] = 'config';
274$tab['dict']['default'] = 'View';
275$tab['dict']['edit'] = 'Edit words';
276$tab['dict']['chapters'] = 'Manage chapters';
8b6ffe9c
DO
277$tabhandler['dict']['default'] = 'renderDictionary';
278$tabhandler['dict']['edit'] = 'renderDictionaryEditor';
279$tabhandler['dict']['chapters'] = 'renderChaptersEditor';
e673ee24
DO
280$ophandler['dict']['edit']['del'] = 'reduceDictionary';
281$ophandler['dict']['edit']['upd'] = 'updateDictionary';
282$ophandler['dict']['edit']['add'] = 'supplementDictionary';
283$ophandler['dict']['chapters']['del'] = 'delChapter';
284$ophandler['dict']['chapters']['upd'] = 'updateChapter';
285$ophandler['dict']['chapters']['add'] = 'addChapter';
286
eebf9145 287$page['ui']['title'] = 'User interface';
e673ee24 288$page['ui']['parent'] = 'config';
0a1b1268 289$tab['ui']['default'] = 'View';
4fe32e78 290$tab['ui']['edit'] = 'Change';
b07f617c 291$tab['ui']['reset'] = 'Reset';
8b6ffe9c
DO
292$tabhandler['ui']['default'] = 'renderUIConfig';
293$tabhandler['ui']['edit'] = 'renderUIConfigEditForm';
294$tabhandler['ui']['reset'] = 'renderUIResetForm';
4fe32e78 295$ophandler['ui']['edit']['upd'] = 'updateUI';
b07f617c 296$ophandler['ui']['reset']['go'] = 'resetUIConfig';
e673ee24 297
931bf334
DO
298$page['tagtree']['title'] = 'Tag tree';
299$page['tagtree']['parent'] = 'config';
300$tab['tagtree']['default'] = 'View';
301$tab['tagtree']['edit'] = 'Change';
302$tabhandler['tagtree']['default'] = 'renderTagTree';
303$tabhandler['tagtree']['edit'] = 'renderTagTreeEditor';
304
eebf9145 305$page['reports']['title'] = 'Reports';
e673ee24
DO
306$page['reports']['parent'] = 'index';
307$tab['reports']['default'] = 'View';
8b6ffe9c 308$tabhandler['reports']['default'] = 'renderReportSummary';
e673ee24 309
eebf9145 310$page['help']['title'] = 'Help';
8b6ffe9c 311$page['help']['handler'] = 'renderHelpTab';
ae545907 312$page['help']['parent'] = 'index';
ae545907 313
e673ee24
DO
314// This function returns array if page numbers leading to the target page
315// plus page number of target page itself. The first element is the target
316// page number and the last element is the index page number.
317function getPath ($targetno)
318{
319 global $page;
320 $path = array();
321 // Recursion breaks at first parentless page.
322 if (!isset ($page[$targetno]['parent']))
323 $path = array ($targetno);
324 else
325 {
326 $path = getPath ($page[$targetno]['parent']);
327 $path[] = $targetno;
328 }
329 return $path;
330}
331
332function showPathAndSearch ($pageno)
333{
9c0b0016 334 global $root, $page;
e673ee24 335 // Path.
73635d32 336 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
eebf9145
DO
337 $path = getPath ($pageno);
338 foreach ($path as $no)
e673ee24 339 {
eebf9145
DO
340 $title['params'] = array();
341 if (isset ($page[$no]['title']))
342 $title['name'] = $page[$no]['title'];
343 elseif (isset ($page[$no]['title_handler']))
344 $title = $page[$no]['title_handler']($no);
345 else
346 $title['name'] = '[N/A]';
347 echo ": <a href='${root}?page=${no}";
348 foreach ($title['params'] as $param_name => $param_value)
349 echo "&${param_name}=${param_value}";
350 echo "'>" . $title['name'] . "</a>";
e673ee24
DO
351 }
352 echo "</td>";
353 // Search form.
354 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
355 echo "<form method=get action='${root}'><td>";
356 echo '<input type=hidden name=page value=search>';
357 // This input will be the first, if we don't add ports or addresses.
358 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
359}
360
361function getTitle ($pageno, $tabno)
362{
9c0b0016 363 global $page;
eebf9145
DO
364 if (isset ($page[$pageno]['title']))
365 return $page[$pageno]['title'];
366 elseif (isset ($page[$pageno]['title_handler']))
367 {
368 $tmp = $page[$pageno]['title_handler']($pageno);
369 return $tmp['name'];
370 }
371 else
9c0b0016 372 return getConfigVar ('enterprise');
e673ee24
DO
373}
374
375function showTabs ($pageno, $tabno)
376{
08b16bf5 377 global $tab, $root, $page, $remote_username, $trigger, $tabextraclass;
e673ee24
DO
378 if (!isset ($tab[$pageno]['default']))
379 return;
380 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
381 foreach ($tab[$pageno] as $tabidx => $tabtitle)
382 {
383 // Hide forbidden tabs.
384 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
385 continue;
641fe9b0
DO
386 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
387 if
388 (
389 isset ($trigger[$pageno][$tabidx]) &&
390 $trigger[$pageno][$tabidx] () != TRUE
391 )
392 continue;
08b16bf5
DO
393 $class = ($tabidx == $tabno) ? 'current' : 'std';
394 $extra = (isset ($tabextraclass[$pageno][$tabidx])) ? $tabextraclass[$pageno][$tabidx] : '';
395 echo "<li><a class=${class}{$extra}";
e673ee24
DO
396 echo " href='${root}?page=${pageno}&tab=${tabidx}";
397 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
398 {
399 $bpname = $page[$pageno]['bypass'];
400 $bpval = $_REQUEST[$bpname];
401 echo "&${bpname}=${bpval}";
402 }
403 echo "'>${tabtitle}</a></li>\n";
404 }
ae9a3784 405 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
406 echo "</ul></div></td>\n";
407}
408
409// This function returns pages, which are direct children of the requested
410// page and are accessible by the current user.
411function getDirectChildPages ($pageno)
412{
413 global $page, $remote_username;
414 $children = array();
415 foreach ($page as $cpageno => $cpage)
416 if
417 (
418 isset ($cpage['parent']) and
419 $cpage['parent'] == $pageno and
420 authorized ($remote_username, $cpageno, 'default') == TRUE
421 )
422 $children[$cpageno] = $cpage;
423 return $children;
424}
425
426function getAllChildPages ($parent)
427{
428 global $page;
429 // Array pointer is global, so if we don't create local copies of
430 // the global array, we can't advance any more after nested call
431 // of getAllChildPages returns.
432 $mypage = $page;
433 $mykids = array();
434 foreach ($mypage as $ctitle => $cpage)
435 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
436 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
437 return $mykids;
438}
439
440?>