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