]> 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 ac2a82d7750bab66fbd27fe5e93fbd131a16b326..b93c09d0aab997ec20f3ab2e12cee6d4b51ee2d6 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/15/2008 *
- * ===============                              Last change: 10/15/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 10/15/2008 *
+ * ===================                          Last change: 10/15/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : beg_functions.php                                *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Funktionen fuer den Bettel-Link                  *
  * -------------------------------------------------------------------- *
- * $Revision:: 856                                                    $ *
- * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009)             $ *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author:: stelzi                                                   $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * 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 *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
+       die();
+} // END - if
 
 // Add points to user or begging rallye account
-function BEG_ADD_POINTS ($uid, $points) {
-       // Set mode depending on how many mails the member has to confirm
-       $locked = false;
-       if ((getConfig('ref_payout') > 0) && (getConfig('allow_direct_pay') != "Y")) $locked = true;
+function addPointsBeg ($userid, $points) {
+       // Default is not added
+       $added = FALSE;
 
        // Is begging rallye active?
-       if (getConfig('beg_rallye') == "Y") {
+       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",
-                       array($points, $uid), __FUNCTION__, __LINE__);
+               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
-               unset($GLOBALS['ref_level']);
-               ADD_POINTS_REFSYSTEM("beg", $uid, $points, false, "0", $locked, strtolower(getConfig('beg_mode')));
+               initReferralSystem();
+               $added = addPointsThroughReferralSystem('beg', $userid, $points);
        }
 
        // Subtract begged points from member account if the admin has selected one
-       if (getConfig('beg_uid') > 0) {
+       if (($added === TRUE) && (isValidId(getBegUserid()))) {
                // Subtract from this account
-               SUB_POINTS("beg_payout", getConfig('beg_uid'), $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 () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Get it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_new_member_notify');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether beg_new_member_notify is enabled
+function isBegNewMemberNotifyEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getBegNewMemberNotify() == 'Y'));
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_userid
+function getBegUserid () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Get it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_userid');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_timeout
+function getBegTimeout () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_timeout');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_userid_timeout
+function getBegUseridTimeout () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_userid_timeout');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_ip_timeout
+function getBegIpTimeout () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_ip_timeout');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_ranks
+function getBegRanks () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_ranks');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_points_max
+function getBegPointsMax () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_points_max');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_points
+function getBegPoints () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_points');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_notify_bonus
+function getBegNotifyBonus () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_notify_bonus');
        } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_notify_wait
+function getBegNotifyWait () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_notify_wait');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_pay_mode
+function getBegPayMode () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_pay_mode');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_include_own
+function getBegIncludeOwn () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_include_own');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether beg_include_own is "Y"
+function isBegIncludeOwnEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getBegIncludeOwn() == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_active
+function getBegActive () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_active');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether beg_active is "Y"
+function isBegActiveEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getBegActive() == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_rallye
+function getBegRallye () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_rallye');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether beg_rallye is "Y"
+function isBegRallyeEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getBegRallye() == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_rallye_enable_notify
+function getBegRallyeEnableNotify () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_enable_notify');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether beg_rallye_enable_notify is "Y"
+function isBegRallyeEnableNotifyEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getBegRallyeEnableNotify() == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for beg_rallye_disable_notify
+function getBegRallyeDisableNotify () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_disable_notify');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether beg_rallye_disable_notify is "Y"
+function isBegRallyeDisableNotifyEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getBegRallyeDisableNotify() == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
 }
 
 // [EOF]