r1421 + testing the new tabhandler array
[racktables] / inc / pagehandlers.php
CommitLineData
b325120a 1<?php
e673ee24
DO
2/*
3*
4* This file is a library of page handlers for RackTables.
5*
6*/
7
8// This function assures that specified argument was passed
9// and is a number greater than zero.
10function assertUIntArg ($argname, $allow_zero = FALSE)
11{
12 if (!isset ($_REQUEST[$argname]))
13 {
14 showError ("Parameter '${argname}' is missing.");
15 die();
16 }
17 if (!is_numeric ($_REQUEST[$argname]))
18 {
19 showError ("Parameter '${argname}' is not a number.");
20 die();
21 }
22 if ($_REQUEST[$argname] < 0)
23 {
24 showError ("Parameter '${argname}' is less than zero.");
25 die();
26 }
27 if (!$allow_zero and $_REQUEST[$argname] == 0)
28 {
29 showError ("Parameter '${argname}' is equal to zero.");
30 die();
31 }
32}
33
34// This function assures that specified argument was passed
35// and is a non-empty string.
36function assertStringArg ($argname, $ok_if_empty = FALSE)
37{
38 if (!isset ($_REQUEST[$argname]))
39 {
40 showError ("Parameter '${argname}' is missing.");
41 die();
42 }
43 if (!is_string ($_REQUEST[$argname]))
44 {
45 showError ("Parameter '${argname}' is not a string.");
46 die();
47 }
48 if (!$ok_if_empty and empty ($_REQUEST[$argname]))
49 {
50 showError ("Parameter '${argname}' is an empty string.");
51 die();
52 }
53}
54
55function assertBoolArg ($argname, $ok_if_empty = FALSE)
56{
57 if (!isset ($_REQUEST[$argname]))
58 {
59 showError ("Parameter '${argname}' is missing.");
60 die();
61 }
62 if (!is_string ($_REQUEST[$argname]) or $_REQUEST[$argname] != 'on')
63 {
64 showError ("Parameter '${argname}' is not a string.");
65 die();
66 }
67 if (!$ok_if_empty and empty ($_REQUEST[$argname]))
68 {
69 showError ("Parameter '${argname}' is an empty string.");
70 die();
71 }
72}
73
74function handler_row ($tabno)
75{
76 assertUIntArg ('row_id');
77 switch ($tabno)
78 {
79 case 'default':
80 renderRow ($_REQUEST['row_id']);
81 break;
82 case 'newrack':
83 renderNewRackForm ($_REQUEST['row_id']);
84 break;
85 default:
86 showError ("Invalid tab '${tabno}' requested in handler_row().");
87 }
88}
89
90function handler_rack ($tabno)
91{
92 assertUIntArg ('rack_id');
93 switch ($tabno)
94 {
95 case 'default':
96 // FIXME: add tab renderer instead of table generator
97 renderRackPage ($_REQUEST['rack_id']);
98 break;
99 case 'problems':
100 renderRackProblems ($_REQUEST['rack_id']);
101 break;
102 case 'design':
103 renderRackDesign ($_REQUEST['rack_id']);
104 break;
105 case 'edit':
106 renderEditRackForm ($_REQUEST['rack_id']);
107 break;
108 default:
109 showError ("Invalid tab '${tabno}' requested in handler_rack().");
110 }
111}
112
e673ee24
DO
113function handler_objects ($tabno)
114{
115 switch ($tabno)
116 {
117 case 'default':
118 renderObjectGroupSummary();
119 break;
120 case 'newobj':
121 renderNewObjectForm();
122 break;
123 case 'newmulti':
124 renderAddMultipleObjectsForm();
125 break;
126 default:
127 showError ("Invalid tab '${tabno}' requested in handler_objects().");
128 }
129}
130
131function handler_objgroup ()
132{
133 assertUIntArg ('group_id');
134 renderObjectGroup ($_REQUEST['group_id']);
135}
136
137function handler_rackspace ($tabno)
138{
139 switch ($tabno)
140 {
141 case 'default':
142 renderRackspace();
143 break;
144 case 'history':
145 renderRackspaceHistory ();
146 break;
9b0cf84f
DO
147 case 'firstrow':
148 renderFirstRowForm ();
149 break;
e673ee24
DO
150 default:
151 showError ("Invalid tab '${tabno}' requested in handler_rackspace().");
152 }
153}
154
155function handler_ipv4space ($tabno)
156{
157 switch ($tabno)
158 {
159 case 'default':
160 renderAddressspace();
161 break;
162 case 'newrange':
163 renderAddNewRange();
164 break;
165 default:
166 showError ("Invalid tab '${tabno}' requested in handler_ipv4space().");
167 }
168}
169
170function handler_iprange ($tabno)
171{
172 switch ($tabno)
173 {
174 case 'default':
175 renderIPRange();
176 break;
177 case 'properties':
178 renderIPRangeProperties();
179 break;
180 default:
181 showError ("Invalid tab '${tabno}' requested in handler_iprange().");
182 }
183}
184
185function handler_ipaddress ($tabno)
186{
187 switch ($tabno)
188 {
189 case 'default':
190 renderIPAddress();
191 break;
192 case 'properties':
193 renderIPAddressProperties();
194 break;
195 case 'assignment':
196 renderIPAddressAssignment();
197 break;
198 default:
199 showError ("Invalid tab '${tabno}' requested in handler_ipaddress().");
200 }
201}
202
203function handler_search ($tabno)
204{
205 renderSearchResults();
206}
207
208function handler_config ($tabno)
209{
210 switch ($tabno)
211 {
212 case 'default':
213 renderConfigMainpage();
214 break;
215 default:
216 showError ("Invalid tab '${tabno}' requested in handler_config().");
217 }
218}
219
220function handler_accounts ($tabno)
221{
222 switch ($tabno)
223 {
224 case 'default':
225 renderAccounts();
226 break;
227 case 'edit':
228 renderAccountsEditForm();
229 break;
230 default:
231 showError ("Invalid tab '${tabno}' requested in handler_accounts().");
232 }
233}
234
235function handler_perms ($tabno)
236{
237 switch ($tabno)
238 {
239 case 'default':
240 renderPermissions();
241 break;
242 case 'edit':
243 renderPermissionsEditForm();
244 break;
245 default:
246 showError ("Invalid tab '${tabno}' requested in handler_perms().");
247 }
248}
249
e673ee24
DO
250function handler_ui ($tabno)
251{
252 switch ($tabno)
253 {
254 case 'default':
255 renderUIConfig();
256 break;
4fe32e78
DY
257 case 'edit':
258 renderUIConfigEditForm();
259 break;
b07f617c
DO
260 case 'reset':
261 renderUIResetForm();
262 break;
e673ee24
DO
263 default:
264 showError ("Invalid tab '${tabno}' requested in handler_ui().");
265 }
266}
267
268function handler_portmap ($tabno)
269{
270 switch ($tabno)
271 {
272 case 'default':
273 renderPortMap (FALSE);
274 break;
275 case 'edit':
276 renderPortMap (TRUE);
277 break;
278 default:
279 showError ("Invalid tab '${tabno}' requested in handler_portmap().");
280 }
281}
282
283function handler_dict ($tabno)
284{
285 switch ($tabno)
286 {
287 case 'default':
288 renderDictionary();
289 break;
290 case 'edit':
291 renderDictionaryEditor();
292 break;
293 case 'chapters':
294 renderChaptersEditor();
295 break;
296 default:
297 showError ("Invalid tab '${tabno}' requested in handler_dict().");
298 }
299}
300
301function handler_attrs ($tabno)
302{
303 switch ($tabno)
304 {
305 case 'default':
306 renderAttributes();
307 break;
308 case 'editattrs':
309 renderEditAttributesForm ();
310 break;
311 case 'editmap':
312 renderEditAttrMapForm ();
313 break;
314 default:
315 showError ("Invalid tab '${tabno}' requested in handler_attrs().");
316 }
317}
318
319function handler_reports ($tabno)
320{
321 switch ($tabno)
322 {
323 case 'default':
324 renderReportSummary();
325 break;
326 default:
327 showError ("Invalid tab '${tabno}' requested in handler_reports().");
328 }
329}
330
ae545907
DO
331function handler_help ($tabno)
332{
e3758526 333 renderHelpTab ($tabno);
ae545907
DO
334}
335
e673ee24 336?>