Listing of notifications added
[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", basename(__FILE__));
42
43 if (isset($_POST['ok']))
44 {
45         // Replace german decimal commas to computer decimal dots
46         $_POST['login_bonus']         = REVERT_COMMA($_POST['login_bonus']        );
47         $_POST['turbo_bonus']         = REVERT_COMMA($_POST['turbo_bonus']        );
48         $_POST['bonus_ref']           = REVERT_COMMA($_POST['bonus_ref']          );
49         $_POST['bonus_order']         = REVERT_COMMA($_POST['bonus_order']        );
50         $_POST['bonus_notify_points'] = REVERT_COMMA($_POST['bonus_notify_points']);
51
52         // Generate string for saving ranks
53         $_POST['turbo_rates'] = ""; $RATES = array();
54         foreach ($_POST['rate'] as $rate)
55         {
56                 $rate = trim(REVERT_COMMA($rate));
57                 if (isset($rate)) $RATES[] = $rate;
58         }
59         $_POST['turbo_rates'] = trim(implode(";", $RATES));
60         unset($_POST['rate']);
61
62         // Automatically calculate bonus points for ranks 2 and 3 when not set
63         if (empty($_POST['turbo_rates'])) $_POST['turbo_rates'] = "".round($_CONFIG['turbo_bonus'] / 2).";".round($_CONFIG['turbo_bonus'] / 4)."";
64
65         // Save data
66         ADMIN_SAVE_SETTINGS($_POST);
67
68         // Remember new settings
69         $_CONFIG['bonus_active']    = $_POST['bonus_active'];
70         $_CONFIG['bonus_en_notify'] = $_POST['bonus_en_notify'];
71         $_CONFIG['bonus_di_notify'] = $_POST['bonus_di_notify'];
72
73         // Include sending out mails
74         if ((($_CONFIG['bonus_active'] == "Y") && ($_CONFIG['bonus_en_notify'] == "Y")) || (($_CONFIG['bonus_active'] == "N") && ($_CONFIG['bonus_di_notify'] == "Y"))) {
75                 // Send mails out!
76                 include(PATH."inc/mails/bonus_mails.php");
77         }
78 } else {
79         // Prepare contants for the template
80         define('__LOGIN_VALUE' , TRANSLATE_COMMA($_CONFIG['login_bonus']        , false));
81         define('__TURBO_VALUE' , TRANSLATE_COMMA($_CONFIG['turbo_bonus']        , false));
82         define('__ORDER_VALUE' , TRANSLATE_COMMA($_CONFIG['bonus_order']        , false));
83         define('__REF_VALUE'   , TRANSLATE_COMMA($_CONFIG['bonus_ref']          , false));
84         define('__STATS_VALUE' , TRANSLATE_COMMA($_CONFIG['bonus_stats']        , false));
85         define('__NOTIFY_VALUE', TRANSLATE_COMMA($_CONFIG['bonus_notify_points'], false));
86         define('__TRANKS_VALUE', $_CONFIG['bonus_ranks']);
87         define('__TLINES_VALUE', $_CONFIG['bonus_lines']);
88
89         // Transfer options to template __MEMBER_SELECTION
90         define('__MEMBER_SELECTION', ADD_MEMBER_SELECTION_BOX($_CONFIG['bonus_uid'], false, true, true, "bonus_uid"));
91
92         // Initialize array for the points list
93         //die("*".$_CONFIG['turbo_rates']."*");
94         $RANKS = explode(";", $_CONFIG['turbo_rates']);
95
96         // Automatically calculate bonus points for ranks 2 and 3 when not set
97         if (empty($_CONFIG['turbo_rates'])) $RANKS = array(round($_CONFIG['turbo_bonus'] / 2), round($_CONFIG['turbo_bonus'] / 4));
98
99         // Generate list
100         $OUT = "<OL start=\"2\">\n";
101         $cnt = 0;
102         foreach ($RANKS as $k => $rate) {
103                 if (!empty($rate))      {
104                         // Print only when something is in
105                         $OUT .= "  <LI><INPUT type=\"text\" name=\"rate[".($k + 2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\" value=\"".$rate."\">&nbsp;<FONT class=\"admin_notes\">(".POINTS.")</FONT?</LI>\n";
106                 }
107                 $cnt++;
108         }
109         // Maxmium entries
110         $max = 10;
111         if ($cnt >= 8) $max = $cnt+3;
112
113         // Add more empty fields
114         for ($i = $cnt; $i < $max; $i++) {
115                 $OUT .= "  <LI><INPUT type=\"text\" name=\"rate[".($i+2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\">&nbsp;<FONT class=\"admin_notes\">(".POINTS.")</FONT?</LI>\n";
116         }
117         $OUT .= "</OL>\n";
118         define('__TRATES_LIST', $OUT);
119
120         define('__LOGIN_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS($_CONFIG['login_timeout']    , "login_timeout"    , "WDh"));
121         define('__BONUS_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS($_CONFIG['bonus_timeout']    , "bonus_timeout"    , "WDh"));
122         define('__WAIT_SELECTION'         , CREATE_TIME_SELECTIONS($_CONFIG['bonus_notify_wait'], "bonus_notify_wait", "ms" ));
123
124         // Activate / Deactivate bonus active rallye (Y/N)
125         switch ($_CONFIG['bonus_active'])
126         {
127         case 'Y':
128                 define('__BONUS_ACTIVE_Y', " checked=\"checked\"");
129                 define('__BONUS_ACTIVE_N', "");
130                 break;
131
132         case 'N':
133                 define('__BONUS_ACTIVE_Y', "");
134                 define('__BONUS_ACTIVE_N', " checked=\"checked\"");
135                 break;
136         }
137         // Other bonus to de-/activate
138         switch ($_CONFIG['bonus_login_yn'])
139         {
140         case 'Y':
141                 define('__BONUS_LOGIN_Y', " checked=\"checked\"");
142                 define('__BONUS_LOGIN_N', "");
143                 break;
144
145         case 'N':
146                 define('__BONUS_LOGIN_Y', "");
147                 define('__BONUS_LOGIN_N', " checked=\"checked\"");
148                 break;
149         }
150         switch ($_CONFIG['bonus_stats_yn'])
151         {
152         case 'Y':
153                 define('__BONUS_STATS_Y', " checked=\"checked\"");
154                 define('__BONUS_STATS_N', "");
155                 break;
156
157         case 'N':
158                 define('__BONUS_STATS_Y', "");
159                 define('__BONUS_STATS_N', " checked=\"checked\"");
160                 break;
161         }
162         switch ($_CONFIG['bonus_order_yn'])
163         {
164         case 'Y':
165                 define('__BONUS_ORDER_Y', " checked=\"checked\"");
166                 define('__BONUS_ORDER_N', "");
167                 break;
168
169         case 'N':
170                 define('__BONUS_ORDER_Y', "");
171                 define('__BONUS_ORDER_N', " checked=\"checked\"");
172                 break;
173         }
174         switch ($_CONFIG['bonus_ref_yn'])
175         {
176         case 'Y':
177                 define('__BONUS_REF_Y', " checked=\"checked\"");
178                 define('__BONUS_REF_N', "");
179                 break;
180
181         case 'N':
182                 define('__BONUS_REF_Y', "");
183                 define('__BONUS_REF_N', " checked=\"checked\"");
184                 break;
185         }
186         switch ($_CONFIG['bonus_click_yn'])
187         {
188         case 'Y':
189                 define('__BONUS_CLICK_Y', " checked=\"checked\"");
190                 define('__BONUS_CLICK_N', "");
191                 break;
192
193         case 'N':
194                 define('__BONUS_CLICK_Y', "");
195                 define('__BONUS_CLICK_N', " checked=\"checked\"");
196                 break;
197         }
198         switch ($_CONFIG['bonus_en_notify'])
199         {
200         case 'Y':
201                 define('__BONUS_EN_NOTIFY_Y', " checked=\"checked\"");
202                 define('__BONUS_EN_NOTIFY_N', "");
203                 break;
204
205         case 'N':
206                 define('__BONUS_EN_NOTIFY_Y', "");
207                 define('__BONUS_EN_NOTIFY_N', " checked=\"checked\"");
208                 break;
209         }
210         switch ($_CONFIG['bonus_di_notify'])
211         {
212         case 'Y':
213                 define('__BONUS_DI_NOTIFY_Y', " checked=\"checked\"");
214                 define('__BONUS_DI_NOTIFY_N', "");
215                 break;
216
217         case 'N':
218                 define('__BONUS_DI_NOTIFY_Y', "");
219                 define('__BONUS_DI_NOTIFY_N', " checked=\"checked\"");
220                 break;
221         }
222         switch ($_CONFIG['bonus_new_mem_notify'])
223         {
224         case 'Y':
225                 define('__BONUS_NEW_MEMBER_NOTIFY_Y', " checked=\"checked\"");
226                 define('__BONUS_NEW_MEMBER_NOTIFY_N', "");
227                 break;
228
229         case 'N':
230                 define('__BONUS_NEW_MEMBER_NOTIFY_Y', "");
231                 define('__BONUS_NEW_MEMBER_NOTIFY_N', " checked=\"checked\"");
232                 break;
233         }
234         switch ($_CONFIG['bonus_include_own'])
235         {
236         case 'Y':
237                 define('__BONUS_INCLUDE_OWN_Y', " checked=\"checked\"");
238                 define('__BONUS_INCLUDE_OWN_N', "");
239                 break;
240
241         case 'N':
242                 define('__BONUS_INCLUDE_OWN_Y', "");
243                 define('__BONUS_INCLUDE_OWN_N', " checked=\"checked\"");
244                 break;
245         }
246
247         // Load final template
248         LOAD_TEMPLATE("admin_config_bonus", false);
249 }
250 //
251 ?>