90e61bdc45bf6a84aee9ea7fe8e0dc912f055618
[mailer.git] / inc / libs / beg_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/15/2008 *
4  * ===================                          Last change: 10/15/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : beg_functions.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Beg link functions                               *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Funktionen fuer den Bettel-Link                  *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Add points to user or begging rallye account
44 function addPointsBeg ($userid, $points) {
45         // Default is not added
46         $added = false;
47
48         // Is begging rallye active?
49         if (isBegRallyeEnabled()) {
50                 // Add points to rallye account
51                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=`beg_points`+%s WHERE `userid`=%s LIMIT 1",
52                         array($points, $userid), __FUNCTION__, __LINE__);
53         } else {
54                 // Add points to account
55                 // @TODO Try to rewrite the following unset()
56                 unset($GLOBALS['ref_level']);
57                 $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, strtolower(getConfig('beg_mode')));
58         }
59
60         // Subtract begged points from member account if the admin has selected one
61         if (getConfig('beg_userid') > 0) {
62                 // Subtract from this account
63                 subtractPoints('beg_payout', getConfig('beg_userid'), $points);
64         } // END - if
65
66         // Return result
67         return $added;
68 }
69
70 // Checks wether beg_rallye is enabled
71 function isBegRallyeEnabled () {
72         // Do we have cache?
73         if (!isset($GLOBALS[__FUNCTION__])) {
74                 // Determine it
75                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.8')) && (getConfig('beg_rallye') == 'Y'));
76         } // END - if
77
78         // Return cache
79         return $GLOBALS[__FUNCTION__];
80 }
81
82 // Checks wether beg_rallye is enabled
83 function isBegNewMemberNotifyEnabled () {
84         // Do we have cache?
85         if (!isset($GLOBALS[__FUNCTION__])) {
86                 // Determine it
87                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getConfig('beg_new_member_notify') == 'Y'));
88         } // END - if
89
90         // Return cache
91         return $GLOBALS[__FUNCTION__];
92 }
93
94 // "Getter" for beg_userid
95 function getBegUserid () {
96         // Do we have cache?
97         if (!isset($GLOBALS[__FUNCTION__])) {
98                 // Get it
99                 $GLOBALS[__FUNCTION__] = getConfig('beg_userid');
100         } // END - if
101
102         // Return cache
103         return $GLOBALS[__FUNCTION__];
104 }
105
106 // [EOF]
107 ?>