]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Required database changes for configuration entries in templates added
[mailer.git] / inc / wrapper-functions.php
index bbe9c0c87932b3b860a92bd60da0199b6946970c..c59e12c9230ff867178214fe42712c79bf40bd95 100644 (file)
@@ -114,7 +114,7 @@ function clearOutputBuffer () {
 // Loads an include file and logs any missing files for debug purposes
 function loadInclude ($INC) {
        // Add the path. This is why we need a trailing slash in config.php
-       $FQFN = constant('PATH') . $INC;
+       $FQFN = getConfig('PATH') . $INC;
 
        // Is the include file there?
        if (!isIncludeReadable($INC)) {
@@ -132,7 +132,7 @@ function loadIncludeOnce ($INC) {
        // Is it not loaded?
        if (!isset($GLOBALS['load_once'][$INC])) {
                // Mark it as loaded
-               $GLOBALS['load_once'][$INC] = "loaded";
+               $GLOBALS['load_once'][$INC] = 'loaded';
 
                // Then try to load it
                loadInclude($INC);
@@ -142,7 +142,7 @@ function loadIncludeOnce ($INC) {
 // Checks wether an include file (non-FQFN better) is readable
 function isIncludeReadable ($INC) {
        // Construct FQFN
-       $FQFN = constant('PATH') . $INC;
+       $FQFN = getConfig('PATH') . $INC;
 
        // Is it readable?
        return isFileReadable($FQFN);
@@ -180,21 +180,19 @@ function decodeEntities ($str) {
 // Merges an array together but only if both are arrays
 function merge_array ($array1, $array2) {
        // Are both an array?
-       if ((is_array($array1)) && (is_array($array2))) {
-               // Merge all together
-               return array_merge($array1, $array2);
-       } elseif (is_array($array1)) {
-               // Return left array
-               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
-               return $array1;
-       } elseif (is_array($array2)) {
-               // Return right array
-               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
-               return $array2;
+       if ((!is_array($array1)) && (!is_array($array2))) {
+               // Both are not arrays
+               debug_report_bug(__FUNCTION__ . ': No arrays provided!');
+       } elseif (!is_array($array1)) {
+               // Left one is not an array
+               debug_report_bug(__FUNCTION__, sprintf("array1 is not an array. array != %s", gettype($array1)));
+       } elseif (!is_array($array2)) {
+               // Right one is not an array
+               debug_report_bug(__FUNCTION__, sprintf("array2 is not an array. array != %s", gettype($array2)));
        }
 
-       // Both are not arrays
-       debug_report_bug(__FUNCTION__.": No arrays provided!");
+       // Merge all together
+       return array_merge($array1, $array2);
 }
 
 // Check if given FQFN is a readable file
@@ -287,10 +285,10 @@ function isInstalled () {
        return (
        (
                // New config file found and loaded
-               getConfig('MXCHANGE_INSTALLED') == 'Y'
+               isIncludeReadable('inc/cache/config-local.php')
        ) || (
-               // Fall-back!
-               isIncludeReadable('inc/config.php')
+               // Fall-back to config
+               getConfig('MXCHANGE_INSTALLED') == 'Y'
        ) || (
                (
                        // New config file found, but not yet read
@@ -352,7 +350,7 @@ function copyFileVerified ($source, $dest, $chmod = '') {
        // Is the target directory there?
        if (!isDirectory(dirname($dest))) {
                // Then abort here
-               debug_report_bug('Cannot find directory ' . str_replace(constant('PATH'), '', dirname($dest)) . '.');
+               debug_report_bug('Cannot find directory ' . str_replace(getConfig('PATH'), '', dirname($dest)) . '.');
        } // END - if
 
        // Now try to copy it
@@ -434,7 +432,7 @@ function isNicknameUsed ($userid) {
                $isUsed = $GLOBALS['cache_probe_nicknames'][$userid];
        } else {
                // Determine it
-               $isUsed = ((EXT_IS_ACTIVE('nickname')) && ((''.round($userid).'') != $userid));
+               $isUsed = ((EXT_IS_ACTIVE('nickname')) && (('' . round($userid) . '') != $userid));
 
                // And write it to the cache
                $GLOBALS['cache_probe_nicknames'][$userid] = $isUsed;
@@ -444,5 +442,171 @@ function isNicknameUsed ($userid) {
        return $isUsed;
 }
 
+// Getter for 'what' value
+function getWhat () {
+       // Default is null
+       $what = null;
+
+       // Is the value set?
+       if (isWhatSet(true)) {
+               // Then use it
+               $what = $GLOBALS['what'];
+       } // END - if
+
+       // Return it
+       return $what;
+}
+
+// Setter for 'what' value
+function setWhat ($newWhat) {
+       $GLOBALS['what'] = SQL_ESCAPE($newWhat);
+}
+
+// Setter for 'what' from configuration
+function setWhatFromConfig ($configEntry) {
+       // Get 'what' from config
+       $what = getConfig($configEntry);
+
+       // Set it
+       setWhat($what);
+}
+
+// Checks wether what is set and optionally aborts on miss
+function isWhatSet ($abortOnMiss =  false) {
+       // Check for it
+       $isset = (isset($GLOBALS['what']));
+
+       // Should we abort here?
+       if (($abortOnMiss === true) && ($isset === false)) {
+               // Output backtrace
+               debug_report_bug('what is empty.');
+       } // END - if
+
+       // Return it
+       return $isset;
+}
+
+// Getter for 'action' value
+function getAction () {
+       // Default is null
+       $action = null;
+
+       // Is the value set?
+       if (isActionSet(true)) {
+               // Then use it
+               $action = $GLOBALS['action'];
+       } // END - if
+
+       // Return it
+       return $action;
+}
+
+// Setter for 'action' value
+function setAction ($newAction) {
+       $GLOBALS['action'] = SQL_ESCAPE($newAction);
+}
+
+// Checks wether action is set and optionally aborts on miss
+function isActionSet ($abortOnMiss =  false) {
+       // Check for it
+       $isset = (isset($GLOBALS['action']));
+
+       // Should we abort here?
+       if (($abortOnMiss === true) && ($isset === false)) {
+               // Output backtrace
+               debug_report_bug('action is empty.');
+       } // END - if
+
+       // Return it
+       return $isset;
+}
+
+// Getter for 'module' value
+function getModule () {
+       // Default is null
+       $module = null;
+
+       // Is the value set?
+       if (isModuleSet(true)) {
+               // Then use it
+               $module = $GLOBALS['module'];
+       } // END - if
+
+       // Return it
+       return $module;
+}
+
+// Setter for 'module' value
+function setModule ($newModule) {
+       $GLOBALS['module'] = SQL_ESCAPE($newModule);
+}
+
+// Checks wether module is set and optionally aborts on miss
+function isModuleSet ($abortOnMiss =  false) {
+       // Check for it
+       $isset = (!empty($GLOBALS['module']));
+
+       // Should we abort here?
+       if (($abortOnMiss === true) && ($isset === false)) {
+               // Output backtrace
+               debug_report_bug('module is empty.');
+       } // END - if
+
+       // Return it
+       return $isset;
+}
+
+// Getter for 'output_mode' value
+function getOutputMode () {
+       // Default is null
+       $output_mode = null;
+
+       // Is the value set?
+       if (isOutputModeSet(true)) {
+               // Then use it
+               $output_mode = $GLOBALS['output_mode'];
+       } // END - if
+
+       // Return it
+       return $output_mode;
+}
+
+// Setter for 'output_mode' value
+function setOutputMode ($newOutputMode) {
+       $GLOBALS['output_mode'] = SQL_ESCAPE($newOutputMode);
+}
+
+// Checks wether output_mode is set and optionally aborts on miss
+function isOutputModeSet ($abortOnMiss =  false) {
+       // Check for it
+       $isset = (isset($GLOBALS['output_mode']));
+
+       // Should we abort here?
+       if (($abortOnMiss === true) && ($isset === false)) {
+               // Output backtrace
+               debug_report_bug('output_mode is empty.');
+       } // END - if
+
+       // Return it
+       return $isset;
+}
+
+// Enables block-mode
+function enableBlockMode ($enabled = true) {
+       $GLOBALS['block_mode'] = $enabled;
+}
+
+// Checks wether block-mode is enabled
+function isBlockModeEnabled () {
+       // Abort if not set
+       if (!isset($GLOBALS['block_mode'])) {
+               // Needs to be fixed
+               debug_report_bug(__FUNCTION__ . ': block_mode is not set.');
+       } // END - if
+
+       // Return it
+       return $GLOBALS['block_mode'];
+}
+
 // [EOF]
 ?>