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