0d7456a6983215d735040fbb23a7f20bbfcf76c4
[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://www.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) != 3) {
125                 // Not the right count
126                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 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['VALUE'])) {
137                 // 'VALUE' not found
138                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
139         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
140                 // Not valid/verifyable
141                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
142         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_list'])) {
143                 // doXmlCallbackFunction is missing
144                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/database-column-list not included around this node. Please fix your XML.');
145         }
146
147         // Add the entry to the list
148         addXmlValueToCallbackAttributes('column_list', $attributes);
149 }
150
151 // Handles the XML node 'callback-function-list'
152 function doXmlCallbackFunctionList ($resource, $attributes) {
153         // There should be no attributes
154         if (count($attributes) > 0) {
155                 // Please don't add any attributes to foo-list nodes
156                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
157         } // END - if
158
159         // Add an empty list
160         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['callback_list'] = array();
161 }
162
163 // Handles the XML node 'callback-function-list-entry'
164 function doXmlCallbackFunctionListEntry ($resource, $attributes) {
165         // There are three attributes, by default
166         if (count($attributes) != 3) {
167                 // Not the right count
168                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
169         } elseif (!isset($attributes['NAME'])) {
170                 // 'NAME' not found
171                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
172         } elseif (!isset($attributes['TYPE'])) {
173                 // 'TYPE' not found
174                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
175         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
176                 // No valid type
177                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
178         } elseif (!isset($attributes['VALUE'])) {
179                 // 'VALUE' not found
180                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
181         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
182                 // Not valid/verifyable
183                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
184         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['callback_list'])) {
185                 // doXmlCallbackFunction is missing
186                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/callback-function-list not included around this node. Please fix your XML.');
187         }
188
189         // Add the entry to the list
190         addXmlValueToCallbackAttributes('callback_list', $attributes);
191 }
192
193 // Handles the XML node 'extra-parameter-list'
194 function doXmlExtraParameterList ($resource, $attributes) {
195         // There should be no attributes
196         if (count($attributes) > 0) {
197                 // Please don't add any attributes to foo-list nodes
198                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
199         } // END - if
200
201         // Add an empty list
202         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list'] = array();
203 }
204
205 // Handles the XML node 'extra-parameter-list-entry'
206 function doXmlExtraParameterListEntry ($resource, $attributes) {
207         // There are three attributes, by default
208         if (count($attributes) != 3) {
209                 // Not the right count
210                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
211         } elseif (!isset($attributes['NAME'])) {
212                 // 'NAME' not found
213                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
214         } elseif (!isset($attributes['TYPE'])) {
215                 // 'TYPE' not found
216                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
217         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
218                 // No valid type
219                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
220         } elseif (!isset($attributes['VALUE'])) {
221                 // 'VALUE' not found
222                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
223         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
224                 // Not valid/verifyable
225                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
226         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list'])) {
227                 // doXmlCallbackFunction is missing
228                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list not included around this node. Please fix your XML.');
229         }
230
231         // Add the entry to the list
232         addXmlValueToCallbackAttributes('extra_list', $attributes);
233 }
234
235 // Handles the XML node 'extra-parameter-member-list'
236 function doXmlExtraParameterMemberList ($resource, $attributes) {
237         // There should be no attributes
238         if (count($attributes) > 0) {
239                 // Please don't add any attributes to foo-list nodes
240                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
241         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['member_list'])) {
242                 // This list should be created already
243                 debug_report_bug(__FUNCTION__, __LINE__, 'member_list should be already created.');
244         }
245 }
246
247 // Handles the XML node 'extra-parameter-member-list-entry'
248 function doXmlExtraParameterMemberListEntry ($resource, $attributes) {
249         // There are three attributes, by default
250         if (count($attributes) != 3) {
251                 // Not the right count
252                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
253         } elseif (!isset($attributes['NAME'])) {
254                 // 'NAME' not found
255                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
256         } elseif (!isset($attributes['TYPE'])) {
257                 // 'TYPE' not found
258                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
259         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
260                 // No valid type
261                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
262         } elseif (!isset($attributes['VALUE'])) {
263                 // 'VALUE' not found
264                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
265         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
266                 // Not valid/verifyable
267                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
268         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['member_list'])) {
269                 // doXmlCallbackFunction is missing
270                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.');
271         }
272
273         // Add the entry to the list
274         addXmlValueToCallbackAttributes('extra_list', $attributes, 'member_list');
275 }
276
277 // Handles the XML node 'status-change-column'
278 function doXmlStatusChangeColumn ($resource, $attributes) {
279         // There are three attributes, by default
280         if (count($attributes) != 3) {
281                 // Not the right count
282                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
283         } elseif (!isset($attributes['NAME'])) {
284                 // 'NAME' not found
285                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
286         } elseif (!isset($attributes['TYPE'])) {
287                 // 'TYPE' not found
288                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
289         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
290                 // No valid type
291                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
292         } elseif (!isset($attributes['VALUE'])) {
293                 // 'VALUE' not found
294                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
295         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
296                 // Not valid/verifyable
297                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
298         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
299                 // doXmlCallbackFunction is missing
300                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
301         }
302
303         // Add the entry to the list
304         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['status_list'][$attributes['VALUE']] = array();
305 }
306
307 // Handles the XML node 'status-change-list'
308 function doXmlStatusChangeList ($resource, $attributes) {
309         // There should be no attributes
310         if (count($attributes) > 0) {
311                 // Please don't add any attributes to foo-list nodes
312                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
313         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['status_list'])) {
314                 // doXmlCallbackFunction is missing
315                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/status-list not included around this node. Please fix your XML.');
316         }
317 }
318
319 // Handles the XML node 'status-change-list-entry'
320 function doXmlStatusChangeListEntry ($resource, $attributes) {
321         // There are for attributes, by default
322         if (count($attributes) != 4) {
323                 // Not the right count
324                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 4 attributes, got ' . count($attributes));
325         } elseif (!isset($attributes['NAME'])) {
326                 // 'NAME' not found
327                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
328         } elseif (!isset($attributes['TYPE'])) {
329                 // 'TYPE' not found
330                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
331         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
332                 // No valid type
333                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
334         } elseif (!isset($attributes['VALUE'])) {
335                 // 'VALUE' not found
336                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
337         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['OLD'])) {
338                 // Not valid/verifyable
339                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute OLD does not validate. TYPE=' . $attributes['TYPE'] . ',OLD=' . $attributes['OLD']);
340         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
341                 // Not valid/verifyable
342                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
343         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['status_list'])) {
344                 // doXmlCallbackFunction is missing
345                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.');
346         }
347
348         // Add the entry to the list
349         addXmlValueToCallbackAttributes('status_list', $attributes, $attributes['NAME'], 'OLD');
350 }
351
352 // Handles the XML node 'enable-modify-entries'
353 function doXmlEnableModifyEntries ($resource, $attributes) {
354         // There are three attributes, by default
355         if (count($attributes) != 3) {
356                 // Not the right count
357                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
358         } elseif (!isset($attributes['NAME'])) {
359                 // 'NAME' not found
360                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
361         } elseif (!isset($attributes['TYPE'])) {
362                 // 'TYPE' not found
363                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
364         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
365                 // No valid type
366                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
367         } elseif (!isset($attributes['VALUE'])) {
368                 // 'VALUE' not found
369                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
370         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
371                 // Not valid/verifyable
372                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
373         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
374                 // doXmlCallbackFunction is missing
375                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
376         }
377
378         // Add the entry to the list
379         addXmlValueToCallbackAttributes('enable_modify_entries', $attributes);
380         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['enable_modify_entries'] = convertStringToBoolean($attributes['VALUE']);
381 }
382
383 // Handles the XML node 'table-id-column'
384 function doXmlTableIdColumn ($resource, $attributes) {
385         // There are three attributes, by default
386         if (count($attributes) != 3) {
387                 // Not the right count
388                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
389         } elseif (!isset($attributes['NAME'])) {
390                 // 'NAME' not found
391                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
392         } elseif (!isset($attributes['TYPE'])) {
393                 // 'TYPE' not found
394                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
395         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
396                 // No valid type
397                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
398         } elseif (!isset($attributes['VALUE'])) {
399                 // 'VALUE' not found
400                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
401         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
402                 // Not valid/verifyable
403                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
404         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
405                 // doXmlCallbackFunction is missing
406                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
407         }
408
409         // Add the entry to the array
410         addXmlValueToCallbackAttributes('table_id_column', $attributes);
411         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['table_id_column'] = $attributes['VALUE'];
412 }
413
414 // Handles the XML node 'table-userid-column'
415 function doXmlTableUseridColumn ($resource, $attributes) {
416         // There are three attributes, by default
417         if (count($attributes) != 3) {
418                 // Not the right count
419                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
420         } elseif (!isset($attributes['NAME'])) {
421                 // 'NAME' not found
422                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
423         } elseif (!isset($attributes['TYPE'])) {
424                 // 'TYPE' not found
425                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
426         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
427                 // No valid type
428                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
429         } elseif (!isset($attributes['VALUE'])) {
430                 // 'VALUE' not found
431                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
432         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
433                 // Not valid/verifyable
434                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
435         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
436                 // doXmlCallbackFunction is missing
437                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
438         }
439
440         // Add the entry to the array
441         addXmlValueToCallbackAttributes('table_userid_column', $attributes);
442         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['table_userid_column'] = $attributes['VALUE'];
443 }
444
445 // Handles the XML node 'raw-userid-column-key'
446 function doXmlRawUseridColumnKey ($resource, $attributes) {
447         // There are three attributes, by default
448         if (count($attributes) != 3) {
449                 // Not the right count
450                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
451         } elseif (!isset($attributes['NAME'])) {
452                 // 'NAME' not found
453                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
454         } elseif (!isset($attributes['TYPE'])) {
455                 // 'TYPE' not found
456                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
457         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
458                 // No valid type
459                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
460         } elseif (!isset($attributes['VALUE'])) {
461                 // 'VALUE' not found
462                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
463         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
464                 // Not valid/verifyable
465                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
466         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
467                 // doXmlCallbackFunction is missing
468                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
469         }
470
471         // Add the entry to the array
472         addXmlValueToCallbackAttributes('raw_userid_column_key', $attributes);
473         //$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['raw_userid_column_key'] = $attributes['VALUE'];
474 }
475
476 //-----------------------------------------------------------------------------
477 //           Call-back functions for listing of data in admin area
478 //-----------------------------------------------------------------------------
479
480 // Handles the XML node 'admin-list-data'
481 function doXmlAdminListData ($resource, $attributes) {
482         // There should be no attributes
483         if (count($attributes) > 0) {
484                 // Please don't add any attributes to foo-list nodes
485                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
486         } // END - if
487 }
488
489 // Handles the XML node 'data-tables'
490 function doXmlDataTables ($resource, $attributes) {
491         // There should be no attributes
492         if (count($attributes) > 0) {
493                 // Please don't add any attributes to foo-list nodes
494                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes));
495         } // END - if
496 }
497
498 // Handles the XML node 'data-table'
499 function doXmlDataTable ($resource, $attributes) {
500         // There are three attributes, by default
501         if (count($attributes) != 3) {
502                 // Not the right count
503                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
504         } elseif (!isset($attributes['VALUE'])) {
505                 // 'VALUE' not found
506                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
507         } elseif (!isset($attributes['TYPE'])) {
508                 // 'TYPE' not found
509                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
510         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
511                 // No valid type
512                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
513         } elseif (!isset($attributes['ALIAS'])) {
514                 // 'ALIAS' not found
515                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ALIAS not found.');
516         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
517                 // Not valid/verifyable
518                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
519         } elseif ((trim($attributes['ALIAS']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['ALIAS']))) {
520                 // Not valid/verifyable
521                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. ALIAS=' . $attributes['ALIAS']);
522         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
523                 // doXmlCallbackFunction is missing
524                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
525         }
526
527         // Add the entry to the array
528         addXmlValueToCallbackAttributes('data_table', $attributes);
529 }
530
531 // Handles the XML node 'select-data-from-list'
532 function doXmlSelectDataFromList ($resource, $attributes) {
533         // There should be no attributes
534         if (count($attributes) > 0) {
535                 // Please don't add any attributes to foo-list nodes
536                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
537         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
538                 // doXmlCallbackFunction is missing
539                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
540         }
541
542         // Add an empty list
543         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'] = array();
544 }
545
546 // Handles the XML node 'select-data-from-list-entry'
547 function doXmlSelectDataFromListEntry ($resource, $attributes) {
548         // There are five attributes, by default
549         if (count($attributes) != 5) {
550                 // Not the right count
551                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
552         } elseif (!isset($attributes['VALUE'])) {
553                 // 'VALUE' not found
554                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
555         } elseif (!isset($attributes['TYPE'])) {
556                 // 'TYPE' not found
557                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
558         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
559                 // No valid type
560                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
561         } elseif (!isset($attributes['ALIAS'])) {
562                 // 'ALIAS' not found
563                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ALIAS not found.');
564         } elseif (!isset($attributes['FUNCTION'])) {
565                 // 'FUNCTION' not found
566                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute FUNCTION not found.');
567         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
568                 // 'VALUE' not valid/verifyable
569                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
570         } elseif ((trim($attributes['ALIAS']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['ALIAS']))) {
571                 // 'ALIAS' not valid/verifyable
572                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ALIAS does not validate. ALIAS=' . $attributes['ALIAS']);
573         } elseif ((trim($attributes['FUNCTION']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['FUNCTION']))) {
574                 // 'FUNCTION' not valid/verifyable
575                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute FUNCTION does not validate. FUNCTION=' . $attributes['FUNCTION']);
576         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
577                 // doXmlCallbackFunction is missing
578                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/select-data-from-list not included around this node. Please fix your XML.');
579         }
580
581         // Add the entry to the array
582         addXmlValueToCallbackAttributes('data_column_list', $attributes);
583 }
584
585 // Handles the XML node 'where-select-from-list'
586 function doXmlWhereSelectFromList ($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']['where_select_list'] = array();
598 }
599
600 // Handles the XML node 'where-select-from-list-entry'
601 function doXmlWhereSelectFromListEntry ($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['TYPE'])) {
607                 // 'TYPE' not found
608                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
609         } elseif (!isset($attributes['TABLE'])) {
610                 // 'TABLE' not found
611                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
612         } elseif (!isset($attributes['VALUE'])) {
613                 // 'VALUE' not found
614                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
615         } elseif (!isset($attributes['CONDITION'])) {
616                 // 'CONDITION' not found
617                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute CONDITION not found.');
618         } elseif (!isset($attributes['LOOK-FOR'])) {
619                 // 'LOOK-FOR' not found
620                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute LOOK-FOR not found.');
621         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
622                 // No valid type
623                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
624         } elseif ((trim($attributes['TABLE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE']))) {
625                 // 'TABLE' not valid/verifyable
626                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TABLE=' . $attributes['TABLE']);
627         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
628                 // 'VALUE' not valid/verifyable
629                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
630         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['CONDITION'])) {
631                 // 'CONDITION' not valid/verifyable
632                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION does not validate. CONDITION=' . $attributes['CONDITION']);
633         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['LOOK-FOR'])) {
634                 // 'LOOK-FOR' not valid/verifyable
635                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute LOOK-FOR does not validate. LOOK-FOR=' . $attributes['LOOK-FOR']);
636         } elseif (!isXmlConditionValid($attributes['CONDITION'])) {
637                 // 'CONDITION' is not known
638                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION is not valid. LOOK-FOR=' . $attributes['CONDITION']);
639         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
640                 // doXmlCallbackFunction is missing
641                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-column-list not included around this node. Please fix your XML.');
642         }
643
644         // Add the entry to the array
645         addXmlValueToCallbackAttributes('where_select_list', $attributes);
646 }
647
648 // Handles the XML node 'order-by-list'
649 function doXmlOrderByList ($resource, $attributes) {
650         // There should be no attributes
651         if (count($attributes) > 0) {
652                 // Please don't add any attributes to foo-list nodes
653                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
654         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
655                 // doXmlCallbackFunction is missing
656                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
657         }
658
659         // Add an empty list
660         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['order_by_list'] = array();
661 }
662
663 // Handles the XML node 'order-by-list-entry'
664 function doXmlOrderByListEntry ($resource, $attributes) {
665         // There are four attributes, by default
666         if (count($attributes) != 4) {
667                 // Not the right count
668                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
669         } elseif (!isset($attributes['ORDER'])) {
670                 // 'ORDER' not found
671                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute ORDER not found.');
672         } elseif (!isset($attributes['TYPE'])) {
673                 // 'TYPE' not found
674                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
675         } elseif (!isset($attributes['TABLE'])) {
676                 // 'TABLE' not found
677                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
678         } elseif (!isset($attributes['VALUE'])) {
679                 // 'VALUE' not found
680                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
681         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
682                 // No valid type
683                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
684         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['ORDER'])) {
685                 // 'ORDER' not valid/verifyable
686                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ORDER does not validate. ORDER=' . $attributes['ORDER']);
687         } elseif ((trim($attributes['TABLE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE']))) {
688                 // 'TABLE' not valid/verifyable
689                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TABLE=' . $attributes['TABLE']);
690         } elseif ((trim($attributes['VALUE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE']))) {
691                 // 'VALUE' not valid/verifyable
692                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
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('order_by_list', $attributes);
700 }
701
702 // Handles the XML node 'list-template'
703 function doXmlListTemplate ($resource, $attributes) {
704         // There are two attributes, by default
705         if (count($attributes) != 2) {
706                 // Not the right count
707                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
708         } elseif (!isset($attributes['VALUE'])) {
709                 // 'VALUE' not found
710                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
711         } elseif (!isset($attributes['TYPE'])) {
712                 // 'TYPE' not found
713                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
714         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
715                 // No valid type
716                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
717         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
718                 // Not valid/verifyable
719                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
720         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
721                 // doXmlCallbackFunction is missing
722                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
723         }
724
725         // Add the entry to the array
726         addXmlValueToCallbackAttributes('list_template', $attributes);
727 }
728
729 // Handles the XML node 'list-row-template'
730 function doXmlListRowTemplate ($resource, $attributes) {
731         // There are two attributes, by default
732         if (count($attributes) != 2) {
733                 // Not the right count
734                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
735         } elseif (!isset($attributes['VALUE'])) {
736                 // 'VALUE' not found
737                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
738         } elseif (!isset($attributes['TYPE'])) {
739                 // 'TYPE' not found
740                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
741         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
742                 // No valid type
743                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
744         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
745                 // Not valid/verifyable
746                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
747         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
748                 // doXmlCallbackFunction is missing
749                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
750         }
751
752         // Add the entry to the array
753         addXmlValueToCallbackAttributes('list_row_template', $attributes);
754 }
755
756 // Handles the XML node 'column-callback-list'
757 function doXmlColumnCallbackList ($resource, $attributes) {
758         // There should be no attributes
759         if (count($attributes) > 0) {
760                 // Please don't add any attributes to foo-list nodes
761                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
762         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_table'])) {
763                 // doXmlCallbackFunction is missing
764                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-table not included around this node. Please fix your XML.');
765         }
766
767         // Add an empty list
768         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'] = array();
769 }
770
771 // Handles the XML node 'column-callback-list-entry'
772 function doXmlColumnCallbackListEntry ($resource, $attributes) {
773         // There should be no attributes
774         if (count($attributes) > 0) {
775                 // Please don't add any attributes to foo-list nodes
776                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
777         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'])) {
778                 // doXmlCallbackFunction is missing
779                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/column-callback not included around this node. Please fix your XML.');
780         }
781 }
782
783 // Handles the XML node 'column-callback-data'
784 function doXmlColumnCallbackData ($resource, $attributes) {
785         // There are three attributes, by default
786         if (count($attributes) != 3) {
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 (!isset($attributes['CALLBACK'])) {
796                 // 'CALLBACK' not found
797                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute CALLBACK not found.');
798         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
799                 // No valid type
800                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
801         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
802                 // Not valid/verifyable
803                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
804         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
805                 // doXmlCallbackFunction is missing
806                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
807         } elseif ((trim($attributes['CALLBACK']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['CALLBACK']))) {
808                 // 'CALLBACK' not valid/verifyable
809                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CALLBACK does not validate. CALLBACK=' . $attributes['CALLBACK']);
810         }
811
812         // Add the entry to the array
813         addXmlValueToCallbackAttributes('column_callback_list', $attributes);
814 }
815
816 // Handles the XML node 'callback-extra-parameter-list'
817 function doXmlCallbackExtraParameterList ($resource, $attributes) {
818         // There should be no attributes
819         if (count($attributes) > 0) {
820                 // Please don't add any attributes to foo-list nodes
821                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 1 attributes because this is a named foo-list node, got ' . count($attributes));
822         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_callback_list'])) {
823                 // doXmlCallbackFunction is missing
824                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/column-callback-list not included around this node. Please fix your XML.');
825         } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'])) {
826                 // Abort silently here, no one wants to kill this array
827                 return;
828         }
829
830         // Add an empty list
831         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'] = array();
832 }
833
834 // Handles the XML node 'callback-extra-parameter-list-entry'
835 function doXmlCallbackExtraParameterListEntry ($resource, $attributes) {
836         // There are three attributes, by default
837         if (count($attributes) != 3) {
838                 // Not the right count
839                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
840         } elseif (!isset($attributes['COLUMN'])) {
841                 // 'COLUMN' not found
842                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute COLUMN not found.');
843         } elseif (!isset($attributes['TYPE'])) {
844                 // 'TYPE' not found
845                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
846         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
847                 // No valid type
848                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
849         } elseif (!isset($attributes['VALUE'])) {
850                 // 'VALUE' not found
851                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
852         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
853                 // 'VALUE' not valid/verifyable
854                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
855         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['__EXTRA_PARAMETER'])) {
856                 // doXmlCallbackFunction is missing
857                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/__EXTRA_PARAMETER not included around this node. Please fix your XML.');
858         }
859
860         // Add the entry to the array
861         addXmlValueToCallbackAttributes('__EXTRA_PARAMETER', $attributes);
862 }
863
864 // Handles the XML node 'no-entry-found-message'
865 function doXmlNoEntryFoundMessage ($resource, $attributes) {
866         // There are two attributes, by default
867         if (count($attributes) != 2) {
868                 // Not the right count
869                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
870         } elseif (!isset($attributes['VALUE'])) {
871                 // 'VALUE' not found
872                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
873         } elseif (!isset($attributes['TYPE'])) {
874                 // 'TYPE' not found
875                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
876         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
877                 // No valid type
878                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
879         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
880                 // Not valid/verifyable
881                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
882         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'])) {
883                 // doXmlCallbackFunction is missing
884                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function not included around this node. Please fix your XML.');
885         }
886
887         // Add the entry to the array
888         addXmlValueToCallbackAttributes('no_entry_message_id', $attributes);
889 }
890
891 //-----------------------------------------------------------------------------
892 //                              XML type validation
893 //-----------------------------------------------------------------------------
894
895 // Checks for string without any added extra data
896 function isXmlTypeString ($value) {
897         // Just let SQL_ESCAPE() do the job
898         return ($value == SQL_ESCAPE($value));
899 }
900
901 // Fake-check for array type
902 function isXmlTypeArray ($value) {
903         // This value is always a string
904         return (is_string($value));
905 }
906
907 // Check for boolean type
908 function isXmlTypeBool ($value) {
909         // Trim value
910         $value = trim($value);
911
912         // This value is always a string
913         return (($value == 'true') || ($value == 'false'));
914 }
915
916 // Check for integer type
917 function isXmlTypeInt ($value) {
918         // Trim value
919         $value = trim($value);
920
921         // This value is always a string
922         return (bigintval($value) == $value);
923 }
924
925 // Check for callback type
926 function isXmlTypeCallback ($value) {
927         // Trim value
928         $value = trim($value);
929
930         // This value is always a string
931         return (function_exists($value));
932 }
933
934 //-----------------------------------------------------------------------------
935 //                               Private XML functions
936 //-----------------------------------------------------------------------------
937
938 // Adds given attribut to element
939 function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '', $key = '') {
940         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',key=' . $key . ' - ENTERED!');
941         // Is it boolean type?
942         if (($attributes['TYPE'] == 'bool') && (isset($attributes['VALUE']))) {
943                 // Then convert VALUE
944                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=' . $attributes['TYPE'] . ',element=' . $element . ' - CONVERTING!');
945                 $attributes['VALUE'] = convertStringToBoolean($attributes['VALUE']);
946         } elseif ($attributes['TYPE'] == 'callback') {
947                 // It is a simple call-back type
948                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=' . $attributes['TYPE'] . ',element=' . $element . ' - CALLING!');
949                 $attributes['VALUE'] = call_user_func($attributes['VALUE']);
950         }
951
952         // What do we need to add?
953         if ($attributes['TYPE'] == 'array') {
954                 // Another nested array
955                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=' . $attributes['TYPE'] . ',element=' . $element);
956                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['VALUE'] . '_list'] = array();
957         } elseif (!empty($extraKey)) {
958                 // Is it bool?
959                 if (($attributes['TYPE'] == 'bool') && (isset($attributes['VALUE']))) {
960                         // Then convert VALUE
961                         $attributes['VALUE'] = convertStringToBoolean($attributes['VALUE']);
962                 } // END - if
963
964                 // Sub-array (one level only)
965                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ' - ANALYSING...');
966                 if (trim($attributes['NAME']) == '') {
967                         // Numerical index
968                         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
969                         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][] = $attributes['VALUE'];
970                 } elseif (!empty($key)) {
971                         // Use from $key
972                         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
973                         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes[$key]] = $attributes['VALUE'];
974                 } else {
975                         // Use from NAME
976                         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (NAME=' . $attributes['NAME'] . ')');
977                         $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes['NAME']] = $attributes['VALUE'];
978                 }
979         } elseif ((isset($attributes['FUNCTION'])) && (isset($attributes['ALIAS']))) {
980                 /*
981                  * ALIAS and FUNCTION detected? This may happen with SQL queries
982                  * like: UNIX_TIMESTAMP(`foo_timestamp`) AS `foo_timestamp`
983                  */
984                 // Init array
985                 $array =  array(
986                         'column'   => trim($attributes['VALUE']),
987                         'alias'    => trim($attributes['ALIAS']),
988                         'function' => trim($attributes['FUNCTION']),
989                         'table'    => trim($attributes['TABLE'])
990                 );
991
992                 // Add the entry
993                 //* 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'] . ')');
994                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
995         } elseif ((isset($attributes['CONDITION'])) && (isset($attributes['LOOK-FOR']))) {
996                 // CONDITION/LOOK-FOR detected
997                 // Init array
998                 $array =  array(
999                         'column'    => trim($attributes['VALUE']),
1000                         'table'     => trim($attributes['TABLE']),
1001                         'condition' => convertXmlContion(trim($attributes['CONDITION'])),
1002                         'look_for'  => trim($attributes['LOOK-FOR'])
1003                 );
1004
1005                 //* 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'] . ')');
1006                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
1007         } elseif (isset($attributes['CALLBACK'])) {
1008                 // CALLBACK/VALUE detected
1009                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',CALLBACK[' . gettype($attributes['CALLBACK']) . ']=' . $attributes['CALLBACK'] . ' - CALLBACK! (VALUE=' . $attributes['VALUE'] . ')');
1010                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['VALUE']] = $attributes['CALLBACK'];
1011         } elseif (isset($attributes['ORDER'])) {
1012                 // ORDER/TABLE detected
1013                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',ORDER[' . gettype($attributes['ORDER']) . ']=' . $attributes['ORDER'] . ' - ORDER! (VALUE=' . $attributes['VALUE'] . ')');
1014                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['ORDER']][$attributes['TABLE']] = $attributes['VALUE'];
1015         } elseif (isset($attributes['COLUMN'])) {
1016                 // COLUMN/VALUE detected
1017                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ',COLUMN[' . gettype($attributes['COLUMN']) . ']=' . $attributes['COLUMN'] . ' - COLUMN!');
1018                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['COLUMN']][] = $attributes['VALUE'];
1019         } elseif ((!isset($attributes['NAME'])) || (trim($attributes['NAME']) == '')) {
1020                 // Numerical index
1021                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
1022                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $attributes['VALUE'];
1023         } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['NAME']])) {
1024                 // Already created
1025                 debug_report_bug(__FUNCTION__, __LINE__, 'NAME=' . $attributes['NAME'] . ' already addded to ' . $element . ' attributes=<pre>' . print_r($attributes, true) . '</pre>');
1026         } else {
1027                 // Use from NAME
1028                 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',NAME=' . $attributes['NAME'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME!');
1029                 $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['NAME']] = $attributes['VALUE'];
1030         }
1031         //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',key=' . $key . ' - EXIT!');
1032 }
1033
1034 //-----------------------------------------------------------------------------
1035 //                            Execute call-back functions
1036 //-----------------------------------------------------------------------------
1037
1038 // Execute function for doXmlCallbackFunction()
1039 function doXmlCallbackFunctionExecute ($callbackFunction, $args) {
1040         // Is 'id_index' set and form sent?
1041         if ((isset($args['id_index'])) && (isFormSent())) {
1042                 // Prepare 'id_index'
1043                 $args['id_index'] = postRequestParameter($args['id_index']);
1044         } // END - if
1045
1046         // Just call it
1047         //* DEBUG: */ die('callbackFunction=' . $callbackFunction . ',args=<pre>'.print_r($args, true).'</pre>');
1048         call_user_func_array($callbackFunction, $args);
1049 }
1050
1051 // [EOF]
1052 ?>