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