]> git.mxchange.org Git - mailer.git/blobdiff - inc/callback-functions.php
Fix for SQL with ref_depth=NULL
[mailer.git] / inc / callback-functions.php
index 59c06e66ec95ca9315fa8b414ba01067d1e5673f..aad0498b59475488733bacb3c62a9b6d5ad1cce4 100644 (file)
@@ -628,6 +628,54 @@ function doXmlWhereSelectFromList ($resource, $attributes) {
        $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['where_select_list'] = array();
 }
 
+// Handles the XML node 'where-select-from-list-entry'
+function doXmlWhereSelectFromListEntry ($resource, $attributes) {
+       // There are five attributes, by default
+       if (count($attributes) != 5) {
+               // Not the right count
+               debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
+       } elseif (!isset($attributes['TYPE'])) {
+               // 'TYPE' not found
+               debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
+       } elseif (!isset($attributes['TABLE'])) {
+               // 'TABLE' not found
+               debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
+       } elseif (!isset($attributes['VALUE'])) {
+               // 'VALUE' not found
+               debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
+       } elseif (!isset($attributes['CONDITION'])) {
+               // 'CONDITION' not found
+               debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute CONDITION not found.');
+       } elseif (!isset($attributes['LOOK-FOR'])) {
+               // 'LOOK-FOR' not found
+               debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute LOOK-FOR not found.');
+       } elseif (!isInvalidXmlType($attributes['TYPE'])) {
+               // No valid type
+               debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
+       } elseif ((trim($attributes['TABLE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE']))) {
+               // 'TABLE' not valid/verifyable
+               debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TABLE=' . $attributes['TABLE']);
+       } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
+               // 'VALUE' not valid/verifyable
+               debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
+       } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['CONDITION'])) {
+               // 'CONDITION' not valid/verifyable
+               debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION does not validate. CONDITION=' . $attributes['CONDITION']);
+       } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['LOOK-FOR'])) {
+               // 'LOOK-FOR' not valid/verifyable
+               debug_report_bug(__FUNCTION__, __LINE__, 'Attribute LOOK-FOR does not validate. LOOK-FOR=' . $attributes['LOOK-FOR']);
+       } elseif (!isXmlConditionValid($attributes['CONDITION'])) {
+               // 'CONDITION' is not known
+               debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION is not valid. LOOK-FOR=' . $attributes['CONDITION']);
+       } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
+               // doXmlCallbackFunction is missing
+               debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-column-list not included around this node. Please fix your XML.');
+       }
+
+       // Add the entry to the array
+       addXmlValueToCallbackAttributes('where_select_list', $attributes);
+}
+
 // Handles the XML node 'order-by-list'
 function doXmlOrderByList ($resource, $attributes) {
        // There should be no attributes
@@ -655,15 +703,15 @@ function doXmlOrderByListEntry ($resource, $attributes) {
        } elseif (!isset($attributes['TYPE'])) {
                // 'TYPE' not found
                debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
-       } elseif (!isInvalidXmlType($attributes['TYPE'])) {
-               // No valid type
-               debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
        } elseif (!isset($attributes['TABLE'])) {
                // 'TABLE' not found
                debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
        } elseif (!isset($attributes['VALUE'])) {
                // 'VALUE' not found
                debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
+       } elseif (!isInvalidXmlType($attributes['TYPE'])) {
+               // No valid type
+               debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
        } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['ORDER'])) {
                // 'ORDER' not valid/verifyable
                debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ORDER does not validate. ORDER=' . $attributes['ORDER']);
@@ -928,15 +976,15 @@ function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '',
                /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ' - ANALYSING...');
                if (trim($attributes['NAME']) == '') {
                        // Numerical index
-                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
                        $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][] = $attributes['VALUE'];
                } elseif (!empty($key)) {
                        // Use from $key
-                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
                        $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes[$key]] = $attributes['VALUE'];
                } else {
                        // Use from NAME
-                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (NAME=' . $attributes['NAME'] . ')');
+                       /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (NAME=' . $attributes['NAME'] . ')');
                        $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes['NAME']] = $attributes['VALUE'];
                }
        } elseif ((isset($attributes['FUNCTION'])) && (isset($attributes['ALIAS']))) {
@@ -953,15 +1001,27 @@ function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '',
                );
 
                // Add the entry
-               /* 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'] . ')');
+               /* 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'] . ')');
+               $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
+       } elseif ((isset($attributes['CONDITION'])) && (isset($attributes['LOOK-FOR']))) {
+               // CONDITION/LOOK-FOR detected
+               // Init array
+               $array =  array(
+                       'column'    => trim($attributes['VALUE']),
+                       'table'     => trim($attributes['TABLE']),
+                       'condition' => convertXmlContion(trim($attributes['CONDITION'])),
+                       'look_for'  => trim($attributes['LOOK-FOR'])
+               );
+
+               /* 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'] . ')');
                $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
        } elseif (isset($attributes['CALLBACK'])) {
                // CALLBACK/VALUE detected
-               /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',CALLBACK[' . gettype($attributes['CALLBACK']) . ']=' . $attributes['CALLBACK'] . ' - CALLBACK! (VALUE=' . $attributes['VALUE'] . ')');
+               /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',CALLBACK[' . gettype($attributes['CALLBACK']) . ']=' . $attributes['CALLBACK'] . ' - CALLBACK! (VALUE=' . $attributes['VALUE'] . ')');
                $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['VALUE']] = $attributes['CALLBACK'];
        } elseif (isset($attributes['ORDER'])) {
                // ORDER/TABLE detected
-               /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',ORDER[' . gettype($attributes['ORDER']) . ']=' . $attributes['ORDER'] . ' - ORDER! (VALUE=' . $attributes['VALUE'] . ')');
+               /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',ORDER[' . gettype($attributes['ORDER']) . ']=' . $attributes['ORDER'] . ' - ORDER! (VALUE=' . $attributes['VALUE'] . ')');
                $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['ORDER']][$attributes['TABLE']] = $attributes['VALUE'];
        } elseif (isset($attributes['COLUMN'])) {
                // COLUMN/VALUE detected