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