Some language strings fixed, renamed. Copyright notice updated
[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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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 commas to computer decimal dots
48         setPostRequestParameter('login_bonus',         convertCommaToDot(postRequestParameter('login_bonus')));
49         setPostRequestParameter('turbo_bonus',         convertCommaToDot(postRequestParameter('turbo_bonus')));
50         setPostRequestParameter('bonus_ref',           convertCommaToDot(postRequestParameter('bonus_ref')));
51         setPostRequestParameter('bonus_order',         convertCommaToDot(postRequestParameter('bonus_order')));
52         setPostRequestParameter('bonus_notify_points', convertCommaToDot(postRequestParameter('bonus_notify_points')));
53
54         // Generate string for saving ranks
55         setPostRequestParameter('turbo_rates', '');
56         $RATES = array();
57         foreach (postRequestParameter('rate') as $rate) {
58                 $rate = trim(convertCommaToDot($rate));
59                 if (!empty($rate)) $RATES[] = $rate;
60         } // END - foreach
61         setPostRequestParameter('turbo_rates', trim(implode(';', $RATES)));
62         unsetPostRequestParameter('rate');
63
64         // Automatically calculate bonus points for ranks 2 and 3 when not set
65         if (!isPostRequestParameterSet('turbo_rates')) setPostRequestParameter('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).'');
66
67         // Save data
68         adminSaveSettingsFromPostData();
69
70         // Remember new settings
71         setConfigEntry('bonus_active'        , postRequestParameter('bonus_active'));
72         setConfigEntry('bonus_enable_notify' , postRequestParameter('bonus_enable_notify'));
73         setConfigEntry('bonus_disable_notify', postRequestParameter('bonus_disable_notify'));
74 } else {
75         // Transfer options to template
76         $content['form_selection'] = addMemberSelectionBox(getBonusUserId(), false, true, true, 'bonus_userid');
77
78         // Initialize array for the points list
79         $RANKS = explode(';', getConfig('turbo_rates'));
80
81         // Automatically calculate bonus points for ranks 2 and 3 when not set
82         if (getConfig('turbo_rates') == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4));
83
84         // Generate list
85         $OUT = '<ol start="2">';
86         $count = '0';
87         foreach ($RANKS as $k => $rate) {
88                 if (!empty($rate)) {
89                         // Print only when something is in
90                         $OUT .= '<li><input type="text" name="rate[' . ($k + 2) . ']" class="form_field" size="4" maxlength="7" value="' . $rate . '" /> <div class="notice">({?POINTS?})</div></li>';
91                 } // END - if
92                 $count++;
93         } // END - foreach
94
95         // Maxmium entries
96         $max = 10;
97         if ($count >= 8) $max = $count+3;
98
99         // Add more empty fields
100         for ($i = $count; $i < $max; $i++) {
101                 $OUT .= '  <li><input type="text" name="rate[' . ($i+2) . ']" class="form_field" size="4" maxlength="7" /> <div class="notice">({?POINTS?})</div></li>';
102         } // END - for
103         $OUT .= '</ol>';
104         $content['trates_list'] = $OUT;
105
106         // Selection boxes
107         $content['login_timeout_selection'] = createTimeSelections(getConfig('login_timeout')    , 'login_timeout'    , 'WDh');
108         $content['bonus_timeout_selection'] = createTimeSelections(getConfig('bonus_timeout')    , 'bonus_timeout'    , 'WDh');
109         $content['wait_selection']          = createTimeSelections(getConfig('bonus_notify_wait'), 'bonus_notify_wait', 'ms' );
110
111         // Init Y/N selections
112         foreach (array('active','login_yn','stats_yn','order_yn','ref_yn','click_yn','enable_notify','disable_notify','new_member_notify','include_own') as $entry) {
113                 $content[$entry . '_y'] = '';
114                 $content[$entry . '_n'] = '';
115                 $content[$entry . '_' . strtolower(getConfig('bonus_' . $entry))] = ' checked="checked"';
116         } // END - foreach
117
118         // Load final template
119         loadTemplate('admin_config_bonus', false, $content);
120 }
121
122 // [EOF]
123 ?>