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