]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/sponsor_functions.php
Added more config wrappers
[mailer.git] / inc / libs / sponsor_functions.php
index ee1f9050b9f01966cb2a485522809b272feaf72b..b60e222682f0fbf7eb3c80e2ff23a0aeb0a9e961 100644 (file)
@@ -43,10 +43,10 @@ if (!defined('__SECURITY')) {
 //
 function handleSponsorRequest ($postData, $update=false, $messageArray = array(), $RET_STATUS=false) {
        // Init a lot variables
-       $SAVE = true;
-       $UPDATE = false;
-       $skip = false;
-       $ALREADY = false;
+       $SAVE = TRUE;
+       $UPDATE = FALSE;
+       $skip = FALSE;
+       $ALREADY = FALSE;
        $ret = 'unused';
 
        // Skip these entries
@@ -66,24 +66,24 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                // Check only posted input entries not the submit button
                                switch ($k) {
                                        case 'email':
-                                               $ALREADY = false;
+                                               $ALREADY = FALSE;
                                                if (!isEmailValid($v)) {
                                                        // Email address is not valid
-                                                       $SAVE = false;
+                                                       $SAVE = FALSE;
                                                } else {
-                                                       // Do we want to add a new sponsor or update his data?
+                                                       // Add a new sponsor or update his data?
                                                        $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE email='%s' LIMIT 1",
-                                                       array($postData['email']), __FUNCTION__, __LINE__);
+                                                               array($postData['email']), __FUNCTION__, __LINE__);
 
                                                        // Is a sponsor alread in the db?
                                                        if (SQL_NUMROWS($result) == 1) {
                                                                // Yes, he is!
                                                                if ((getWhat() == 'add_sponsor') || ($update)) {
                                                                        // Already found
-                                                                       $ALREADY = true;
+                                                                       $ALREADY = TRUE;
                                                                } else {
                                                                        // Update his data
-                                                                       $UPDATE = true;
+                                                                       $UPDATE = TRUE;
                                                                }
                                                        }
 
@@ -103,7 +103,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                        case 'url':
                                                if (!isUrlValid($v)) {
                                                        // Don't save the URL
-                                                       $SAVE = false;
+                                                       $SAVE = FALSE;
                                                } // END - if
                                                break;
 
@@ -113,7 +113,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                                break;
                                } // END - switch
 
-                               if ((!empty($k)) && ($skip == false)) {
+                               if ((!empty($k)) && ($skip == FALSE)) {
                                        // Add data
                                        array_push($DATA['keys']  , $k);
                                        array_push($DATA['values'], $v);
@@ -122,7 +122,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                } // END - foreach
 
                // Save sponsor?
-               if ($SAVE === true) {
+               if ($SAVE === TRUE) {
                        // Default is no force even when a guest want to abuse this force switch
                        if ((empty($postData['force'])) || (!isAdmin())) $postData['force'] = '0';
 
@@ -144,10 +144,10 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                // Generate message
                                $message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_UPDATED--}', 'updated', $messageArray);
                                $ret = 'updated';
-                       } elseif (($ALREADY === false) || (($postData['force'] == 1) && (isAdmin()))) {
+                       } elseif (($ALREADY === FALSE) || (($postData['force'] == 1) && (isAdmin()))) {
                                // Add new sponsor, first add more data
                                array_push($DATA['keys'], 'status');
-                               if (($update === true) && (isAdmin()) && (getWhat() == 'add_sponsor')) {
+                               if (($update === TRUE) && (isAdmin()) && (getWhat() == 'add_sponsor')) {
                                        // Only allowed for admin
                                        array_push($DATA['values'], 'PENDING');
 
@@ -174,7 +174,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                unset($DATA['values'][$key]);
 
                                // Implode all data into strings
-                               $keyArray   = implode('`,`'  , $DATA['keys']);
+                               $keyArray   = implode('`, `'  , $DATA['keys']);
                                $valueArray = str_repeat("%s', '", count($DATA['values']) - 1);
 
                                // Generate string
@@ -183,7 +183,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                // Generate message
                                $message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_ADDED--}', 'added', $messageArray);
                                $ret = 'added';
-                       } elseif (($update === true) && (isAdmin())) {
+                       } elseif (($update === TRUE) && (isAdmin())) {
                                // Add all data as hidden data
                                $OUT = '';
                                foreach ($postData as $k => $v) {
@@ -198,7 +198,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray = array()
                                $content['email']  = $postData['email'];
 
                                // Ask for adding a sponsor with same email address
-                               loadTemplate('admin_add_sponsor_already', false, $content);
+                               loadTemplate('admin_add_sponsor_already', FALSE, $content);
                                return;
                        } else {
                                // Already added!
@@ -242,8 +242,8 @@ function translateSponsorStatus ($status) {
 
 // Search for an email address in the database
 function isSponsorRegisteredWithEmail ($email) {
-       // Do we already have the provided email address in our DB?
-       $ret = (countSumTotalData($email, 'sponsor_data', 'id', 'email', true) == 1);
+       // Is there already the provided email address in database?
+       $ret = (countSumTotalData($email, 'sponsor_data', 'id', 'email', TRUE) == 1);
 
        // Return result
        return $ret;
@@ -252,7 +252,7 @@ function isSponsorRegisteredWithEmail ($email) {
 // Wether the current user is a sponsor
 function isSponsor () {
        // Failed is default
-       $ret = false;
+       $ret = FALSE;
 
        // Determine it
        $ret = (
@@ -307,17 +307,17 @@ ORDER BY
                                        if ($current == $content2['sub_what']) $content2['sub_title'] = '<strong>' . $content2['sub_title'] . '</strong>';
 
                                        // Load row template
-                                       $SUB .= loadTemplate('sponsor_what', true, $content2);
+                                       $SUB .= loadTemplate('sponsor_what', TRUE, $content2);
                                } // END - while
 
                                // Prepare data for the main template
                                $content['menu'] = $SUB;
 
                                // Load menu template
-                               $OUT .= loadTemplate('sponsor_action', true, $content);
+                               $OUT .= loadTemplate('sponsor_action', TRUE, $content);
                        } else {
                                // No sub menus active
-                               $OUT .= displayMessage('{--SPONSOR_NO_SUB_MENUS_ACTIVE--}', true);
+                               $OUT .= displayMessage('{--SPONSOR_NO_SUB_MENUS_ACTIVE--}', TRUE);
                        }
 
                        // Free memory
@@ -325,7 +325,7 @@ ORDER BY
                } // END - while
        } else {
                // No main menus active
-               $OUT .= displayMessage('{--SPONSOR_NO_MAIN_MENUS_ACTIVE--}', true);
+               $OUT .= displayMessage('{--SPONSOR_NO_MAIN_MENUS_ACTIVE--}', TRUE);
        }
 
        // Free memory
@@ -347,7 +347,7 @@ function addSponsorContent ($what) {
                loadIncludeOnce($INC);
        } else {
                // File not found
-               $GLOBALS['sponsor_output'] .= displayMessage('{%message,SPONSOR_CONTENT_404=' . $what . '%}', true);
+               $GLOBALS['sponsor_output'] .= displayMessage('{%message,SPONSOR_CONTENT_404=' . $what . '%}', TRUE);
        }
 
        // Return content
@@ -357,7 +357,7 @@ function addSponsorContent ($what) {
 //
 function updateSponsorLogin () {
        // Failed by default
-       $login = false;
+       $login = FALSE;
 
        // Is sponsor?
        if (isSponsor()) {
@@ -385,7 +385,7 @@ LIMIT 1",
 
 // Saves sponsor's data
 function saveSponsorData ($postData, $content) {
-       $EMAIL = false;
+       $EMAIL = FALSE;
 
        // Unsecure data which we don't want
        $UNSAFE = array('password', 'id', 'remote_addr', 'sponsor_created', 'last_online', 'status', 'ref_count',
@@ -427,7 +427,7 @@ function saveSponsorData ($postData, $content) {
        if ((!empty($content['email'])) && (!empty($postData['email']))) {
                if ($content['email'] != $postData['email']) {
                        // Change email address
-                       $EMAIL = true;
+                       $EMAIL = TRUE;
 
                        // Okay, has changed then add status with UNCONFIRMED and new hash code
                        $sql .= " `status`='EMAIL',`hash`='%s',";
@@ -451,7 +451,7 @@ function saveSponsorData ($postData, $content) {
        // Saving data was completed... ufff...
        switch (getWhat()) {
                case 'account': // Change account data
-                       if ($EMAIL === true) {
+                       if ($EMAIL === TRUE) {
                                $message = '{--SPONSOR_ACCOUNT_EMAIL_CHANGED--}';
                                $templ   = 'admin_sponsor_change_email';
                                $subject    = '{--ADMIN_SPONSOR_ACC_EMAIL_SUBJECT--}';
@@ -503,7 +503,7 @@ function saveSponsorData ($postData, $content) {
                                                $email_msg = loadEmailTemplate('sponsor_change_data', $content);
                                                sendEmail($content['email'], '{--SPONSOR_ACC_DATA_SUBJECT--}', $email_msg);
 
-                                               if ($EMAIL === true) {
+                                               if ($EMAIL === TRUE) {
                                                        // Add hash code to content array
                                                        $content['hash'] = $HASH;
 
@@ -565,7 +565,7 @@ function doProcessSponsorFormRequest ($messageArray = array()) {
        $message = '';
 
        // Handle the request
-       $status = handleSponsorRequest(postRequestArray(), true, $messageArray, true);
+       $status = handleSponsorRequest(postRequestArray(), TRUE, $messageArray, TRUE);
 
        // Check the status of the registration process
        switch ($status) {
@@ -627,7 +627,7 @@ function doExpressionSponsor ($data) {
 
        // Sponsor-related data, so is there a sponsor_id?
        if (!empty($data['matches'][4][$data['key']])) {
-               // Do we have a sponsor_id or $sponsor_id?
+               // Is there a sponsor_id or $sponsor_id?
                if ($data['matches'][4][$data['key']] == '$userid') {
                        // Use dynamic call
                        $functionName = "getFetchedSponsorData('id', \$userid, '" . $data['callback'] . "')";
@@ -640,7 +640,7 @@ function doExpressionSponsor ($data) {
                $functionName = "getSponsorData('" . $data['callback'] . "')";
        }
 
-       // Do we have another function to run (e.g. translations)
+       // Is there another function to run (e.g. translations)
        if (!empty($data['extra_func'])) {
                // Surround the original function call with it
                $functionName = $data['extra_func'] . '(' . $functionName . ')';
@@ -672,15 +672,15 @@ function fetchSponsorData ($sponsor_id, $column = 'id') {
                        reportBug(__FUNCTION__, __LINE__, 'Sponsor id ' . $sponsor_id . ' is invalid.');
                } elseif (isSponsorDataValid()) {
                        // Use cache, so it is fine
-                       return true;
+                       return TRUE;
                }
        } elseif (isSponsorDataValid()) {
                // Use cache, so it is fine
-               return true;
+               return TRUE;
        }
 
        // By default none was found
-       $found = false;
+       $found = FALSE;
 
        // Extra statements
        $ADD = '';
@@ -689,7 +689,7 @@ function fetchSponsorData ($sponsor_id, $column = 'id') {
        $result = SQL_QUERY_ESC("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `%s`='%s' LIMIT 1",
                array($column, $sponsor_id), __FUNCTION__, __LINE__);
 
-       // Do we have a record?
+       // Is there a record?
        if (SQL_NUMROWS($result) == 1) {
                // Load data from cookies
                $data = SQL_FETCHARRAY($result);
@@ -768,7 +768,7 @@ function getFetchedSponsorData ($keyColumn, $sponsor_id, $valueColumn) {
 // in, but you should use isMember() if you want to find that out.
 function isSponsorDataValid () {
        // Sponsor id should not be zero so abort here
-       if (!isCurrentSponsorIdSet()) return false;
+       if (!isCurrentSponsorIdSet()) return FALSE;
 
        // Is it cached?
        if (!isset($GLOBALS['is_sponsor_data_valid'][getCurrentSponsorId()])) {
@@ -808,7 +808,7 @@ function isCurrentSponsorIdSet () {
 
 // Is given sponsor_id valid?
 function isValidSponsorId ($sponsor_id) {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__][$sponsor_id])) {
                // Check it out
                $GLOBALS[__FUNCTION__][$sponsor_id] = ((!is_null($sponsor_id)) && (!empty($sponsor_id)) && ($sponsor_id > 0));
@@ -853,7 +853,7 @@ function destroySponsorSession () {
 
 // Getter for sponsor_min_points
 function getSponsorMinPoints () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('sponsor_min_points');
@@ -865,7 +865,7 @@ function getSponsorMinPoints () {
 
 // Getter for sponsor_ref_points
 function getSponsorRefPoints () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('sponsor_ref_points');