63fcbeecc06c94dc049a46b59d35ff1f26f9182f
[mailer.git] / inc / modules / admin / what-config_bonus.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * -------------------------------------------------------------------- *
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')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 if (isFormSent()) {
47         // Replace german decimal comma with computer decimal dot
48         convertCommaToDotInPostDataArray(array('login_bonus', 'turbo_bonus', 'bonus_ref', 'bonus_order', 'bonus_notify_points'));
49
50         // Generate string for saving ranks
51         setPostRequestElement('turbo_rates', '');
52         $RATES = array();
53         foreach (postRequestElement('rate') as $rate) {
54                 // Convert German comma to dot
55                 $rate = trim(convertCommaToDot($rate));
56
57                 if (!empty($rate)) {
58                         array_push($RATES, $rate);
59                 } // END - if
60         } // END - foreach
61         setPostRequestElement('turbo_rates', trim(implode(';', $RATES)));
62         unsetPostRequestElement('rate');
63
64         // Automatically calculate bonus points for ranks 2 and 3 when not set
65         if (!isPostRequestElementSet('turbo_rates')) {
66                 setPostRequestElement('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).'');
67         } // END - if
68
69         // Save data
70         adminSaveSettingsFromPostData();
71
72         // Remember new settings
73         setConfigEntry('bonus_active'        , postRequestElement('bonus_active'));
74         setConfigEntry('bonus_enable_notify' , postRequestElement('bonus_enable_notify'));
75         setConfigEntry('bonus_disable_notify', postRequestElement('bonus_disable_notify'));
76 } else {
77         // Transfer options to template
78         $content['bonus_userid'] = addMemberSelectionBox(getBonusUserid(), FALSE, TRUE, TRUE, 'bonus_userid');
79
80         // Initialize array for the points list
81         $RANKS = explode(';', getTurboRates());
82
83         // Automatically calculate bonus points for ranks 2 and 3 when not set
84         if (getTurboRates() == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4));
85
86         // Generate list
87         $OUT = '<ol start="2">';
88         $count = '0';
89         foreach ($RANKS as $k => $rate) {
90                 if (!empty($rate)) {
91                         // Print only when something is in
92                         $OUT .= '<li><input type="text" name="rate[' . ($k + 2) . ']" class="form_field" size="4" maxlength="7" value="' . $rate . '" /> <div class="notice">({?POINTS?})</div></li>';
93                 } // END - if
94                 $count++;
95         } // END - foreach
96
97         // Maxmium entries
98         $max = 10;
99         if ($count >= 8) $max = $count+3;
100
101         // Add more empty fields
102         for ($i = $count; $i < $max; $i++) {
103                 $OUT .= '  <li><input type="text" name="rate[' . ($i+2) . ']" class="form_field" size="4" maxlength="7" /> <div class="notice">({?POINTS?})</div></li>';
104         } // END - for
105         $OUT .= '</ol>';
106         $content['trates_list'] = $OUT;
107
108         // Selection boxes
109         $content['login_timeout_selection'] = createConfigurationTimeSelections('login_timeout'    , 'WDh');
110         $content['bonus_timeout_selection'] = createConfigurationTimeSelections('bonus_timeout'    , 'WDh');
111         $content['wait_selection']          = createConfigurationTimeSelections('bonus_notify_wait', 'ms' );
112
113         // Load final template
114         loadTemplate('admin_config_bonus', FALSE, $content);
115 }
116
117 // [EOF]
118 ?>