]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Opps (sorry guys)
[mailer.git] / inc / wrapper-functions.php
index 3dbbfa8dc3e3b8ae5c0f11f6777ce0e2ccf867b7..47bf5c07afd39968bd7d9c40083e76f4a079d4da 100644 (file)
@@ -972,6 +972,10 @@ function getUserDataArray () {
 function isUserDataValid () {
        // User id should not be zero so abort here
        if (!isCurrentUserIdSet()) {
+               // Debug message
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
+
+               // Abort here
                return false;
        } // END - if
 
@@ -987,18 +991,25 @@ function isUserDataValid () {
 
 // Setter for current userid
 function setCurrentUserId ($userid) {
-       // Set userid
-       $GLOBALS['current_userid'] = bigintval($userid);
-
-       // Unset it to re-determine the actual state
-       unset($GLOBALS['is_userdata_valid'][$userid]);
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
 
        // Is the cache from below functions different?
-       if ((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) {
+       if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
                // Then unset both
                unset($GLOBALS['getCurrentUserId']);
                unset($GLOBALS['isCurrentUserIdSet']);
+               unset($GLOBALS['isValidUserId'][$userid]);
        } // END - if
+
+       // Set userid
+       $GLOBALS['current_userid'] = bigintval($userid);
+
+       // Unset it to re-determine the actual state
+       unset($GLOBALS['is_userdata_valid'][$userid]);
+
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
 }
 
 // Getter for current userid
@@ -1249,12 +1260,6 @@ function isValidUserId ($userid) {
        // Debug message
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid);
 
-       // Handle NULL
-       if (is_null($userid)) {
-               // Do not handle this as of below isset() will always return false
-               return false;
-       } // END - if
-
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__][$userid])) {
                // Check it out
@@ -1262,6 +1267,7 @@ function isValidUserId ($userid) {
        } // END - if
 
        // Return cache
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',result=' . intval($GLOBALS[__FUNCTION__][$userid]));
        return $GLOBALS[__FUNCTION__][$userid];
 }
 
@@ -1817,6 +1823,18 @@ function getMtWord2 () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// "Getter" for mt_word2
+function getMtWord3 () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('mt_word3');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // "Getter" for main_title
 function getMainTitle () {
        // Do we have cache?
@@ -2796,6 +2814,40 @@ function parseFloat ($floatString){
        return floatval($floatString);
 }
 
+/**
+ * Searches a multi-dimensional array (as used in many places) for given
+ * key/value pair as taken from user comments from PHP documentation website.
+ *
+ * @param      $array          An array with one or more dimensions
+ * @param      $key            Key to look for
+ * @param      $valur          Value to look for
+ * @return     $results        Resulted array or empty array if $array is no array
+ * @author     sunelbe<at>gmail<dot>com
+ * @link       http://de.php.net/manual/en/function.array-search.php#110120
+ */
+function search_array ($array, $key, $value) {
+       // Init array result
+       $results = array();
+
+       // Is $array really an array?
+       if (is_array($array)) {
+               // Does key and value match?
+               if (isset($array[$key]) && $array[$key] == $value) {
+                       // Then add it as result
+                       $results[] = $array;
+               } // END - if
+
+               // Search for whole array
+               foreach ($array as $subArray) {
+                       // Search recursive and merge again
+                       $results = merge_array($results, search_array($subArray, $key, $value));
+               } // END - foreach
+       } // END - if
+
+       // Return resulting array
+       return $results;
+}
+
 // Generates a YES/NO option list from given default
 function generateYesNoOptions ($defaultValue = '') {
        // Generate it