]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-wernis.php
A lot more wrapper functions introduced, TODOs.txt updated
[mailer.git] / inc / modules / member / what-wernis.php
index 8cd3a295f5e5dc990327d7a0dffb951480f68b9d..c19027ea283a04732577c8e6b20a86f4cf0b700b 100644 (file)
@@ -14,8 +14,6 @@
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
@@ -46,7 +44,7 @@ if (!defined('__SECURITY')) {
 }
 
 // Add description as navigation point
-addMenuDescription('member', __FILE__);
+addYouAreHereLink('member', __FILE__);
 
 if ((!isExtensionActive('wernis')) && (!isAdmin())) {
        loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('wernis'));
@@ -66,7 +64,6 @@ $content = array(); $points = false;
 // Is the mode set (withdraw or payout)
 if ((!isGetRequestParameterSet('mode')) || (getRequestParameter('mode') == 'choose')) {
        // Let the user choose what he wants to do
-       $content['refid']    = getConfig(('wernis_refid'));
        $content['wernis_userid'] = '0';
 
        // Is there an id?
@@ -116,11 +113,8 @@ if ((!isGetRequestParameterSet('mode')) || (getRequestParameter('mode') == 'choo
                setGetRequestParameter('mode', 'choose');
        }
 } elseif ((getRequestParameter('mode') == 'payout') && (getConfig('wernis_payout_active') == 'Y')) {
-       // Get total points and check if the user can request a payout
-       $points = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
-
-       // Remove the registration fee
-       $points = $points - getConfig('points_register');
+       // Get user's total points and remove the registration fee
+       $points = getTotalPoints(getMemberId()) - getPointsRegister();
 
        // Is there a percentage or fixed fee?
        $points = WERNIS_TAKE_FEE($points, 'payout');
@@ -128,11 +122,7 @@ if ((!isGetRequestParameterSet('mode')) || (getRequestParameter('mode') == 'choo
        // Is this enougth for a payout?
        if ($points < getConfig('wernis_min_payout')) {
                // No, then abort here
-               loadTemplate('admin_settings_saved', false, sprintf(
-                       getMessage('MEMBER_WERNIS_MIN_PAYOUT'),
-                       translateComma(getConfig('wernis_min_payout')),
-                       translateComma($points)
-               ));
+               loadTemplate('admin_settings_saved', false, '{%message,MEMBER_WERNIS_MIN_PAYOUT=' . $points . '%}');
                return;
        } // END - if
 
@@ -141,21 +131,12 @@ if ((!isGetRequestParameterSet('mode')) || (getRequestParameter('mode') == 'choo
        $points = bigintval($points[0]);
 
        // Add points to content array
-       $content['points']     = translateComma($points);
-
-       // Get WDS66 username
-       $content['wernis_userid'] = getUserData('wernis_userid');
+       $content['points']     = $points;
 } elseif ((getRequestParameter('mode') == 'withdraw') && (getConfig('wernis_withdraw_active') == 'Y')) {
-       // Get total points for just displaying them
-       $points = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
-
        // Prepare data for the template
-       $content['points']        = translateComma($points);
+       $content['points']        = getTotalPoints(getMemberId());
        $content['wernis_userid'] = '';
 
-       // Add fees to array
-       WERNIS_ADD_FEES_TO_ARRAY($content);
-
        // Fetch id
        $content['wernis_userid'] = getUserData('wernis_userid');
 } else {
@@ -167,13 +148,13 @@ if ((!isGetRequestParameterSet('mode')) || (getRequestParameter('mode') == 'choo
 // Is the formular sent?
 if ((isFormSent()) && (isGetRequestParameterSet('mode'))) {
        // Is the user id and password set?
-       if (!isPostRequestParameterSet(('wernis_userid'))) {
+       if (!isPostRequestParameterSet('wernis_userid')) {
                // Nothing entered in WDS66 user id
                loadTemplate('admin_settings_saved', false, '{--MEMBER_WERNIS_EMPTY_USERNAME--}');
-       } elseif (!isPostRequestParameterSet(('wds66_password'))) {
+       } elseif (!isPostRequestParameterSet('wds66_password')) {
                // Nothing entered in WDS66 password
                loadTemplate('admin_settings_saved', false, '{--MEMBER_WERNIS_EMPTY_PASSWORD--}');
-       } elseif (!isPostRequestParameterSet(('amount'))) {
+       } elseif (!isPostRequestParameterSet('amount')) {
                // Nothing entered in amount
                loadTemplate('admin_settings_saved', false, '{--MEMBER_WERNIS_EMPTY_AMOUNT--}');
        } elseif (postRequestParameter('wernis_userid') != bigintval(postRequestParameter('wernis_userid'))) {
@@ -248,7 +229,7 @@ if ((isFormSent()) && (isGetRequestParameterSet('mode'))) {
                                logDebugMessage(__FILE__, __LINE__, sprintf("Invalid mode %s detected.", getRequestParameter('mode')));
                                loadTemplate('admin_settings_saved', false, getMaskedMessage('MEMBER_WERNIS_MODE_INVALID', getRequestParameter('mode')));
                                return;
-               }
+               } // END - switch
        }
 } // END - if