More constant rewrites
[mailer.git] / inc / modules / admin / what-config_bonus.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/31/2004 *
4  * ================                             Last change: 11/14/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_bonus.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Configure "turbo-click-bonus"                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Einstellen der Turbo-Klick-Verguetungen          *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 if (IS_FORM_SENT()) {
44         // Replace german decimal commas to computer decimal dots
45         REQUEST_POST('login_bonus')         = REVERT_COMMA(REQUEST_POST('login_bonus')        );
46         REQUEST_POST('turbo_bonus')         = REVERT_COMMA(REQUEST_POST('turbo_bonus')        );
47         REQUEST_POST('bonus_ref')           = REVERT_COMMA(REQUEST_POST('bonus_ref')          );
48         REQUEST_POST('bonus_order')         = REVERT_COMMA(REQUEST_POST('bonus_order')        );
49         REQUEST_SET_POST('bonus_notify_points', REVERT_COMMA(REQUEST_POST('bonus_notify_points')));
50
51         // Generate string for saving ranks
52         REQUEST_SET_POST('turbo_rates', "");
53         $RATES = array();
54         foreach (REQUEST_POST('rate') as $rate) {
55                 $rate = trim(REVERT_COMMA($rate));
56                 if (!empty($rate)) $RATES[] = $rate;
57         }
58         REQUEST_SET_POST('turbo_rates', trim(implode(";", $RATES)));
59         REQUEST_UNSET_POST(('rate'));
60
61         // Automatically calculate bonus points for ranks 2 and 3 when not set
62         if (!REQUEST_ISSET_POST(('turbo_rates'))) REQUEST_SET_POST('turbo_rates', "".round(getConfig('turbo_bonus') / 2).";".round(getConfig('turbo_bonus') / 4)."");
63
64         // Save data
65         ADMIN_SAVE_SETTINGS_POST();
66
67         // Remember new settings
68         setConfigEntry('bonus_active'   , REQUEST_POST('bonus_active'));
69         setConfigEntry('bonus_en_notify', REQUEST_POST('bonus_en_notify'));
70         setConfigEntry('bonus_di_notify', REQUEST_POST('bonus_di_notify'));
71 } else {
72         // Prepare contants for the template
73         define('__LOGIN_VALUE' , TRANSLATE_COMMA(getConfig('login_bonus')        , false));
74         define('__TURBO_VALUE' , TRANSLATE_COMMA(getConfig('turbo_bonus')        , false));
75         define('__ORDER_VALUE' , TRANSLATE_COMMA(getConfig('bonus_order')        , false));
76         define('__REF_VALUE'   , TRANSLATE_COMMA(getConfig('bonus_ref')          , false));
77         define('__STATS_VALUE' , TRANSLATE_COMMA(getConfig('bonus_stats')        , false));
78         define('__NOTIFY_VALUE', TRANSLATE_COMMA(getConfig('bonus_notify_points'), false));
79         define('__TRANKS_VALUE', getConfig('bonus_ranks'));
80         define('__TLINES_VALUE', getConfig('bonus_lines'));
81
82         // Transfer options to template __MEMBER_SELECTION
83         define('__MEMBER_SELECTION', ADD_MEMBER_SELECTION_BOX(getConfig('bonus_uid'), false, true, true, "bonus_uid"));
84
85         // Initialize array for the points list
86         //die("*".getConfig('turbo_rates')."*");
87         $RANKS = explode(";", getConfig('turbo_rates'));
88
89         // Automatically calculate bonus points for ranks 2 and 3 when not set
90         if (getConfig('turbo_rates') == "") $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4));
91
92         // Generate list
93         $OUT = "<ol start=\"2\">\n";
94         $cnt = 0;
95         foreach ($RANKS as $k => $rate) {
96                 if (!empty($rate))      {
97                         // Print only when something is in
98                         $OUT .= "  <li><input type=\"text\" name=\"rate[".($k + 2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\" value=\"".$rate."\">&nbsp;<div class=\"admin_notes\">({!POINTS!})</div?</li>\n";
99                 }
100                 $cnt++;
101         }
102         // Maxmium entries
103         $max = 10;
104         if ($cnt >= 8) $max = $cnt+3;
105
106         // Add more empty fields
107         for ($i = $cnt; $i < $max; $i++) {
108                 $OUT .= "  <li><input type=\"text\" name=\"rate[".($i+2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\">&nbsp;<div class=\"admin_notes\">({!POINTS!})</div?</li>\n";
109         }
110         $OUT .= "</ol>\n";
111         define('__TRATES_LIST', $OUT);
112
113         define('__LOGIN_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS(getConfig('login_timeout')    , "login_timeout"    , "WDh"));
114         define('__BONUS_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS(getConfig('bonus_timeout')    , "bonus_timeout"    , "WDh"));
115         define('__WAIT_SELECTION'         , CREATE_TIME_SELECTIONS(getConfig('bonus_notify_wait'), "bonus_notify_wait", "ms" ));
116
117         // Activate / Deactivate bonus active rallye (Y/N)
118         switch (getConfig('bonus_active'))
119         {
120         case "Y":
121                 define('__BONUS_ACTIVE_Y', " checked=\"checked\"");
122                 define('__BONUS_ACTIVE_N', "");
123                 break;
124
125         case "N":
126                 define('__BONUS_ACTIVE_Y', "");
127                 define('__BONUS_ACTIVE_N', " checked=\"checked\"");
128                 break;
129         }
130         // Other bonus to de-/activate
131         switch (getConfig('bonus_login_yn'))
132         {
133         case "Y":
134                 define('__BONUS_LOGIN_Y', " checked=\"checked\"");
135                 define('__BONUS_LOGIN_N', "");
136                 break;
137
138         case "N":
139                 define('__BONUS_LOGIN_Y', "");
140                 define('__BONUS_LOGIN_N', " checked=\"checked\"");
141                 break;
142         }
143         switch (getConfig('bonus_stats_yn'))
144         {
145         case "Y":
146                 define('__BONUS_STATS_Y', " checked=\"checked\"");
147                 define('__BONUS_STATS_N', "");
148                 break;
149
150         case "N":
151                 define('__BONUS_STATS_Y', "");
152                 define('__BONUS_STATS_N', " checked=\"checked\"");
153                 break;
154         }
155         switch (getConfig('bonus_order_yn'))
156         {
157         case "Y":
158                 define('__BONUS_ORDER_Y', " checked=\"checked\"");
159                 define('__BONUS_ORDER_N', "");
160                 break;
161
162         case "N":
163                 define('__BONUS_ORDER_Y', "");
164                 define('__BONUS_ORDER_N', " checked=\"checked\"");
165                 break;
166         }
167         switch (getConfig('bonus_ref_yn'))
168         {
169         case "Y":
170                 define('__BONUS_REF_Y', " checked=\"checked\"");
171                 define('__BONUS_REF_N', "");
172                 break;
173
174         case "N":
175                 define('__BONUS_REF_Y', "");
176                 define('__BONUS_REF_N', " checked=\"checked\"");
177                 break;
178         }
179         switch (getConfig('bonus_click_yn'))
180         {
181         case "Y":
182                 define('__BONUS_CLICK_Y', " checked=\"checked\"");
183                 define('__BONUS_CLICK_N', "");
184                 break;
185
186         case "N":
187                 define('__BONUS_CLICK_Y', "");
188                 define('__BONUS_CLICK_N', " checked=\"checked\"");
189                 break;
190         }
191         switch (getConfig('bonus_en_notify'))
192         {
193         case "Y":
194                 define('__BONUS_EN_NOTIFY_Y', " checked=\"checked\"");
195                 define('__BONUS_EN_NOTIFY_N', "");
196                 break;
197
198         case "N":
199                 define('__BONUS_EN_NOTIFY_Y', "");
200                 define('__BONUS_EN_NOTIFY_N', " checked=\"checked\"");
201                 break;
202         }
203         switch (getConfig('bonus_di_notify'))
204         {
205         case "Y":
206                 define('__BONUS_DI_NOTIFY_Y', " checked=\"checked\"");
207                 define('__BONUS_DI_NOTIFY_N', "");
208                 break;
209
210         case "N":
211                 define('__BONUS_DI_NOTIFY_Y', "");
212                 define('__BONUS_DI_NOTIFY_N', " checked=\"checked\"");
213                 break;
214         }
215         switch (getConfig('bonus_new_mem_notify'))
216         {
217         case "Y":
218                 define('__BONUS_NEW_MEMBER_NOTIFY_Y', " checked=\"checked\"");
219                 define('__BONUS_NEW_MEMBER_NOTIFY_N', "");
220                 break;
221
222         case "N":
223                 define('__BONUS_NEW_MEMBER_NOTIFY_Y', "");
224                 define('__BONUS_NEW_MEMBER_NOTIFY_N', " checked=\"checked\"");
225                 break;
226         }
227         switch (getConfig('bonus_include_own'))
228         {
229         case "Y":
230                 define('__BONUS_INCLUDE_OWN_Y', " checked=\"checked\"");
231                 define('__BONUS_INCLUDE_OWN_N', "");
232                 break;
233
234         case "N":
235                 define('__BONUS_INCLUDE_OWN_Y', "");
236                 define('__BONUS_INCLUDE_OWN_N', " checked=\"checked\"");
237                 break;
238         }
239
240         // Load final template
241         LOAD_TEMPLATE("admin_config_bonus", false);
242 }
243 //
244 ?>