Referal system refactured (and some parts fixed), wrapper function introduced:
[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 - 2011 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                 initReferalSystem();
56                 $added = addPointsThroughReferalSystem('beg', $userid, $points);
57         }
58
59         // Subtract begged points from member account if the admin has selected one
60         if (isValidUserId(getBegUserid())) {
61                 // Subtract from this account
62                 subtractPoints('beg_payout', getBegUserid(), $points);
63         } // END - if
64
65         // Return result
66         return $added;
67 }
68
69 //-----------------------------------------------------------------------------
70 //                       Wrapper functions for ext-beg
71 //-----------------------------------------------------------------------------
72
73 // "Getter" for beg_new_member_notify
74 function getBegNewMemberNotify () {
75         // Do we have cache?
76         if (!isset($GLOBALS[__FUNCTION__])) {
77                 // Get it
78                 $GLOBALS[__FUNCTION__] = getConfig('beg_new_member_notify');
79         } // END - if
80
81         // Return cache
82         return $GLOBALS[__FUNCTION__];
83 }
84
85 // Checks wether beg_new_member_notify is enabled
86 function isBegNewMemberNotifyEnabled () {
87         // Do we have cache?
88         if (!isset($GLOBALS[__FUNCTION__])) {
89                 // Determine it
90                 $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getBegNewMemberNotify() == 'Y'));
91         } // END - if
92
93         // Return cache
94         return $GLOBALS[__FUNCTION__];
95 }
96
97 // "Getter" for beg_userid
98 function getBegUserid () {
99         // Do we have cache?
100         if (!isset($GLOBALS[__FUNCTION__])) {
101                 // Get it
102                 $GLOBALS[__FUNCTION__] = getConfig('beg_userid');
103         } // END - if
104
105         // Return cache
106         return $GLOBALS[__FUNCTION__];
107 }
108
109 // "Getter" for beg_timeout
110 function getBegTimeout () {
111         // Do we have cache?
112         if (!isset($GLOBALS[__FUNCTION__])) {
113                 // Determine it
114                 $GLOBALS[__FUNCTION__] = getConfig('beg_timeout');
115         } // END - if
116
117         // Return cache
118         return $GLOBALS[__FUNCTION__];
119 }
120
121 // "Getter" for beg_userid_timeout
122 function getBegUseridTimeout () {
123         // Do we have cache?
124         if (!isset($GLOBALS[__FUNCTION__])) {
125                 // Determine it
126                 $GLOBALS[__FUNCTION__] = getConfig('beg_userid_timeout');
127         } // END - if
128
129         // Return cache
130         return $GLOBALS[__FUNCTION__];
131 }
132
133 // "Getter" for beg_ip_timeout
134 function getBegIpTimeout () {
135         // Do we have cache?
136         if (!isset($GLOBALS[__FUNCTION__])) {
137                 // Determine it
138                 $GLOBALS[__FUNCTION__] = getConfig('beg_ip_timeout');
139         } // END - if
140
141         // Return cache
142         return $GLOBALS[__FUNCTION__];
143 }
144
145 // "Getter" for beg_ranks
146 function getBegRanks () {
147         // Do we have cache?
148         if (!isset($GLOBALS[__FUNCTION__])) {
149                 // Determine it
150                 $GLOBALS[__FUNCTION__] = getConfig('beg_ranks');
151         } // END - if
152
153         // Return cache
154         return $GLOBALS[__FUNCTION__];
155 }
156
157 // "Getter" for beg_points_max
158 function getBegPointsMax () {
159         // Do we have cache?
160         if (!isset($GLOBALS[__FUNCTION__])) {
161                 // Determine it
162                 $GLOBALS[__FUNCTION__] = getConfig('beg_points_max');
163         } // END - if
164
165         // Return cache
166         return $GLOBALS[__FUNCTION__];
167 }
168
169 // "Getter" for beg_points
170 function getBegPoints () {
171         // Do we have cache?
172         if (!isset($GLOBALS[__FUNCTION__])) {
173                 // Determine it
174                 $GLOBALS[__FUNCTION__] = getConfig('beg_points');
175         } // END - if
176
177         // Return cache
178         return $GLOBALS[__FUNCTION__];
179 }
180
181 // "Getter" for beg_notify_bonus
182 function getBegNotifyBonus () {
183         // Do we have cache?
184         if (!isset($GLOBALS[__FUNCTION__])) {
185                 // Determine it
186                 $GLOBALS[__FUNCTION__] = getConfig('beg_notify_bonus');
187         } // END - if
188
189         // Return cache
190         return $GLOBALS[__FUNCTION__];
191 }
192
193 // "Getter" for beg_notify_wait
194 function getBegNotifyWait () {
195         // Do we have cache?
196         if (!isset($GLOBALS[__FUNCTION__])) {
197                 // Determine it
198                 $GLOBALS[__FUNCTION__] = getConfig('beg_notify_wait');
199         } // END - if
200
201         // Return cache
202         return $GLOBALS[__FUNCTION__];
203 }
204
205 // "Getter" for beg_pay_mode
206 function getBegPayMode () {
207         // Do we have cache?
208         if (!isset($GLOBALS[__FUNCTION__])) {
209                 // Determine it
210                 $GLOBALS[__FUNCTION__] = getConfig('beg_pay_mode');
211         } // END - if
212
213         // Return cache
214         return $GLOBALS[__FUNCTION__];
215 }
216
217 // "Getter" for beg_include_own
218 function getBegIncludeOwn () {
219         // Do we have cache?
220         if (!isset($GLOBALS[__FUNCTION__])) {
221                 // Determine it
222                 $GLOBALS[__FUNCTION__] = getConfig('beg_include_own');
223         } // END - if
224
225         // Return cache
226         return $GLOBALS[__FUNCTION__];
227 }
228
229 // Checks wether beg_include_own is "Y"
230 function isBegIncludeOwnEnabled () {
231         // Do we have cache?
232         if (!isset($GLOBALS[__FUNCTION__])) {
233                 // Determine it
234                 $GLOBALS[__FUNCTION__] = (getBegIncludeOwn() == 'Y');
235         } // END - if
236
237         // Return cache
238         return $GLOBALS[__FUNCTION__];
239 }
240
241 // "Getter" for beg_active
242 function getBegActive () {
243         // Do we have cache?
244         if (!isset($GLOBALS[__FUNCTION__])) {
245                 // Determine it
246                 $GLOBALS[__FUNCTION__] = getConfig('beg_active');
247         } // END - if
248
249         // Return cache
250         return $GLOBALS[__FUNCTION__];
251 }
252
253 // Checks wether beg_active is "Y"
254 function isBegActiveEnabled () {
255         // Do we have cache?
256         if (!isset($GLOBALS[__FUNCTION__])) {
257                 // Determine it
258                 $GLOBALS[__FUNCTION__] = (getBegActive() == 'Y');
259         } // END - if
260
261         // Return cache
262         return $GLOBALS[__FUNCTION__];
263 }
264
265 // "Getter" for beg_rallye
266 function getBegRallye () {
267         // Do we have cache?
268         if (!isset($GLOBALS[__FUNCTION__])) {
269                 // Determine it
270                 $GLOBALS[__FUNCTION__] = getConfig('beg_rallye');
271         } // END - if
272
273         // Return cache
274         return $GLOBALS[__FUNCTION__];
275 }
276
277 // Checks wether beg_rallye is "Y"
278 function isBegRallyeEnabled () {
279         // Do we have cache?
280         if (!isset($GLOBALS[__FUNCTION__])) {
281                 // Determine it
282                 $GLOBALS[__FUNCTION__] = (getBegRallye() == 'Y');
283         } // END - if
284
285         // Return cache
286         return $GLOBALS[__FUNCTION__];
287 }
288
289 // "Getter" for beg_rallye_enable_notify
290 function getBegRallyeEnableNotify () {
291         // Do we have cache?
292         if (!isset($GLOBALS[__FUNCTION__])) {
293                 // Determine it
294                 $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_enable_notify');
295         } // END - if
296
297         // Return cache
298         return $GLOBALS[__FUNCTION__];
299 }
300
301 // Checks wether beg_rallye_enable_notify is "Y"
302 function isBegRallyeEnableNotifyEnabled () {
303         // Do we have cache?
304         if (!isset($GLOBALS[__FUNCTION__])) {
305                 // Determine it
306                 $GLOBALS[__FUNCTION__] = (getBegRallyeEnableNotify() == 'Y');
307         } // END - if
308
309         // Return cache
310         return $GLOBALS[__FUNCTION__];
311 }
312
313 // "Getter" for beg_rallye_disable_notify
314 function getBegRallyeDisableNotify () {
315         // Do we have cache?
316         if (!isset($GLOBALS[__FUNCTION__])) {
317                 // Determine it
318                 $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_disable_notify');
319         } // END - if
320
321         // Return cache
322         return $GLOBALS[__FUNCTION__];
323 }
324
325 // Checks wether beg_rallye_disable_notify is "Y"
326 function isBegRallyeDisableNotifyEnabled () {
327         // Do we have cache?
328         if (!isset($GLOBALS[__FUNCTION__])) {
329                 // Determine it
330                 $GLOBALS[__FUNCTION__] = (getBegRallyeDisableNotify() == 'Y');
331         } // END - if
332
333         // Return cache
334         return $GLOBALS[__FUNCTION__];
335 }
336
337 // [EOF]
338 ?>