More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / wrapper-functions.php
index 1abc3ca5de7261f0e0e92c04bd91e3cef6889cff..6af2c038bd453976b151379c6307dee53c0c22fc 100644 (file)
@@ -499,23 +499,14 @@ function isConfigLocalLoaded () {
 
 // Checks wether a nickname or userid was entered and caches the result
 function isNicknameUsed ($userid) {
-       // Default is false
-       $isUsed = false;
-
        // Is the cache there
-       if (isset($GLOBALS['is_nickname_used'][$userid])) {
-               // Then use it
-               $isUsed = $GLOBALS['is_nickname_used'][$userid];
-       } else {
+       if (!isset($GLOBALS['is_nickname_used'][$userid])) {
                // Determine it
-               $isUsed = (('' . round($userid) . '') != $userid);
-
-               // And write it to the cache
-               $GLOBALS['is_nickname_used'][$userid] = $isUsed;
-       }
+               $GLOBALS['is_nickname_used'][$userid] = (('' . round($userid) . '') != $userid);
+       } // END - if
 
        // Return the result
-       return $isUsed;
+       return $GLOBALS['is_nickname_used'][$userid];
 }
 
 // Getter for 'what' value
@@ -885,7 +876,7 @@ function getCurrentUserId () {
 
 // Checks if current userid is set
 function isCurrentUserIdSet () {
-       return ((isset($GLOBALS['current_userid'])) && ($GLOBALS['current_userid'] > 0));
+       return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
 }
 
 // Checks wether we are debugging template cache
@@ -908,7 +899,7 @@ function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
                $data = '{--USERNAME_GUEST--}';
 
                // Can we fetch the user data?
-               if (($userid > 0) && (fetchUserData($userid, $keyColumn))) {
+               if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) {
                        // Now get the data back
                        $data = getUserData($valueColumn);
                } // END - if
@@ -1535,5 +1526,29 @@ function getApInactiveSince () {
        return $GLOBALS['ap_inactive_since'];
 }
 
+// Checks wether proxy configuration is used
+function isProxyUsed () {
+       // Do we have cache?
+       if (!isset($GLOBALS['is_proxy_used'])) {
+               // Determine it
+               $GLOBALS['is_proxy_used'] = ((getExtensionVersion('sql_patches') >= '0.4.3') && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['is_proxy_used'];
+}
+
+// Checks wether POST data contains selections
+function ifPostContainsSelections ($element = 'sel') {
+       // Do we have cache?
+       if (!isset($GLOBALS['post_contains_selections'][$element])) {
+               // Determine it
+               $GLOBALS['post_contains_selections'][$element] = (countPostSelection($element) > 0);
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['post_contains_selections'][$element];
+}
+
 // [EOF]
 ?>