b57ebfaccf800b83b47a5431b45a387ec4935f9a
[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  * 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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (isFormSent()) {
49         // Replace german decimal commas to computer decimal dots
50         setPostRequestParameter('login_bonus',         convertCommaToDot(postRequestParameter('login_bonus')));
51         setPostRequestParameter('turbo_bonus',         convertCommaToDot(postRequestParameter('turbo_bonus')));
52         setPostRequestParameter('bonus_ref',           convertCommaToDot(postRequestParameter('bonus_ref')));
53         setPostRequestParameter('bonus_order',         convertCommaToDot(postRequestParameter('bonus_order')));
54         setPostRequestParameter('bonus_notify_points', convertCommaToDot(postRequestParameter('bonus_notify_points')));
55
56         // Generate string for saving ranks
57         setPostRequestParameter('turbo_rates', '');
58         $RATES = array();
59         foreach (postRequestParameter('rate') as $rate) {
60                 $rate = trim(convertCommaToDot($rate));
61                 if (!empty($rate)) $RATES[] = $rate;
62         }
63         setPostRequestParameter('turbo_rates', trim(implode(';', $RATES)));
64         unsetPostRequestParameter('rate');
65
66         // Automatically calculate bonus points for ranks 2 and 3 when not set
67         if (!isPostRequestParameterSet('turbo_rates')) setPostRequestParameter('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).'');
68
69         // Save data
70         adminSaveSettingsFromPostData();
71
72         // Remember new settings
73         setConfigEntry('bonus_active'   , postRequestParameter('bonus_active'));
74         setConfigEntry('bonus_en_notify', postRequestParameter('bonus_en_notify'));
75         setConfigEntry('bonus_di_notify', postRequestParameter('bonus_di_notify'));
76 } else {
77         // Prepare contants for the template
78         $content['login']  = translateComma(getConfig('login_bonus')        , false);
79         $content['turbo']  = translateComma(getConfig('turbo_bonus')        , false);
80         $content['order']  = translateComma(getConfig('bonus_order')        , false);
81         $content['ref']    = translateComma(getConfig('bonus_ref')          , false);
82         $content['stats']  = translateComma(getConfig('bonus_stats')        , false);
83         $content['notify'] = translateComma(getConfig('bonus_notify_points'), false);
84
85         // Transfer options to template
86         $content['member_selection'] = addMemberSelectionBox(getConfig('bonus_userid'), false, true, true, 'bonus_userid');
87
88         // Initialize array for the points list
89         //die("*".getConfig('turbo_rates')."*");
90         $RANKS = explode(';', getConfig('turbo_rates'));
91
92         // Automatically calculate bonus points for ranks 2 and 3 when not set
93         if (getConfig('turbo_rates') == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4));
94
95         // Generate list
96         $OUT = "<ol start=\"2\">\n";
97         $cnt = '0';
98         foreach ($RANKS as $k => $rate) {
99                 if (!empty($rate))      {
100                         // Print only when something is in
101                         $OUT .= "  <li><input type=\"text\" name=\"rate[".($k + 2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\" value=\"".$rate."\" /> <div class=\"admin_notes\">({?POINTS?})</div?</li>\n";
102                 } // END - if
103                 $cnt++;
104         } // END - foreach
105
106         // Maxmium entries
107         $max = 10;
108         if ($cnt >= 8) $max = $cnt+3;
109
110         // Add more empty fields
111         for ($i = $cnt; $i < $max; $i++) {
112                 $OUT .= "  <li><input type=\"text\" name=\"rate[".($i+2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\" /> <div class=\"admin_notes\">({?POINTS?})</div></li>\n";
113         } // END - for
114         $OUT .= "</ol>\n";
115         $content['trates_list'] = $OUT;
116
117         // Selection boxes
118         $content['login_timeout_selection'] = createTimeSelections(getConfig('login_timeout')    , 'login_timeout'    , 'WDh');
119         $content['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         // Init Y/N selections
123         foreach (array('active','login_yn','stats_yn','order_yn','ref_yn','click_yn','en_notify','di_notify','new_mem_notify','include_own') as $entry) {
124                 $content[$entry . '_y'] = '';
125                 $content[$entry . '_n'] = '';
126                 $content[$entry . '_' . strtolower(getConfig('bonus_' . $entry))] = ' checked="checked"';
127         } // END - foreach
128
129         // Load final template
130         loadTemplate('admin_config_bonus', false, $content);
131 }
132
133 // [EOF]
134 ?>