2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 07/08/2011 *
4 * =================== Last change: 07/08/2011 *
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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Handles the XML node 'admin-entry-meta-data'
44 function doXmlAdminEntryMetaData ($resource, $attributes) {
46 * This node has no attributes by default so it remains just with this
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'])) {
59 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
60 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
62 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
63 } elseif (!isset($attributes['VALUE'])) {
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']);
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();
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'])) {
85 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
86 } elseif (!isset($attributes['TYPE'])) {
88 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
89 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
91 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
92 } elseif (!isset($attributes['VALUE'])) {
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.');
103 // Add the POST data index for 'id'
104 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['id_index'] = $attributes['VALUE'];
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'])) {
115 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
116 } elseif (!isset($attributes['TYPE'])) {
118 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
119 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
121 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
122 } elseif (!isset($attributes['VALUE'])) {
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.');
133 // Add the database's name
134 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['database_table'] = $attributes['VALUE'];
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));
146 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['column_list'] = array();
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'])) {
157 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
158 } elseif (!isset($attributes['TYPE'])) {
160 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
161 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
163 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
164 } elseif (!isset($attributes['VALUE'])) {
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.');
175 // Add the entry to the list
176 addXmlValueToCallbackAttributes('column_list', $attributes);
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));
188 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['callback_list'] = array();
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'])) {
199 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
200 } elseif (!isset($attributes['TYPE'])) {
202 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
203 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
205 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
206 } elseif (!isset($attributes['VALUE'])) {
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.');
217 // Add the entry to the list
218 addXmlValueToCallbackAttributes('callback_list', $attributes);
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));
230 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list'] = array();
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'])) {
241 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
242 } elseif (!isset($attributes['TYPE'])) {
244 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
245 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
247 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
248 } elseif (!isset($attributes['VALUE'])) {
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.');
259 // Add the entry to the list
260 addXmlValueToCallbackAttributes('extra_list', $attributes);
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.');
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'])) {
283 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
284 } elseif (!isset($attributes['TYPE'])) {
286 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
287 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
289 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
290 } elseif (!isset($attributes['VALUE'])) {
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.');
301 // Add the entry to the list
302 addXmlValueToCallbackAttributes('extra_list', $attributes, 'member_list');
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'])) {
313 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
314 } elseif (!isset($attributes['TYPE'])) {
316 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
317 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
319 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
320 } elseif (!isset($attributes['VALUE'])) {
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.');
331 // Add the entry to the list
332 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'][$attributes['VALUE']] = array();
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.');
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'])) {
355 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
356 } elseif (!isset($attributes['TYPE'])) {
358 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
359 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
361 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
362 } elseif (!isset($attributes['VALUE'])) {
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.');
376 // Add the entry to the list
377 addXmlValueToCallbackAttributes('status_list', $attributes, $attributes['NAME'], 'OLD');
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'])) {
388 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
389 } elseif (!isset($attributes['TYPE'])) {
391 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
392 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
394 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
395 } elseif (!isset($attributes['VALUE'])) {
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.');
406 // Add the entry to the array
407 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['enable_modify_entries'] = convertStringToBoolean($attributes['VALUE']);
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'])) {
418 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
419 } elseif (!isset($attributes['TYPE'])) {
421 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
422 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
424 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
425 } elseif (!isset($attributes['VALUE'])) {
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.');
436 // Add the entry to the array
437 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['table_id_column'] = $attributes['VALUE'];
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'])) {
448 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
449 } elseif (!isset($attributes['TYPE'])) {
451 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
452 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
454 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
455 } elseif (!isset($attributes['VALUE'])) {
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.');
466 // Add the entry to the array
467 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['table_userid_column'] = $attributes['VALUE'];
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'])) {
478 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.');
479 } elseif (!isset($attributes['TYPE'])) {
481 debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
482 } elseif (!isInvalidXmlType($attributes['TYPE'])) {
484 debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
485 } elseif (!isset($attributes['VALUE'])) {
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.');
496 // Add the entry to the array
497 $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['raw_userid_column_key'] = $attributes['VALUE'];
500 // ----------------------------------------------------------------------------
501 // XML type validation
502 // ----------------------------------------------------------------------------
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));
510 // Fake-check for array type
511 function isXmlTypeArray ($value) {
512 // This value is always a string
513 return (is_string($value));
516 // Check for boolean type
517 function isXmlTypeBool ($value) {
519 $value = trim($value);
521 // This value is always a string
522 return (($value == 'true') || ($value == 'false'));
525 // ----------------------------------------------------------------------------
526 // Private XML functions
527 // ----------------------------------------------------------------------------
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)) {
537 if ($attributes['TYPE'] == 'bool') {
538 // Then convert VALUE
539 $attributes['VALUE'] = convertStringToBoolean($attributes['VALUE']);
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']) == '') {
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)) {
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'];
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'];
557 } elseif (trim($attributes['NAME']) == '') {
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']])) {
563 debug_report_bug(__FUNCTION__, __LINE__, 'NAME=' . $attributes['NAME'] . ' already addded to ' . $element . '.');
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'];
571 // ----------------------------------------------------------------------------
572 // Execute call-back functions
573 // ----------------------------------------------------------------------------
575 // Execute function for doXmlAdminCallbackFunction()
576 function doXmlAdminCallbackFunctionExecute ($function, $args) {
577 // Prepare 'id_index'
578 $args['id_index'] = postRequestParameter($args['id_index']);
581 //* DEBUG: */ die('<pre>'.print_r($args, true).'</pre>');
582 call_user_func_array($function, $args);