is missing
[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 - 2009 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')) || (!isAdmin())) {
41         die();
42 } // END - if
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 if (isFormSent()) {
48         // Replace german decimal commas to computer decimal dots
49         setRequestPostElement('login_bonus',         convertCommaToDot(postRequestElement('login_bonus')));
50         setRequestPostElement('turbo_bonus',         convertCommaToDot(postRequestElement('turbo_bonus')));
51         setRequestPostElement('bonus_ref',           convertCommaToDot(postRequestElement('bonus_ref')));
52         setRequestPostElement('bonus_order',         convertCommaToDot(postRequestElement('bonus_order')));
53         setRequestPostElement('bonus_notify_points', convertCommaToDot(postRequestElement('bonus_notify_points')));
54
55         // Generate string for saving ranks
56         setRequestPostElement('turbo_rates', '');
57         $RATES = array();
58         foreach (postRequestElement('rate') as $rate) {
59                 $rate = trim(convertCommaToDot($rate));
60                 if (!empty($rate)) $RATES[] = $rate;
61         }
62         setRequestPostElement('turbo_rates', trim(implode(';', $RATES)));
63         unsetPostRequestElement('rate');
64
65         // Automatically calculate bonus points for ranks 2 and 3 when not set
66         if (!isPostRequestElementSet('turbo_rates')) setRequestPostElement('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).'');
67
68         // Save data
69         adminSaveSettingsFromPostData();
70
71         // Remember new settings
72         setConfigEntry('bonus_active'   , postRequestElement('bonus_active'));
73         setConfigEntry('bonus_en_notify', postRequestElement('bonus_en_notify'));
74         setConfigEntry('bonus_di_notify', postRequestElement('bonus_di_notify'));
75 } else {
76         // Prepare contants for the template
77         $content['login']  = translateComma(getConfig('login_bonus')        , false);
78         $content['turbo']  = translateComma(getConfig('turbo_bonus')        , false);
79         $content['order']  = translateComma(getConfig('bonus_order')        , false);
80         $content['ref']    = translateComma(getConfig('bonus_ref')          , false);
81         $content['stats']  = translateComma(getConfig('bonus_stats')        , false);
82         $content['notify'] = translateComma(getConfig('bonus_notify_points'), false);
83
84         // Transfer options to template
85         $content['member_selection'] = addMemberSelectionBox(getConfig('bonus_userid'), false, true, true, 'bonus_userid');
86
87         // Initialize array for the points list
88         //die("*".getConfig('turbo_rates')."*");
89         $RANKS = explode(';', getConfig('turbo_rates'));
90
91         // Automatically calculate bonus points for ranks 2 and 3 when not set
92         if (getConfig('turbo_rates') == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4));
93
94         // Generate list
95         $OUT = "<ol start=\"2\">\n";
96         $cnt = 0;
97         foreach ($RANKS as $k => $rate) {
98                 if (!empty($rate))      {
99                         // Print only when something is in
100                         $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";
101                 } // END - if
102                 $cnt++;
103         } // END - foreach
104
105         // Maxmium entries
106         $max = 10;
107         if ($cnt >= 8) $max = $cnt+3;
108
109         // Add more empty fields
110         for ($i = $cnt; $i < $max; $i++) {
111                 $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";
112         } // END - for
113         $OUT .= "</ol>\n";
114         $content['trates_list'] = $OUT;
115
116         // Selection boxes
117         $content['login_timeout_selection'] = createTimeSelections(getConfig('login_timeout')    , 'login_timeout'    , 'WDh');
118         $content['bonus_timeout_selection'] = createTimeSelections(getConfig('bonus_timeout')    , 'bonus_timeout'    , 'WDh');
119         $content['wait_selection']          = createTimeSelections(getConfig('bonus_notify_wait'), 'bonus_notify_wait', 'ms' );
120
121         // Init Y/N selections
122         foreach (array('active','login_yn','stats_yn','order_yn','ref_yn','click_yn','en_notify','di_notify','new_mem_notify','include_own') as $entry) {
123                 $content[$entry . '_y'] = '';
124                 $content[$entry . '_n'] = '';
125                 $content[$entry . '_' . strtolower(getConfig('bonus_' . $entry))] = ' checked="checked"';
126         } // END - foreach
127
128         // Load final template
129         loadTemplate('admin_config_bonus', false, $content);
130 }
131
132 // [EOF]
133 ?>