]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/beg_functions.php
Opps, not all elements for sprintf() has been set.
[mailer.git] / inc / libs / beg_functions.php
index 8035ccf27d1ed1f8bad22d111137e4f13bc5eb88..b93c09d0aab997ec20f3ab2e12cee6d4b51ee2d6 100644 (file)
@@ -16,8 +16,8 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -43,36 +43,58 @@ if (!defined('__SECURITY')) {
 // Add points to user or begging rallye account
 function addPointsBeg ($userid, $points) {
        // Default is not added
-       $added = false;
+       $added = FALSE;
 
        // Is begging rallye active?
        if (isBegRallyeEnabled()) {
                // Add points to rallye account
-               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=`beg_points`+%s WHERE `userid`=%s LIMIT 1",
+               sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=`beg_points`+%s WHERE `userid`=%s LIMIT 1",
                        array($points, $userid), __FUNCTION__, __LINE__);
+
+               // We need to set $add here, two
+               $added = (!ifSqlHasZeroAffectedRows());
        } else {
                // Add points to account
-               initReferalSystem();
-               $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, getBegMode());
+               initReferralSystem();
+               $added = addPointsThroughReferralSystem('beg', $userid, $points);
        }
 
        // Subtract begged points from member account if the admin has selected one
-       if (isValidUserId(getBegUserid())) {
+       if (($added === TRUE) && (isValidId(getBegUserid()))) {
                // Subtract from this account
-               subtractPoints('beg_payout', getBegUserid(), $points);
+               $added = ($added && subtractPoints('beg_payout', getBegUserid(), $points));
        } // END - if
 
        // Return result
        return $added;
 }
 
+//-----------------------------------------------------------------------------
+//                            Template functions
+//-----------------------------------------------------------------------------
+
+// Outputs points which a member can get
+function doTemplateOutputBegPoints ($templateName, $clear = FALSE) {
+       // Default is not the same
+       $return = '{--BEG_POINTS_MIN_MAX--}';
+
+       // Is min/max points the same?
+       if (getBegPoints() == getBegPointsMax()) {
+               // Is the same, output different message
+               $return = '{--BEG_POINTS_FIXED--}';
+       } // END - if
+
+       // Return message
+       return $return;
+}
+
 //-----------------------------------------------------------------------------
 //                       Wrapper functions for ext-beg
 //-----------------------------------------------------------------------------
 
 // "Getter" for beg_new_member_notify
 function getBegNewMemberNotify () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Get it
                $GLOBALS[__FUNCTION__] = getConfig('beg_new_member_notify');
@@ -82,9 +104,9 @@ function getBegNewMemberNotify () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether beg_new_member_notify is enabled
+// Checks whether beg_new_member_notify is enabled
 function isBegNewMemberNotifyEnabled () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getBegNewMemberNotify() == 'Y'));
@@ -96,7 +118,7 @@ function isBegNewMemberNotifyEnabled () {
 
 // "Getter" for beg_userid
 function getBegUserid () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Get it
                $GLOBALS[__FUNCTION__] = getConfig('beg_userid');
@@ -108,7 +130,7 @@ function getBegUserid () {
 
 // "Getter" for beg_timeout
 function getBegTimeout () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_timeout');
@@ -120,7 +142,7 @@ function getBegTimeout () {
 
 // "Getter" for beg_userid_timeout
 function getBegUseridTimeout () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_userid_timeout');
@@ -132,7 +154,7 @@ function getBegUseridTimeout () {
 
 // "Getter" for beg_ip_timeout
 function getBegIpTimeout () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_ip_timeout');
@@ -144,7 +166,7 @@ function getBegIpTimeout () {
 
 // "Getter" for beg_ranks
 function getBegRanks () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_ranks');
@@ -156,7 +178,7 @@ function getBegRanks () {
 
 // "Getter" for beg_points_max
 function getBegPointsMax () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_points_max');
@@ -168,7 +190,7 @@ function getBegPointsMax () {
 
 // "Getter" for beg_points
 function getBegPoints () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_points');
@@ -180,7 +202,7 @@ function getBegPoints () {
 
 // "Getter" for beg_notify_bonus
 function getBegNotifyBonus () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_notify_bonus');
@@ -192,7 +214,7 @@ function getBegNotifyBonus () {
 
 // "Getter" for beg_notify_wait
 function getBegNotifyWait () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_notify_wait');
@@ -204,7 +226,7 @@ function getBegNotifyWait () {
 
 // "Getter" for beg_pay_mode
 function getBegPayMode () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_pay_mode');
@@ -214,21 +236,9 @@ function getBegPayMode () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// "Getter" for beg_mode
-function getBegMode () {
-       // Do we have cache?
-       if (!isset($GLOBALS[__FUNCTION__])) {
-               // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('beg_mode');
-       } // END - if
-
-       // Return cache
-       return $GLOBALS[__FUNCTION__];
-}
-
 // "Getter" for beg_include_own
 function getBegIncludeOwn () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_include_own');
@@ -238,9 +248,9 @@ function getBegIncludeOwn () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether beg_include_own is "Y"
+// Checks whether beg_include_own is "Y"
 function isBegIncludeOwnEnabled () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = (getBegIncludeOwn() == 'Y');
@@ -252,7 +262,7 @@ function isBegIncludeOwnEnabled () {
 
 // "Getter" for beg_active
 function getBegActive () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_active');
@@ -262,9 +272,9 @@ function getBegActive () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether beg_active is "Y"
+// Checks whether beg_active is "Y"
 function isBegActiveEnabled () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = (getBegActive() == 'Y');
@@ -276,7 +286,7 @@ function isBegActiveEnabled () {
 
 // "Getter" for beg_rallye
 function getBegRallye () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_rallye');
@@ -286,9 +296,9 @@ function getBegRallye () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether beg_rallye is "Y"
+// Checks whether beg_rallye is "Y"
 function isBegRallyeEnabled () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = (getBegRallye() == 'Y');
@@ -300,7 +310,7 @@ function isBegRallyeEnabled () {
 
 // "Getter" for beg_rallye_enable_notify
 function getBegRallyeEnableNotify () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_enable_notify');
@@ -310,9 +320,9 @@ function getBegRallyeEnableNotify () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether beg_rallye_enable_notify is "Y"
+// Checks whether beg_rallye_enable_notify is "Y"
 function isBegRallyeEnableNotifyEnabled () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = (getBegRallyeEnableNotify() == 'Y');
@@ -324,7 +334,7 @@ function isBegRallyeEnableNotifyEnabled () {
 
 // "Getter" for beg_rallye_disable_notify
 function getBegRallyeDisableNotify () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_disable_notify');
@@ -334,9 +344,9 @@ function getBegRallyeDisableNotify () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether beg_rallye_disable_notify is "Y"
+// Checks whether beg_rallye_disable_notify is "Y"
 function isBegRallyeDisableNotifyEnabled () {
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
                $GLOBALS[__FUNCTION__] = (getBegRallyeDisableNotify() == 'Y');