+ return $mailMode;
+}
+
+// Extract code from response
+function YOOMEDIA_GET_ERRORCODE_FROM_RESULT ($response) {
+ // The response must be an array
+ assert(is_array($response));
+
+ // Bad code as default
+ $code = -999;
+
+ // Which response should we parse?
+ if ((isset($response[8])) && (count($response) == 9)) {
+ // Use error code from element 8 (mostly API errors)
+ $codeArray = explode('<br>', $response[8]);
+
+ // Use only the first element
+ $code = bigintval($codeArray[0]);
+ } elseif (!empty($response[0])) {
+ // Merge response together
+ $parts = explode('|', implode('', $response));
+
+ // If we have only one part, we got an error
+ if (count($parts) > 1) {
+ // All fine
+ $code = '0';
+ } else {
+ // Begin with extraction of error code
+ $codeArray = explode(' ', $response[0]);
+ $code = $codeArray[0];
+ $codeArray = explode('<br />', $code);
+ $code = $codeArray[0];
+ $codeArray = explode('<br>', $code);
+ $code = $codeArray[0];
+
+ // Remove all new-line characters
+ $codeArray = explode(chr(10), $code);
+ $code = $codeArray[0];
+
+ // Remove carrige-return
+ $code = trim(str_replace(chr(10), '', $code));
+
+ // Is it still empty?
+ if (empty($code)) {
+ // Then fix it
+ $code = -999;
+ } // END - if
+ }
+ } elseif (count($response) == 0) {
+ // All fine, but empty result
+ $code = '0';
+ } else {
+ // Should not happen!
+ reportBug(__FUNCTION__, __LINE__, 'Cannot parse response. Raw response:<pre>' . print_r($response, true) . '</pre>');
+ }
+
+ // Return error code
+ return $code;