98f19e24b238f07466233e8031b70c9b0ab95ce4
[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         /*
46          * This node has no attributes by default so it remains just with this
47          * comment.
48          */
49 }
50
51 // Handles the XML node 'admin-callback-function'
52 function doXmlAdminCallbackFunction ($resource, $attributes) {
53         // There are two attributes, by default
54         if (count($attributes) != 2) {
55                 // Not the right count
56                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 2 attributes, got ' . count($attributes));
57         } elseif (!isset($attributes['TYPE'])) {
58                 // 'TYPE' not found
59                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
60         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
61                 // No valid type
62                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
63         } elseif (!isset($attributes['VALUE'])) {
64                 // 'VALUE' not found
65                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
66         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
67                 // Not valid/verifyable
68                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
69         }
70
71         // Add the function name and no attributes by default
72         $GLOBALS['__XML_CALLBACKS']['callbacks'][] = __FUNCTION__;
73         $GLOBALS['__XML_CALLBACKS']['functions'][__FUNCTION__][] = $attributes['VALUE'];
74         $GLOBALS['__XML_ARGUMENTS'][__FUNCTION__] = array();
75 }
76
77 // Handles the XML node 'post-data-identify-index'
78 function doXmlPostDataIdentifyIndex ($resource, $attributes) {
79         // There are three attributes, by default
80         if (count($attributes) != 3) {
81                 // Not the right count
82                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
83         } elseif (!isset($attributes['NAME'])) {
84                 // 'NAME' not found
85                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
86         } elseif (!isset($attributes['TYPE'])) {
87                 // 'TYPE' not found
88                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
89         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
90                 // No valid type
91                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
92         } elseif (!isset($attributes['VALUE'])) {
93                 // 'VALUE' not found
94                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
95         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
96                 // Not valid/verifyable
97                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
98         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
99                 // doXmlAdminCallbackFunction is missing
100                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
101         }
102
103         // Add the POST data index for 'id'
104         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['id_index'] = $attributes['VALUE'];
105 }
106
107 // Handles the XML node 'database-table'
108 function doXmlDatabaseTable ($resource, $attributes) {
109         // There are three attributes, by default
110         if (count($attributes) != 3) {
111                 // Not the right count
112                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
113         } elseif (!isset($attributes['NAME'])) {
114                 // 'NAME' not found
115                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
116         } elseif (!isset($attributes['TYPE'])) {
117                 // 'TYPE' not found
118                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
119         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
120                 // No valid type
121                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
122         } elseif (!isset($attributes['VALUE'])) {
123                 // 'VALUE' not found
124                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
125         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
126                 // Not valid/verifyable
127                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
128         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
129                 // doXmlAdminCallbackFunction is missing
130                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
131         }
132
133         // Add the database's name
134         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['database_table'] = $attributes['VALUE'];
135 }
136
137 // Handles the XML node 'database-column-list'
138 function doXmlDatabaseColumnList ($resource, $attributes) {
139         // There should be no attributes
140         if (count($attributes) > 0) {
141                 // Please don't add any attributes to foo-list nodes
142                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
143         } // END - if
144
145         // Add an empty list
146         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['column_list'] = array();
147 }
148
149 // Handles the XML node 'database-column-list-entry'
150 function doXmlDatabaseColumnListEntry ($resource, $attributes) {
151         // There are three attributes, by default
152         if (count($attributes) != 3) {
153                 // Not the right count
154                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
155         } elseif (!isset($attributes['NAME'])) {
156                 // 'NAME' not found
157                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
158         } elseif (!isset($attributes['TYPE'])) {
159                 // 'TYPE' not found
160                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
161         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
162                 // No valid type
163                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
164         } elseif (!isset($attributes['VALUE'])) {
165                 // 'VALUE' not found
166                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
167         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
168                 // Not valid/verifyable
169                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
170         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['column_list'])) {
171                 // doXmlAdminCallbackFunction is missing
172                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/database-column-list not included around this node. Please fix your XML.');
173         }
174
175         // Add the entry to the list
176         addXmlValueToCallbackAttributes('column_list', $attributes);
177 }
178
179 // Handles the XML node 'callback-function-list'
180 function doXmlCallbackFunctionList ($resource, $attributes) {
181         // There should be no attributes
182         if (count($attributes) > 0) {
183                 // Please don't add any attributes to foo-list nodes
184                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
185         } // END - if
186
187         // Add an empty list
188         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['callback_list'] = array();
189 }
190
191 // Handles the XML node 'callback-function-list-entry'
192 function doXmlCallbackFunctionListEntry ($resource, $attributes) {
193         // There are three attributes, by default
194         if (count($attributes) != 3) {
195                 // Not the right count
196                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
197         } elseif (!isset($attributes['NAME'])) {
198                 // 'NAME' not found
199                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
200         } elseif (!isset($attributes['TYPE'])) {
201                 // 'TYPE' not found
202                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
203         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
204                 // No valid type
205                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
206         } elseif (!isset($attributes['VALUE'])) {
207                 // 'VALUE' not found
208                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
209         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
210                 // Not valid/verifyable
211                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
212         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['callback_list'])) {
213                 // doXmlAdminCallbackFunction is missing
214                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/callback-function-list not included around this node. Please fix your XML.');
215         }
216
217         // Add the entry to the list
218         addXmlValueToCallbackAttributes('callback_list', $attributes);
219 }
220
221 // Handles the XML node 'extra-parameter-list'
222 function doXmlExtraParameterList ($resource, $attributes) {
223         // There should be no attributes
224         if (count($attributes) > 0) {
225                 // Please don't add any attributes to foo-list nodes
226                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
227         } // END - if
228
229         // Add an empty list
230         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list'] = array();
231 }
232
233 // Handles the XML node 'extra-parameter-list-entry'
234 function doXmlExtraParameterListEntry ($resource, $attributes) {
235         // There are three attributes, by default
236         if (count($attributes) != 3) {
237                 // Not the right count
238                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
239         } elseif (!isset($attributes['NAME'])) {
240                 // 'NAME' not found
241                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
242         } elseif (!isset($attributes['TYPE'])) {
243                 // 'TYPE' not found
244                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
245         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
246                 // No valid type
247                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
248         } elseif (!isset($attributes['VALUE'])) {
249                 // 'VALUE' not found
250                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
251         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
252                 // Not valid/verifyable
253                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
254         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list'])) {
255                 // doXmlAdminCallbackFunction is missing
256                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/extra-parameter-list not included around this node. Please fix your XML.');
257         }
258
259         // Add the entry to the list
260         addXmlValueToCallbackAttributes('extra_list', $attributes);
261 }
262
263 // Handles the XML node 'extra-parameter-member-list'
264 function doXmlExtraParameterMemberList ($resource, $attributes) {
265         // There should be no attributes
266         if (count($attributes) > 0) {
267                 // Please don't add any attributes to foo-list nodes
268                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
269         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list']['member_list'])) {
270                 // This list should be created already
271                 debug_report_bug(__FUNCTION__, __LINE__, 'member_list should be already created.');
272         }
273 }
274
275 // Handles the XML node 'extra-parameter-member-list-entry'
276 function doXmlExtraParameterMemberListEntry ($resource, $attributes) {
277         // There are three attributes, by default
278         if (count($attributes) != 3) {
279                 // Not the right count
280                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
281         } elseif (!isset($attributes['NAME'])) {
282                 // 'NAME' not found
283                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
284         } elseif (!isset($attributes['TYPE'])) {
285                 // 'TYPE' not found
286                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
287         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
288                 // No valid type
289                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
290         } elseif (!isset($attributes['VALUE'])) {
291                 // 'VALUE' not found
292                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
293         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
294                 // Not valid/verifyable
295                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
296         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list']['member_list'])) {
297                 // doXmlAdminCallbackFunction is missing
298                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.');
299         }
300
301         // Add the entry to the list
302         addXmlValueToCallbackAttributes('extra_list', $attributes, 'member_list');
303 }
304
305 // Handles the XML node 'status-change-column'
306 function doXmlStatusChangeColumn ($resource, $attributes) {
307         // There are three attributes, by default
308         if (count($attributes) != 3) {
309                 // Not the right count
310                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
311         } elseif (!isset($attributes['NAME'])) {
312                 // 'NAME' not found
313                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
314         } elseif (!isset($attributes['TYPE'])) {
315                 // 'TYPE' not found
316                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
317         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
318                 // No valid type
319                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
320         } elseif (!isset($attributes['VALUE'])) {
321                 // 'VALUE' not found
322                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
323         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
324                 // Not valid/verifyable
325                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
326         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
327                 // doXmlAdminCallbackFunction is missing
328                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
329         }
330
331         // Add the entry to the list
332         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'][$attributes['VALUE']] = array();
333 }
334
335 // Handles the XML node 'status-change-list'
336 function doXmlStatusChangeList ($resource, $attributes) {
337         // There should be no attributes
338         if (count($attributes) > 0) {
339                 // Please don't add any attributes to foo-list nodes
340                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes));
341         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'])) {
342                 // doXmlAdminCallbackFunction is missing
343                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/status-list not included around this node. Please fix your XML.');
344         }
345 }
346
347 // Handles the XML node 'status-change-list-entry'
348 function doXmlStatusChangeListEntry ($resource, $attributes) {
349         // There are for attributes, by default
350         if (count($attributes) != 4) {
351                 // Not the right count
352                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 4 attributes, got ' . count($attributes));
353         } elseif (!isset($attributes['NAME'])) {
354                 // 'NAME' not found
355                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
356         } elseif (!isset($attributes['TYPE'])) {
357                 // 'TYPE' not found
358                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
359         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
360                 // No valid type
361                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
362         } elseif (!isset($attributes['VALUE'])) {
363                 // 'VALUE' not found
364                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
365         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['OLD'])) {
366                 // Not valid/verifyable
367                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute OLD does not validate. TYPE=' . $attributes['TYPE'] . ',OLD=' . $attributes['OLD']);
368         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
369                 // Not valid/verifyable
370                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
371         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'])) {
372                 // doXmlAdminCallbackFunction is missing
373                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.');
374         }
375
376         // Add the entry to the list
377         addXmlValueToCallbackAttributes('status_list', $attributes, $attributes['NAME'], 'OLD');
378 }
379
380 // Handles the XML node 'enable-modify-entries'
381 function doXmlEnableModifyEntries ($resource, $attributes) {
382         // There are three attributes, by default
383         if (count($attributes) != 3) {
384                 // Not the right count
385                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
386         } elseif (!isset($attributes['NAME'])) {
387                 // 'NAME' not found
388                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
389         } elseif (!isset($attributes['TYPE'])) {
390                 // 'TYPE' not found
391                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
392         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
393                 // No valid type
394                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
395         } elseif (!isset($attributes['VALUE'])) {
396                 // 'VALUE' not found
397                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
398         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
399                 // Not valid/verifyable
400                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
401         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
402                 // doXmlAdminCallbackFunction is missing
403                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
404         }
405
406         // Add the entry to the array
407         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['enable_modify_entries'] = convertStringToBoolean($attributes['VALUE']);
408 }
409
410 // Handles the XML node 'table-id-column'
411 function doXmlTableIdColumn ($resource, $attributes) {
412         // There are three attributes, by default
413         if (count($attributes) != 3) {
414                 // Not the right count
415                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
416         } elseif (!isset($attributes['NAME'])) {
417                 // 'NAME' not found
418                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
419         } elseif (!isset($attributes['TYPE'])) {
420                 // 'TYPE' not found
421                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
422         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
423                 // No valid type
424                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
425         } elseif (!isset($attributes['VALUE'])) {
426                 // 'VALUE' not found
427                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
428         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
429                 // Not valid/verifyable
430                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
431         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
432                 // doXmlAdminCallbackFunction is missing
433                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
434         }
435
436         // Add the entry to the array
437         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['table_id_column'] = $attributes['VALUE'];
438 }
439
440 // Handles the XML node 'table-userid-column'
441 function doXmlTableUseridColumn ($resource, $attributes) {
442         // There are three attributes, by default
443         if (count($attributes) != 3) {
444                 // Not the right count
445                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
446         } elseif (!isset($attributes['NAME'])) {
447                 // 'NAME' not found
448                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
449         } elseif (!isset($attributes['TYPE'])) {
450                 // 'TYPE' not found
451                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
452         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
453                 // No valid type
454                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
455         } elseif (!isset($attributes['VALUE'])) {
456                 // 'VALUE' not found
457                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
458         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
459                 // Not valid/verifyable
460                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
461         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
462                 // doXmlAdminCallbackFunction is missing
463                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
464         }
465
466         // Add the entry to the array
467         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['table_userid_column'] = $attributes['VALUE'];
468 }
469
470 // Handles the XML node 'raw-userid-column-key'
471 function doXmlRawUseridColumnKey ($resource, $attributes) {
472         // There are three attributes, by default
473         if (count($attributes) != 3) {
474                 // Not the right count
475                 debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes));
476         } elseif (!isset($attributes['NAME'])) {
477                 // 'NAME' not found
478                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
479         } elseif (!isset($attributes['TYPE'])) {
480                 // 'TYPE' not found
481                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
482         } elseif (!isInvalidXmlType($attributes['TYPE'])) {
483                 // No valid type
484                 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
485         } elseif (!isset($attributes['VALUE'])) {
486                 // 'VALUE' not found
487                 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
488         } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
489                 // Not valid/verifyable
490                 debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']);
491         } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) {
492                 // doXmlAdminCallbackFunction is missing
493                 debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.');
494         }
495
496         // Add the entry to the array
497         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['raw_userid_column_key'] = $attributes['VALUE'];
498 }
499
500 // ----------------------------------------------------------------------------
501 //                                XML type validation
502 // ----------------------------------------------------------------------------
503
504 // Checks for string without any added extra data
505 function isXmlTypeString ($value) {
506         // Just let SQL_ESCAPE() do the job
507         return ($value == SQL_ESCAPE($value));
508 }
509
510 // Fake-check for array type
511 function isXmlTypeArray ($value) {
512         // This value is always a string
513         return (is_string($value));
514 }
515
516 // Check for boolean type
517 function isXmlTypeBool ($value) {
518         // Trim value
519         $value = trim($value);
520
521         // This value is always a string
522         return (($value == 'true') || ($value == 'false'));
523 }
524
525 // ----------------------------------------------------------------------------
526 //                               Private XML functions
527 // ----------------------------------------------------------------------------
528
529 // Adds given attribut to element
530 function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '', $key = '') {
531         if ($attributes['TYPE'] == 'array') {
532                 // Another nested array
533                 /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=ARRAY, element=' . $element);
534                 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$attributes['VALUE'] . '_list'] = array();
535         } elseif (!empty($extraKey)) {
536                 // Is it bool?
537                 if ($attributes['TYPE'] == 'bool') {
538                         // Then convert VALUE
539                         $attributes['VALUE'] = convertStringToBoolean($attributes['VALUE']);
540                 } // END - if
541
542                 // Sub-array (one level only)
543                 /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE']);
544                 if (trim($attributes['NAME']) == '') {
545                         // Numerical index
546                         /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
547                         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$extraKey][] = $attributes['VALUE'];
548                 } elseif (!empty($key)) {
549                         // Use from $key
550                         /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
551                         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$extraKey][$attributes[$key]] = $attributes['VALUE'];
552                 } else {
553                         // Use from NAME
554                         /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (name=' . $attributes['NAME'] . ')');
555                         $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$extraKey][$attributes['NAME']] = $attributes['VALUE'];
556                 }
557         } elseif (trim($attributes['NAME']) == '') {
558                 // Numerical index
559                 /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE']);
560                 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][] = $attributes['VALUE'];
561         } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$attributes['NAME']])) {
562                 // Already created
563                 debug_report_bug(__FUNCTION__, __LINE__, 'NAME=' . $attributes['NAME'] . ' already addded to ' . $element . '.');
564         } else {
565                 // Use from NAME
566                 /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',NAME=' . $attributes['NAME'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE']);
567                 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$attributes['NAME']] = $attributes['VALUE'];
568         }
569 }
570
571 // ----------------------------------------------------------------------------
572 //                            Execute call-back functions
573 // ----------------------------------------------------------------------------
574
575 // Execute function for doXmlAdminCallbackFunction()
576 function doXmlAdminCallbackFunctionExecute ($function, $args) {
577         // Prepare 'id_index'
578         $args['id_index'] = postRequestParameter($args['id_index']);
579
580         // Just call it
581         //* DEBUG: */ die('<pre>'.print_r($args, true).'</pre>');
582         call_user_func_array($function, $args);
583 }
584
585 // [EOF]
586 ?>