]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/wernis_functions.php
Queries fixed
[mailer.git] / inc / libs / wernis_functions.php
index db99fbdfb43243063b89f51d1c2c363a4ffef6ca..b28bc9ee2d8efdb18c77445b69e2e2b3dae5830a 100644 (file)
@@ -264,7 +264,7 @@ function WERNIS_EXECUTE_WITHDRAW ($wdsId, $userMd5, $amount) {
                $result = true;
 
                // Log the transfer
-               WERNIS_LOG_TRANSFER($wdsId, $amount, 'IN');
+               WERNIS_LOG_TRANSFER($wdsId, $amount, 'WITHDRAW');
        } else {
                // Status failure text
                WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
@@ -301,7 +301,7 @@ function WERNIS_EXECUTE_PAYOUT ($wdsId, $amount) {
                $result = true;
 
                // Log the transfer
-               WERNIS_LOG_TRANSFER($wdsId, $amount, 'OUT');
+               WERNIS_LOG_TRANSFER($wdsId, $amount, 'PAYOUT');
        } else {
                // Status failure text
                WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
@@ -316,23 +316,17 @@ function WERNIS_EXECUTE_PAYOUT ($wdsId, $amount) {
 
 // Translate the status IN/OUT
 function translateWernisTransferStatus ($status) {
-       // Default status
+       // Default status is unknown
        $return = '{%message,WERNIS_STATUS_UNKNWOWN=' . $status . '%}';
 
-       // Which status?
-       switch ($status) {
-               case 'IN': // Withdraw
-                       $return = '{--WERNIS_STATUS_WITHDRAW--}';
-                       break;
-
-               case 'OUT': // Payout
-                       $return = '{--WERNIS_STATUS_PAYOUT--}';
-                       break;
+       // Construct message id
+       $messageId = 'WERNIS_STATUS_' . $status;
 
-               case 'FAILED': // Payout
-                       $return = '{--WERNIS_STATUS_FAILED--}';
-                       break;
-       } // END - switch
+       // Is it there?
+       if (isMessageIdValid($messageId)) {
+               // Then use it as message string
+               $return = '{--' . $messageId . '--}';
+       } // END - if
 
        // Return the status
        return $return;
@@ -341,7 +335,7 @@ function translateWernisTransferStatus ($status) {
 // Log the transfer
 function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = '', $status = '') {
        // Register this wernis movement
-       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_wernis` (`userid`,`wernis_account`,`wernis_amount`,`wernis_timestamp`,`wernis_type`,`wernis_api_message`,`wernis_api_status`) VALUES (%s, %s, %s, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
+       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_wernis` (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES (%s, %s, %s, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
                array(
                        getMemberId(),
                        bigintval($wdsId),
@@ -400,9 +394,9 @@ function WERNIS_ADD_WITHDRAW_FEE ($points) {
        return $points;
 }
 
-// ---------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 //                             Wrapper functions
-// ---------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 
 // Wrapper function for 'wernis_refid'
 function getWernisRefid () {