]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
WARNING: id is very generic, it has been now renamed to booking_id, please fix your...
[mailer.git] / inc / functions.php
index 321eddfaf5b202ee83831f3d022567d043277528..a941932a6ca5d471dbe8008484b418f6c5802fbd 100644 (file)
@@ -1290,41 +1290,41 @@ function handleExtraValues ($filterFunction, $value, $extraValue) {
        $ret = $value;
 
        // Is there a special filter function?
-       if (!empty($filterFunction)) {
-               // Does the filter function exist?
-               if (function_exists($filterFunction)) {
-                       // Is there extra parameters here?
-                       if ((!is_null($extraValue)) && (!empty($extraValue))) {
-                               // Put both parameters in one new array by default
-                               $args = array($value, $extraValue);
-
-                               // If we have an array simply use it and pre-extend it with our value
-                               if (is_array($extraValue)) {
-                                       // Make the new args array
-                                       $args = merge_array(array($value), $extraValue);
-                               } // END - if
+       if ((empty($filterFunction)) || (!function_exists($filterFunction))) {
+               // Call-back function does not exist or is empty
+               reportBug(__FUNCTION__, __LINE__, 'Filter function ' . $filterFunction . ' does not exist or is empty: value[' . gettype($value) . ']=' . $value . ',extraValue[' . gettype($extraValue) . ']=' . $extraValue);
+       } // END - if
 
-                               // Call the multi-parameter call-back
-                               $ret = call_user_func_array($filterFunction, $args);
+       // Is there extra parameters here?
+       if ((!is_null($extraValue)) && (!empty($extraValue))) {
+               // Put both parameters in one new array by default
+               $args = array($value, $extraValue);
 
-                               // Is $ret 'true'?
-                               if ($ret === TRUE) {
-                                       // Test passed, so write direct value
-                                       $ret = $args;
-                               } // END - if
-                       } else {
-                               // One parameter call
-                               $ret = call_user_func($filterFunction, $value);
-                               //* BUG */ die('ret['.gettype($ret).']=' . $ret . ',value=' . $value.',filterFunction=' . $filterFunction);
-
-                               // Is $ret 'true'?
-                               if ($ret === TRUE) {
-                                       // Test passed, so write direct value
-                                       $ret = $value;
-                               } // END - if
-                       }
+               // If we have an array simply use it and pre-extend it with our value
+               if (is_array($extraValue)) {
+                       // Make the new args array
+                       $args = merge_array(array($value), $extraValue);
                } // END - if
-       } // END - if
+
+               // Call the multi-parameter call-back
+               $ret = call_user_func_array($filterFunction, $args);
+
+               // Is $ret 'true'?
+               if ($ret === TRUE) {
+                       // Test passed, so write direct value
+                       $ret = $args;
+               } // END - if
+       } else {
+               // One parameter call
+               $ret = call_user_func($filterFunction, $value);
+               //* BUG */ die('ret['.gettype($ret).']=' . $ret . ',value=' . $value.',filterFunction=' . $filterFunction);
+
+               // Is $ret 'true'?
+               if ($ret === TRUE) {
+                       // Test passed, so write direct value
+                       $ret = $value;
+               } // END - if
+       }
 
        // Return the value
        return $ret;
@@ -1423,8 +1423,8 @@ function rebuildCache ($cache, $inc = '', $force = FALSE) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("cache=%s, inc=%s, force=%s", $cache, $inc, intval($force)));
 
        // Shall I remove the cache file?
-       if ((isExtensionInstalled('cache')) && (isCacheInstanceValid())) {
-               // Rebuild cache
+       if ((isExtensionInstalled('cache')) && (isCacheInstanceValid()) && (isHtmlOutputMode())) {
+               // Rebuild cache only in HTML output-mode
                if ($GLOBALS['cache_instance']->loadCacheFile($cache)) {
                        // Destroy it
                        $GLOBALS['cache_instance']->removeCacheFile($force);
@@ -2157,7 +2157,7 @@ function detectMultiBytePrefix ($str) {
        return $mbPrefix;
 }
 
-// Searches the given array for a sub-string match and returns all found keys in an array
+// Searches given array for a sub-string match and returns all found keys in an array
 function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) {
        // Init array for all found keys
        $keys = array();
@@ -2409,6 +2409,21 @@ function isIp4AddressValid ($address) {
        return $GLOBALS[__FUNCTION__][$address];
 }
 
+// Returns the string if not empty or FALSE if empty
+function validateIsEmpty ($str) {
+       // Trim it
+       $trimmed = trim($str);
+
+       // Is the string empty?
+       if (empty($trimmed)) {
+               // Then set FALSE
+               $str = FALSE;
+       } // END - if
+
+       // Return it
+       return $str;
+}
+
 // ----------------------------------------------------------------------------
 //              "Translatation" functions for points_data table
 // ----------------------------------------------------------------------------
@@ -2449,37 +2464,43 @@ function translatePointsSubject ($subject) {
        return translateGeneric('POINTS_SUBJECT', $subject);
 }
 
-// "Translates" the given points account type
+// "Translates" given points account type
 function translatePointsAccountType ($accountType) {
        // Return it
        return translateGeneric('POINTS_ACCOUNT_TYPE', $accountType);
 }
 
-// "Translates" the given points "locked mode"
+// "Translates" given points "locked mode"
 function translatePointsLockedMode ($lockedMode) {
        // Return it
        return translateGeneric('POINTS_LOCKED_MODE', $lockedMode);
 }
 
-// "Translates" the given points payment method
+// "Translates" given points payment method
 function translatePointsPaymentMethod ($paymentMethod) {
        // Return it
        return translateGeneric('POINTS_PAYMENT_METHOD', $paymentMethod);
 }
 
-// "Translates" the given points account provider
+// "Translates" given points account provider
 function translatePointsAccountProvider ($accountProvider) {
        // Return it
        return translateGeneric('POINTS_ACCOUNT_PROVIDER', $accountProvider);
 }
 
-// "Translates" the given points notify recipient
+// "Translates" given points notify recipient
 function translatePointsNotifyRecipient ($notifyRecipient) {
        // Return it
        return translateGeneric('POINTS_NOTIFY_RECIPIENT', $notifyRecipient);
 }
 
-// Translates task type to a human-readable version
+// "Translates" given mode to a human-readable version
+function translatePointsMode ($pointsMode) {
+       // Return it
+       return translateGeneric('POINTS_MODE', $pointsMode);
+}
+
+// "Translates" task type to a human-readable version
 function translateTaskType ($taskType) {
        // Return it
        return translateGeneric('ADMIN_TASK_TYPE', $taskType);