Bad things are now 'classified' as bad (CSS class 'bad' is being used instead of...
[mailer.git] / inc / callback-functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/08/2011 *
4  * ===================                          Last change: 07/08/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : callback-functions.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Call-back functions for XML templates            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Call-Back-Funktionen fuer XML-Templates          *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Handles the XML node 'admin-entry-meta-data'
44 function doXmlAdminEntryMetaData ($resource, $attributes) {
45         // There should be no attributes
46         if (count($attributes) > 0) {
47                 // Please don't add any attributes to foo-list nodes
48                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
49         } // END - if
50 }
51
52 // Handles the XML node 'callback-function'
53 function doXmlCallbackFunction ($resource, $attributes) {
54         // There are two attributes, by default
55         if (count($attributes) != 2) {
56                 // Not the right count
57                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 2 attributes, got ' . count($attributes));
58         } elseif (!isset($attributes['TYPE'])) {
59                 // 'TYPE' not found
60                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
61         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
62                 // No valid type
63                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
64         } elseif (!isset($attributes['VALUE'])) {
65                 // 'VALUE' not found
66                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
67         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
68                 // Not valid/verifyable
69                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
70         }
71
72         // Add the function name and no attributes by default
73         $GLOBALS['__XML_CALLBACKS']['callbacks'][] = __FUNCTION__;
74         $GLOBALS['__XML_CALLBACKS']['functions'][__FUNCTION__][] = $attributes['VALUE'];
75         $GLOBALS['__XML_ARGUMENTS'][__FUNCTION__] = array();
76 }
77
78 // Handles the XML node 'database-table'
79 function doXmlDatabaseTable ($resource, $attributes) {
80         // There are three attributes, by default
81         if (count($attributes) != 3) {
82                 // Not the right count
83                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
84         } elseif (!isset($attributes['NAME'])) {
85                 // 'NAME' not found
86                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
87         } elseif (!isset($attributes['TYPE'])) {
88                 // 'TYPE' not found
89                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
90         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
91                 // No valid type
92                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
93         } elseif (!isset($attributes['VALUE'])) {
94                 // 'VALUE' not found
95                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
96         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
97                 // Not valid/verifyable
98                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
99         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
100                 // doXmlCallbackFunction is missing
101                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
102         }
103
104         // Add the entry to the list
105         addXmlValueToCallbackAttributes('database_table', $attributes);
106         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['database_table'] = $attributes['VALUE'];
107 }
108
109 // Handles the XML node 'database-column-list'
110 function doXmlDatabaseColumnList ($resource, $attributes) {
111         // There should be no attributes
112         if (count($attributes) > 0) {
113                 // Please don't add any attributes to foo-list nodes
114                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
115         } // END - if
116
117         // Add an empty list
118         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_list'] = array();
119 }
120
121 // Handles the XML node 'database-column-list-entry'
122 function doXmlDatabaseColumnListEntry ($resource, $attributes) {
123         // There are three attributes, by default
124         if (count($attributes) != 6) {
125                 // Not the right count
126                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 6 attributes, got ' . count($attributes));
127         } elseif (!isset($attributes['NAME'])) {
128                 // 'NAME' not found
129                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
130         } elseif (!isset($attributes['TYPE'])) {
131                 // 'TYPE' not found
132                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
133         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
134                 // No valid type
135                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
136         } elseif (!isset($attributes['TABLE'])) {
137                 // 'TABLE' not found
138                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
139         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE'])) {
140                 // Not valid/verifyable
141                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TYPE=' . $attributes['TYPE'] . ',TABLE=' . $attributes['TABLE']);
142         } elseif (!isset($attributes['ALIAS'])) {
143                 // 'ALIAS' not found
144                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ALIAS not found.');
145         } elseif (!isset($attributes['FUNCTION'])) {
146                 // 'FUNCTION' not found
147                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute FUNCTION not found.');
148         } elseif ((trim($attributes['ALIAS']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['ALIAS']))) {
149                 // 'ALIAS' not valid/verifyable
150                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ALIAS does not validate. ALIAS=' . $attributes['ALIAS']);
151         } elseif ((trim($attributes['FUNCTION']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['FUNCTION']))) {
152                 // 'FUNCTION' not valid/verifyable
153                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute FUNCTION does not validate. FUNCTION=' . $attributes['FUNCTION']);
154         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_list'])) {
155                 // doXmlCallbackFunction is missing
156                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/database-column-list not included around this node. Please fix your XML.');
157         }
158
159         // Add the entry to the list
160         addXmlValueToCallbackAttributes('column_list', $attributes);
161 }
162
163 // Handles the XML node 'callback-function-list'
164 function doXmlCallbackFunctionList ($resource, $attributes) {
165         // There should be no attributes
166         if (count($attributes) > 0) {
167                 // Please don't add any attributes to foo-list nodes
168                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
169         } // END - if
170
171         // Add an empty list
172         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['callback_list'] = array();
173 }
174
175 // Handles the XML node 'callback-function-list-entry'
176 function doXmlCallbackFunctionListEntry ($resource, $attributes) {
177         // There are three attributes, by default
178         if (count($attributes) != 3) {
179                 // Not the right count
180                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
181         } elseif (!isset($attributes['NAME'])) {
182                 // 'NAME' not found
183                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
184         } elseif (!isset($attributes['TYPE'])) {
185                 // 'TYPE' not found
186                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
187         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
188                 // No valid type
189                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
190         } elseif (!isset($attributes['VALUE'])) {
191                 // 'VALUE' not found
192                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
193         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
194                 // Not valid/verifyable
195                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
196         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['callback_list'])) {
197                 // doXmlCallbackFunction is missing
198                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/callback-function-list not included around this node. Please fix your XML.');
199         }
200
201         // Add the entry to the list
202         addXmlValueToCallbackAttributes('callback_list', $attributes);
203 }
204
205 // Handles the XML node 'extra-parameter-list'
206 function doXmlExtraParameterList ($resource, $attributes) {
207         // There should be no attributes
208         if (count($attributes) > 0) {
209                 // Please don't add any attributes to foo-list nodes
210                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
211         } // END - if
212
213         // Add an empty list
214         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list'] = array();
215 }
216
217 // Handles the XML node 'extra-parameter-list-entry'
218 function doXmlExtraParameterListEntry ($resource, $attributes) {
219         // There are three attributes, by default
220         if (count($attributes) != 3) {
221                 // Not the right count
222                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
223         } elseif (!isset($attributes['NAME'])) {
224                 // 'NAME' not found
225                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
226         } elseif (!isset($attributes['TYPE'])) {
227                 // 'TYPE' not found
228                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
229         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
230                 // No valid type
231                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
232         } elseif (!isset($attributes['VALUE'])) {
233                 // 'VALUE' not found
234                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
235         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
236                 // Not valid/verifyable
237                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
238         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list'])) {
239                 // doXmlCallbackFunction is missing
240                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list not included around this node. Please fix your XML.');
241         }
242
243         // Add the entry to the list
244         addXmlValueToCallbackAttributes('extra_list', $attributes);
245 }
246
247 // Handles the XML node 'extra-parameter-member-list'
248 function doXmlExtraParameterMemberList ($resource, $attributes) {
249         // There should be no attributes
250         if (count($attributes) > 0) {
251                 // Please don't add any attributes to foo-list nodes
252                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
253         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['member_list'])) {
254                 // This list should be created already
255                 debug_report_bug(__FUNCTION__, __LINE__, 'member_list should be already created.');
256         }
257 }
258
259 // Handles the XML node 'extra-parameter-member-list-entry'
260 function doXmlExtraParameterMemberListEntry ($resource, $attributes) {
261         // There are three attributes, by default
262         if (count($attributes) != 3) {
263                 // Not the right count
264                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
265         } elseif (!isset($attributes['NAME'])) {
266                 // 'NAME' not found
267                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
268         } elseif (!isset($attributes['TYPE'])) {
269                 // 'TYPE' not found
270                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
271         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
272                 // No valid type
273                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
274         } elseif (!isset($attributes['VALUE'])) {
275                 // 'VALUE' not found
276                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
277         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
278                 // Not valid/verifyable
279                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
280         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['member_list'])) {
281                 // doXmlCallbackFunction is missing
282                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.');
283         }
284
285         // Add the entry to the list
286         addXmlValueToCallbackAttributes('extra_list', $attributes, 'member_list');
287 }
288
289 // Handles the XML node 'extra-parameter-added-list'
290 function doXmlExtraParameterAddedList ($resource, $attributes) {
291         // There should be no attributes
292         if (count($attributes) > 0) {
293                 // Please don't add any attributes to foo-list nodes
294                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
295         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['added_list'])) {
296                 // This list should be created already
297                 debug_report_bug(__FUNCTION__, __LINE__, 'added_list should be already created.');
298         }
299 }
300
301 // Handles the XML node 'extra-parameter-added-list-entry'
302 function doXmlExtraParameterAddedListEntry ($resource, $attributes) {
303         // There are three attributes, by default
304         if (count($attributes) != 3) {
305                 // Not the right count
306                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
307         } elseif (!isset($attributes['NAME'])) {
308                 // 'NAME' not found
309                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
310         } elseif (!isset($attributes['TYPE'])) {
311                 // 'TYPE' not found
312                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
313         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
314                 // No valid type
315                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
316         } elseif (!isset($attributes['VALUE'])) {
317                 // 'VALUE' not found
318                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
319         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
320                 // Not valid/verifyable
321                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
322         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['added_list'])) {
323                 // doXmlCallbackFunction is missing
324                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list/added-list not included around this node. Please fix your XML.');
325         }
326
327         // Add the entry to the list
328         addXmlValueToCallbackAttributes('extra_list', $attributes, 'added_list');
329 }
330
331 // Handles the XML node 'status-change-column'
332 function doXmlStatusChangeColumn ($resource, $attributes) {
333         // There are three attributes, by default
334         if (count($attributes) != 3) {
335                 // Not the right count
336                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
337         } elseif (!isset($attributes['NAME'])) {
338                 // 'NAME' not found
339                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
340         } elseif (!isset($attributes['TYPE'])) {
341                 // 'TYPE' not found
342                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
343         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
344                 // No valid type
345                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
346         } elseif (!isset($attributes['VALUE'])) {
347                 // 'VALUE' not found
348                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
349         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
350                 // Not valid/verifyable
351                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
352         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
353                 // doXmlCallbackFunction is missing
354                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
355         }
356
357         // Add the entry to the list
358         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['status_list'][$attributes['VALUE']] = array();
359 }
360
361 // Handles the XML node 'status-change-list'
362 function doXmlStatusChangeList ($resource, $attributes) {
363         // There should be no attributes
364         if (count($attributes) > 0) {
365                 // Please don't add any attributes to foo-list nodes
366                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
367         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['status_list'])) {
368                 // doXmlCallbackFunction is missing
369                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/status-list not included around this node. Please fix your XML.');
370         }
371 }
372
373 // Handles the XML node 'status-change-list-entry'
374 function doXmlStatusChangeListEntry ($resource, $attributes) {
375         // There are for attributes, by default
376         if (count($attributes) != 4) {
377                 // Not the right count
378                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 4 attributes, got ' . count($attributes));
379         } elseif (!isset($attributes['NAME'])) {
380                 // 'NAME' not found
381                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
382         } elseif (!isset($attributes['TYPE'])) {
383                 // 'TYPE' not found
384                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
385         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
386                 // No valid type
387                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
388         } elseif (!isset($attributes['VALUE'])) {
389                 // 'VALUE' not found
390                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
391         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['OLD'])) {
392                 // Not valid/verifyable
393                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute OLD does not validate. TYPE=' . $attributes['TYPE'] . ',OLD=' . $attributes['OLD']);
394         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
395                 // Not valid/verifyable
396                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
397         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['status_list'])) {
398                 // doXmlCallbackFunction is missing
399                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list/change-list not included around this node. Please fix your XML.');
400         }
401
402         // Add the entry to the list
403         addXmlValueToCallbackAttributes('status_list', $attributes, $attributes['NAME'], 'OLD');
404 }
405
406 // Handles the XML node 'enable-modify-entries'
407 function doXmlEnableModifyEntries ($resource, $attributes) {
408         // There are three attributes, by default
409         if (count($attributes) != 3) {
410                 // Not the right count
411                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
412         } elseif (!isset($attributes['NAME'])) {
413                 // 'NAME' not found
414                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
415         } elseif (!isset($attributes['TYPE'])) {
416                 // 'TYPE' not found
417                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
418         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
419                 // No valid type
420                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
421         } elseif (!isset($attributes['VALUE'])) {
422                 // 'VALUE' not found
423                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
424         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
425                 // Not valid/verifyable
426                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
427         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
428                 // doXmlCallbackFunction is missing
429                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
430         }
431
432         // Add the entry to the list
433         addXmlValueToCallbackAttributes('enable_modify_entries', $attributes);
434         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['enable_modify_entries'] = convertStringToBoolean($attributes['VALUE']);
435 }
436
437 // Handles the XML node 'table-id-column'
438 function doXmlTableIdColumn ($resource, $attributes) {
439         // There are three attributes, by default
440         if (count($attributes) != 3) {
441                 // Not the right count
442                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
443         } elseif (!isset($attributes['NAME'])) {
444                 // 'NAME' not found
445                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
446         } elseif (!isset($attributes['TYPE'])) {
447                 // 'TYPE' not found
448                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
449         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
450                 // No valid type
451                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
452         } elseif (!isset($attributes['VALUE'])) {
453                 // 'VALUE' not found
454                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
455         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
456                 // Not valid/verifyable
457                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
458         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
459                 // doXmlCallbackFunction is missing
460                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
461         }
462
463         // Add the entry to the array
464         addXmlValueToCallbackAttributes('table_id_column', $attributes);
465         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['table_id_column'] = $attributes['VALUE'];
466 }
467
468 // Handles the XML node 'table-userid-column'
469 function doXmlTableUseridColumn ($resource, $attributes) {
470         // There are three attributes, by default
471         if (count($attributes) != 3) {
472                 // Not the right count
473                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
474         } elseif (!isset($attributes['NAME'])) {
475                 // 'NAME' not found
476                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
477         } elseif (!isset($attributes['TYPE'])) {
478                 // 'TYPE' not found
479                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
480         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
481                 // No valid type
482                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
483         } elseif (!isset($attributes['VALUE'])) {
484                 // 'VALUE' not found
485                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
486         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
487                 // Not valid/verifyable
488                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
489         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
490                 // doXmlCallbackFunction is missing
491                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
492         }
493
494         // Add the entry to the array
495         addXmlValueToCallbackAttributes('table_userid_column', $attributes);
496         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['table_userid_column'] = $attributes['VALUE'];
497 }
498
499 // Handles the XML node 'raw-userid-column-key'
500 function doXmlRawUseridColumnKey ($resource, $attributes) {
501         // There are three attributes, by default
502         if (count($attributes) != 3) {
503                 // Not the right count
504                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
505         } elseif (!isset($attributes['NAME'])) {
506                 // 'NAME' not found
507                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
508         } elseif (!isset($attributes['TYPE'])) {
509                 // 'TYPE' not found
510                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
511         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
512                 // No valid type
513                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
514         } elseif (!isset($attributes['VALUE'])) {
515                 // 'VALUE' not found
516                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
517         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
518                 // Not valid/verifyable
519                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
520         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
521                 // doXmlCallbackFunction is missing
522                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
523         }
524
525         // Add the entry to the array
526         addXmlValueToCallbackAttributes('raw_userid_column_key', $attributes);
527         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['raw_userid_column_key'] = $attributes['VALUE'];
528 }
529
530 //-----------------------------------------------------------------------------
531 //           Call-back functions for listing of data in admin area
532 //-----------------------------------------------------------------------------
533
534 // Handles the XML node 'admin-list-data'
535 function doXmlAdminListData ($resource, $attributes) {
536         // There should be no attributes
537         if (count($attributes) > 0) {
538                 // Please don't add any attributes to foo-list nodes
539                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
540         } // END - if
541 }
542
543 // Handles the XML node 'data-tables'
544 function doXmlDataTables ($resource, $attributes) {
545         // There should be no attributes
546         if (count($attributes) > 0) {
547                 // Please don't add any attributes to foo-list nodes
548                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
549         } // END - if
550 }
551
552 // Handles the XML node 'data-table'
553 function doXmlDataTable ($resource, $attributes) {
554         // There are three attributes, by default
555         if (count($attributes) != 3) {
556                 // Not the right count
557                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
558         } elseif (!isset($attributes['VALUE'])) {
559                 // 'VALUE' not found
560                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
561         } elseif (!isset($attributes['TYPE'])) {
562                 // 'TYPE' not found
563                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
564         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
565                 // No valid type
566                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
567         } elseif (!isset($attributes['ALIAS'])) {
568                 // 'ALIAS' not found
569                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ALIAS not found.');
570         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
571                 // Not valid/verifyable
572                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
573         } elseif ((trim($attributes['ALIAS']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['ALIAS']))) {
574                 // Not valid/verifyable
575                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. ALIAS=' . $attributes['ALIAS']);
576         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
577                 // doXmlCallbackFunction is missing
578                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
579         }
580
581         // Add the entry to the array
582         addXmlValueToCallbackAttributes('data_table', $attributes);
583 }
584
585 // Handles the XML node 'select-data-from-list'
586 function doXmlSelectDataFromList ($resource, $attributes) {
587         // There should be no attributes
588         if (count($attributes) > 0) {
589                 // Please don't add any attributes to foo-list nodes
590                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
591         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
592                 // doXmlCallbackFunction is missing
593                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
594         }
595
596         // Add an empty list
597         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'] = array();
598 }
599
600 // Handles the XML node 'select-data-from-list-entry'
601 function doXmlSelectDataFromListEntry ($resource, $attributes) {
602         // There are five attributes, by default
603         if (count($attributes) != 5) {
604                 // Not the right count
605                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
606         } elseif (!isset($attributes['VALUE'])) {
607                 // 'VALUE' not found
608                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
609         } elseif (!isset($attributes['TYPE'])) {
610                 // 'TYPE' not found
611                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
612         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
613                 // No valid type
614                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
615         } elseif (!isset($attributes['ALIAS'])) {
616                 // 'ALIAS' not found
617                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ALIAS not found.');
618         } elseif (!isset($attributes['FUNCTION'])) {
619                 // 'FUNCTION' not found
620                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute FUNCTION not found.');
621         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
622                 // 'VALUE' not valid/verifyable
623                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
624         } elseif ((trim($attributes['ALIAS']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['ALIAS']))) {
625                 // 'ALIAS' not valid/verifyable
626                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ALIAS does not validate. ALIAS=' . $attributes['ALIAS']);
627         } elseif ((trim($attributes['FUNCTION']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['FUNCTION']))) {
628                 // 'FUNCTION' not valid/verifyable
629                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute FUNCTION does not validate. FUNCTION=' . $attributes['FUNCTION']);
630         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
631                 // doXmlCallbackFunction is missing
632                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/select-data-from-list not included around this node. Please fix your XML.');
633         }
634
635         // Add the entry to the array
636         addXmlValueToCallbackAttributes('data_column_list', $attributes);
637 }
638
639 // Handles the XML node 'where-select-from-list'
640 function doXmlWhereSelectFromList ($resource, $attributes) {
641         // There should be no attributes
642         if (count($attributes) > 0) {
643                 // Please don't add any attributes to foo-list nodes
644                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
645         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
646                 // doXmlCallbackFunction is missing
647                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
648         }
649
650         // Add an empty list
651         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['where_select_list'] = array();
652 }
653
654 // Handles the XML node 'where-select-from-list-entry'
655 function doXmlWhereSelectFromListEntry ($resource, $attributes) {
656         // There are five attributes, by default
657         if (count($attributes) != 5) {
658                 // Not the right count
659                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
660         } elseif (!isset($attributes['TYPE'])) {
661                 // 'TYPE' not found
662                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
663         } elseif (!isset($attributes['TABLE'])) {
664                 // 'TABLE' not found
665                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
666         } elseif (!isset($attributes['VALUE'])) {
667                 // 'VALUE' not found
668                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
669         } elseif (!isset($attributes['CONDITION'])) {
670                 // 'CONDITION' not found
671                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute CONDITION not found.');
672         } elseif (!isset($attributes['LOOK-FOR'])) {
673                 // 'LOOK-FOR' not found
674                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute LOOK-FOR not found.');
675         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
676                 // No valid type
677                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
678         } elseif ((trim($attributes['TABLE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE']))) {
679                 // 'TABLE' not valid/verifyable
680                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TABLE=' . $attributes['TABLE']);
681         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
682                 // 'VALUE' not valid/verifyable
683                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
684         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['CONDITION'])) {
685                 // 'CONDITION' not valid/verifyable
686                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION does not validate. CONDITION=' . $attributes['CONDITION']);
687         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['LOOK-FOR'])) {
688                 // 'LOOK-FOR' not valid/verifyable
689                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute LOOK-FOR does not validate. LOOK-FOR=' . $attributes['LOOK-FOR']);
690         } elseif (!isXmlConditionValid($attributes['CONDITION'])) {
691                 // 'CONDITION' is not known
692                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION is not valid. LOOK-FOR=' . $attributes['CONDITION']);
693         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
694                 // doXmlCallbackFunction is missing
695                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-column-list not included around this node. Please fix your XML.');
696         }
697
698         // Add the entry to the array
699         addXmlValueToCallbackAttributes('where_select_list', $attributes);
700 }
701
702 // Handles the XML node 'order-by-list'
703 function doXmlOrderByList ($resource, $attributes) {
704         // There should be no attributes
705         if (count($attributes) > 0) {
706                 // Please don't add any attributes to foo-list nodes
707                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
708         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
709                 // doXmlCallbackFunction is missing
710                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
711         }
712
713         // Add an empty list
714         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['order_by_list'] = array();
715 }
716
717 // Handles the XML node 'order-by-list-entry'
718 function doXmlOrderByListEntry ($resource, $attributes) {
719         // There are four attributes, by default
720         if (count($attributes) != 4) {
721                 // Not the right count
722                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
723         } elseif (!isset($attributes['ORDER'])) {
724                 // 'ORDER' not found
725                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ORDER not found.');
726         } elseif (!isset($attributes['TYPE'])) {
727                 // 'TYPE' not found
728                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
729         } elseif (!isset($attributes['TABLE'])) {
730                 // 'TABLE' not found
731                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
732         } elseif (!isset($attributes['VALUE'])) {
733                 // 'VALUE' not found
734                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
735         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
736                 // No valid type
737                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
738         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['ORDER'])) {
739                 // 'ORDER' not valid/verifyable
740                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ORDER does not validate. ORDER=' . $attributes['ORDER']);
741         } elseif ((trim($attributes['TABLE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE']))) {
742                 // 'TABLE' not valid/verifyable
743                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TABLE=' . $attributes['TABLE']);
744         } elseif ((trim($attributes['VALUE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE']))) {
745                 // 'VALUE' not valid/verifyable
746                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
747         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
748                 // doXmlCallbackFunction is missing
749                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-column-list not included around this node. Please fix your XML.');
750         }
751
752         // Add the entry to the array
753         addXmlValueToCallbackAttributes('order_by_list', $attributes);
754 }
755
756 // Handles the XML node 'list-template'
757 function doXmlListTemplate ($resource, $attributes) {
758         // There are two attributes, by default
759         if (count($attributes) != 2) {
760                 // Not the right count
761                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
762         } elseif (!isset($attributes['VALUE'])) {
763                 // 'VALUE' not found
764                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
765         } elseif (!isset($attributes['TYPE'])) {
766                 // 'TYPE' not found
767                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
768         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
769                 // No valid type
770                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
771         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
772                 // Not valid/verifyable
773                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
774         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
775                 // doXmlCallbackFunction is missing
776                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
777         }
778
779         // Add the entry to the array
780         addXmlValueToCallbackAttributes('list_template', $attributes);
781 }
782
783 // Handles the XML node 'list-row-template'
784 function doXmlListRowTemplate ($resource, $attributes) {
785         // There are two attributes, by default
786         if (count($attributes) != 2) {
787                 // Not the right count
788                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
789         } elseif (!isset($attributes['VALUE'])) {
790                 // 'VALUE' not found
791                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
792         } elseif (!isset($attributes['TYPE'])) {
793                 // 'TYPE' not found
794                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
795         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
796                 // No valid type
797                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
798         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
799                 // Not valid/verifyable
800                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
801         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
802                 // doXmlCallbackFunction is missing
803                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
804         }
805
806         // Add the entry to the array
807         addXmlValueToCallbackAttributes('list_row_template', $attributes);
808 }
809
810 // Handles the XML node 'column-callback-list'
811 function doXmlColumnCallbackList ($resource, $attributes) {
812         // There should be no attributes
813         if (count($attributes) > 0) {
814                 // Please don't add any attributes to foo-list nodes
815                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
816         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
817                 // doXmlCallbackFunction is missing
818                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
819         }
820
821         // Add an empty list
822         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'] = array();
823 }
824
825 // Handles the XML node 'column-callback-list-entry'
826 function doXmlColumnCallbackListEntry ($resource, $attributes) {
827         // There should be no attributes
828         if (count($attributes) > 0) {
829                 // Please don't add any attributes to foo-list nodes
830                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
831         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'])) {
832                 // doXmlCallbackFunction is missing
833                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/column-callback not included around this node. Please fix your XML.');
834         }
835 }
836
837 // Handles the XML node 'column-callback-data'
838 function doXmlColumnCallbackData ($resource, $attributes) {
839         // There are three attributes, by default
840         if (count($attributes) != 3) {
841                 // Not the right count
842                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
843         } elseif (!isset($attributes['VALUE'])) {
844                 // 'VALUE' not found
845                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
846         } elseif (!isset($attributes['TYPE'])) {
847                 // 'TYPE' not found
848                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
849         } elseif (!isset($attributes['CALLBACK'])) {
850                 // 'CALLBACK' not found
851                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute CALLBACK not found.');
852         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
853                 // No valid type
854                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
855         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
856                 // Not valid/verifyable
857                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
858         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
859                 // doXmlCallbackFunction is missing
860                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
861         } elseif ((trim($attributes['CALLBACK']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['CALLBACK']))) {
862                 // 'CALLBACK' not valid/verifyable
863                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CALLBACK does not validate. CALLBACK=' . $attributes['CALLBACK']);
864         }
865
866         // Add the entry to the array
867         addXmlValueToCallbackAttributes('column_callback_list', $attributes);
868 }
869
870 // Handles the XML node 'callback-extra-parameter-list'
871 function doXmlCallbackExtraParameterList ($resource, $attributes) {
872         // There should be no attributes
873         if (count($attributes) > 0) {
874                 // Please don't add any attributes to foo-list nodes
875                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 1 attributes because this is a named foo-list node, got ' . count($attributes));
876         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'])) {
877                 // doXmlCallbackFunction is missing
878                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/column-callback-list not included around this node. Please fix your XML.');
879         } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'])) {
880                 // Abort silently here, no one wants to kill this array
881                 return;
882         }
883
884         // Add an empty list
885         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'] = array();
886 }
887
888 // Handles the XML node 'callback-extra-parameter-list-entry'
889 function doXmlCallbackExtraParameterListEntry ($resource, $attributes) {
890         // There are three attributes, by default
891         if (count($attributes) != 3) {
892                 // Not the right count
893                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
894         } elseif (!isset($attributes['COLUMN'])) {
895                 // 'COLUMN' not found
896                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute COLUMN not found.');
897         } elseif (!isset($attributes['TYPE'])) {
898                 // 'TYPE' not found
899                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
900         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
901                 // No valid type
902                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
903         } elseif (!isset($attributes['VALUE'])) {
904                 // 'VALUE' not found
905                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
906         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
907                 // 'VALUE' not valid/verifyable
908                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
909         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'])) {
910                 // doXmlCallbackFunction is missing
911                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/__EXTRA_PARAMETER not included around this node. Please fix your XML.');
912         }
913
914         // Add the entry to the array
915         addXmlValueToCallbackAttributes('__EXTRA_PARAMETER', $attributes);
916 }
917
918 // Handles the XML node 'no-entry-found-message'
919 function doXmlNoEntryFoundMessage ($resource, $attributes) {
920         // There are two attributes, by default
921         if (count($attributes) != 2) {
922                 // Not the right count
923                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
924         } elseif (!isset($attributes['VALUE'])) {
925                 // 'VALUE' not found
926                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
927         } elseif (!isset($attributes['TYPE'])) {
928                 // 'TYPE' not found
929                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
930         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
931                 // No valid type
932                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
933         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
934                 // Not valid/verifyable
935                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
936         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
937                 // doXmlCallbackFunction is missing
938                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
939         }
940
941         // Add the entry to the array
942         addXmlValueToCallbackAttributes('no_entry_message_id', $attributes);
943 }
944
945 //-----------------------------------------------------------------------------
946 //                              XML type validation
947 //-----------------------------------------------------------------------------
948
949 // Checks for string without any added extra data
950 function isXmlTypeString ($value) {
951         // Just let SQL_ESCAPE() do the job
952         return ($value == SQL_ESCAPE($value));
953 }
954
955 // Fake-check for array type
956 function isXmlTypeArray ($value) {
957         // This value is always a string
958         return (is_string($value));
959 }
960
961 // Check for boolean type
962 function isXmlTypeBool ($value) {
963         // Trim value
964         $value = trim($value);
965
966         // This value is always a string
967         return (($value == 'true') || ($value == 'false'));
968 }
969
970 // Check for integer type
971 function isXmlTypeInt ($value) {
972         // Trim value
973         $value = trim($value);
974
975         // This value is always a string
976         return (bigintval($value) == $value);
977 }
978
979 // Check for callback type
980 function isXmlTypeCallback ($value) {
981         // Trim value
982         $value = trim($value);
983
984         // This value is always a string
985         return (function_exists($value));
986 }
987
988 //-----------------------------------------------------------------------------
989 //                               Private XML functions
990 //-----------------------------------------------------------------------------
991
992 // Adds given attribut to element
993 function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '', $key = '') {
994         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',key=' . $key . ' - ENTERED!');
995         // Is it boolean type?
996         if (($attributes['TYPE'] == 'bool') && (isset($attributes['VALUE']))) {
997                 // Then convert VALUE
998                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=' . $attributes['TYPE'] . ',element=' . $element . ' - CONVERTING!');
999                 $attributes['VALUE'] = convertStringToBoolean($attributes['VALUE']);
1000         } elseif ($attributes['TYPE'] == 'callback') {
1001                 // It is a simple call-back type
1002                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=' . $attributes['TYPE'] . ',element=' . $element . ' - CALLING!');
1003                 $attributes['VALUE'] = call_user_func($attributes['VALUE']);
1004         }
1005
1006         // What do we need to add?
1007         if ($attributes['TYPE'] == 'array') {
1008                 // Another nested array
1009                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=' . $attributes['TYPE'] . ',element=' . $element);
1010                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['VALUE'] . '_list'] = array();
1011         } elseif (!empty($extraKey)) {
1012                 // Sub-array (one level only)
1013                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ' - ANALYSING...');
1014                 if (trim($attributes['NAME']) == '') {
1015                         // Numerical index
1016                         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
1017                         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][] = $attributes['VALUE'];
1018                 } elseif (!empty($key)) {
1019                         // Use from $key
1020                         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
1021                         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes[$key]] = $attributes['VALUE'];
1022                 } else {
1023                         // Use from NAME
1024                         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (NAME=' . $attributes['NAME'] . ')');
1025                         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes['NAME']] = $attributes['VALUE'];
1026                 }
1027         } elseif ((isset($attributes['FUNCTION'])) && (isset($attributes['ALIAS']))) {
1028                 /*
1029                  * ALIAS and FUNCTION detected? This may happen with SQL queries
1030                  * like: UNIX_TIMESTAMP(`foo_timestamp`) AS `foo_timestamp`
1031                  */
1032
1033                 // Fix missing 'NAME'
1034                 if (!isset($attributes['NAME'])) {
1035                         $attributes['NAME'] = '';
1036                 } // END - if
1037
1038                 // Init array
1039                 $array =  array(
1040                         'column'   => trim($attributes['VALUE']),
1041                         'alias'    => trim($attributes['ALIAS']),
1042                         'function' => trim($attributes['FUNCTION']),
1043                         'table'    => trim($attributes['TABLE']),
1044                         'name'     => trim($attributes['NAME'])
1045                 );
1046
1047                 // Add the entry
1048                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',ALIAS[' . gettype($attributes['ALIAS']) . ']=' . $attributes['ALIAS'] . ',FUNCTION[' . gettype($attributes['FUNCTION']) . ']=' . $attributes['FUNCTION'] . ' - FUNCTION! (VALUE=' . $attributes['VALUE'] . ')');
1049                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
1050         } elseif ((isset($attributes['CONDITION'])) && (isset($attributes['LOOK-FOR']))) {
1051                 // CONDITION/LOOK-FOR detected
1052                 // Init array
1053                 $array =  array(
1054                         'column'    => trim($attributes['VALUE']),
1055                         'table'     => trim($attributes['TABLE']),
1056                         'condition' => convertXmlContion(trim($attributes['CONDITION'])),
1057                         'look_for'  => trim($attributes['LOOK-FOR'])
1058                 );
1059
1060                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',CONDITION[' . gettype($attributes['CONDITION']) . ']=' . $attributes['CONDITION'] . ',LOOK-FOR[' . gettype($attributes['LOOK-FOR']) . ']=' . $attributes['LOOK-FOR'] . ' - CONDITION! (VALUE=' . $attributes['VALUE'] . ')');
1061                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
1062         } elseif (isset($attributes['CALLBACK'])) {
1063                 // CALLBACK/VALUE detected
1064                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',CALLBACK[' . gettype($attributes['CALLBACK']) . ']=' . $attributes['CALLBACK'] . ' - CALLBACK! (VALUE=' . $attributes['VALUE'] . ')');
1065                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['VALUE']] = $attributes['CALLBACK'];
1066         } elseif (isset($attributes['ORDER'])) {
1067                 // ORDER/TABLE detected
1068                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',ORDER[' . gettype($attributes['ORDER']) . ']=' . $attributes['ORDER'] . ' - ORDER! (VALUE=' . $attributes['VALUE'] . ')');
1069                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['ORDER']][$attributes['TABLE']] = $attributes['VALUE'];
1070         } elseif (isset($attributes['COLUMN'])) {
1071                 // COLUMN/VALUE detected
1072                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ',COLUMN[' . gettype($attributes['COLUMN']) . ']=' . $attributes['COLUMN'] . ' - COLUMN!');
1073                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']][] = $attributes['VALUE'];
1074         } elseif ((!isset($attributes['NAME'])) || (trim($attributes['NAME']) == '')) {
1075                 // Numerical index
1076                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
1077                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $attributes['VALUE'];
1078         } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['NAME']])) {
1079                 // Already created
1080                 debug_report_bug(__FUNCTION__, __LINE__, 'NAME=' . $attributes['NAME'] . ' already addded to ' . $element . ' attributes=<pre>' . print_r($attributes, true) . '</pre>');
1081         } else {
1082                 // Use from NAME
1083                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',NAME=' . $attributes['NAME'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME!');
1084                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['NAME']] = $attributes['VALUE'];
1085         }
1086         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',key=' . $key . ' - EXIT!');
1087 }
1088
1089 //-----------------------------------------------------------------------------
1090 //                            Execute call-back functions
1091 //-----------------------------------------------------------------------------
1092
1093 // Execute function for doXmlCallbackFunction()
1094 function doXmlCallbackFunctionExecute ($callbackFunction, $args) {
1095         // Is 'id_index' set and form sent?
1096         if ((isset($args['id_index'])) && (isFormSent())) {
1097                 // Prepare 'id_index'
1098                 $args['id_index'] = postRequestElement($args['id_index']);
1099         } // END - if
1100
1101         // Just call it
1102         //* DEBUG: */ die('callbackFunction=' . $callbackFunction . ',args=<pre>'.print_r($args, true).'</pre>');
1103         call_user_func_array($callbackFunction, $args);
1104 }
1105
1106 // [EOF]
1107 ?>