More HTML improvements
[mailer.git] / inc / modules / admin / what-config_bonus.php
index cb432f2812f883f4f9ced2247e8cca1b526b76b6..bd3f764c40bfc2045d29b492af174258c99fb9c3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 08/31/2004 *
- * ================                             Last change: 11/14/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 08/31/2004 *
+ * ===================                          Last change: 11/14/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-config_bonus.php                            *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Einstellen der Turbo-Klick-Verguetungen          *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  ************************************************************************/
 
 // Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
+} // END - if
+
 // Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+addMenuDescription('admin', __FILE__);
 
-if (isset($_POST['ok']))
-{
+if (isFormSent()) {
        // Replace german decimal commas to computer decimal dots
-       $_POST['login_bonus']         = str_replace(",", ".", $_POST['login_bonus']        );
-       $_POST['turbo_bonus']         = str_replace(",", ".", $_POST['turbo_bonus']        );
-       $_POST['bonus_ref']           = str_replace(",", ".", $_POST['bonus_ref']          );
-       $_POST['bonus_order']         = str_replace(",", ".", $_POST['bonus_order']        );
-       $_POST['bonus_notify_points'] = str_replace(",", ".", $_POST['bonus_notify_points']);
+       setPostRequestParameter('login_bonus',         convertCommaToDot(postRequestParameter('login_bonus')));
+       setPostRequestParameter('turbo_bonus',         convertCommaToDot(postRequestParameter('turbo_bonus')));
+       setPostRequestParameter('bonus_ref',           convertCommaToDot(postRequestParameter('bonus_ref')));
+       setPostRequestParameter('bonus_order',         convertCommaToDot(postRequestParameter('bonus_order')));
+       setPostRequestParameter('bonus_notify_points', convertCommaToDot(postRequestParameter('bonus_notify_points')));
 
        // Generate string for saving ranks
-       $_POST['turbo_rates'] = ""; $RATES = array();
-       foreach ($_POST['rate'] as $rate)
-       {
-               $rate = trim(str_replace(",", ".", $rate));
-               if (isset($rate)) $RATES[] = $rate;
+       setPostRequestParameter('turbo_rates', '');
+       $RATES = array();
+       foreach (postRequestParameter('rate') as $rate) {
+               $rate = trim(convertCommaToDot($rate));
+               if (!empty($rate)) $RATES[] = $rate;
        }
-       $_POST['turbo_rates'] = trim(implode(";", $RATES));
-       unset($_POST['rate']);
+       setPostRequestParameter('turbo_rates', trim(implode(';', $RATES)));
+       unsetPostRequestParameter('rate');
 
        // Automatically calculate bonus points for ranks 2 and 3 when not set
-       if (empty($_POST['turbo_rates'])) $_POST['turbo_rates'] = "".round($_CONFIG['turbo_bonus'] / 2).";".round($_CONFIG['turbo_bonus'] / 4)."";
+       if (!isPostRequestParameterSet('turbo_rates')) setPostRequestParameter('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).'');
 
        // Save data
-       ADMIN_SAVE_SETTINGS($_POST);
+       adminSaveSettingsFromPostData();
 
        // Remember new settings
-       $_CONFIG['bonus_active']    = $_POST['bonus_active'];
-       $_CONFIG['bonus_en_notify'] = $_POST['bonus_en_notify'];
-       $_CONFIG['bonus_di_notify'] = $_POST['bonus_di_notify'];
-
-       // Include sending out mails
-       if ((($_CONFIG['bonus_active'] == "Y") && ($_CONFIG['bonus_en_notify'] == "Y")) || (($_CONFIG['bonus_active'] == "N") && ($_CONFIG['bonus_di_notify'] == "Y")))
-       {
-               include(PATH."inc/mails/bonus_mails.php");
-       }
-}
- else
-{
+       setConfigEntry('bonus_active'   , postRequestParameter('bonus_active'));
+       setConfigEntry('bonus_en_notify', postRequestParameter('bonus_en_notify'));
+       setConfigEntry('bonus_di_notify', postRequestParameter('bonus_di_notify'));
+} else {
        // Prepare contants for the template
-       define('__LOGIN_VALUE' , TRANSLATE_COMMA($_CONFIG['login_bonus']        , false));
-       define('__TURBO_VALUE' , TRANSLATE_COMMA($_CONFIG['turbo_bonus']        , false));
-       define('__ORDER_VALUE' , TRANSLATE_COMMA($_CONFIG['bonus_order']        , false));
-       define('__REF_VALUE'   , TRANSLATE_COMMA($_CONFIG['bonus_ref']          , false));
-       define('__STATS_VALUE' , TRANSLATE_COMMA($_CONFIG['bonus_stats']        , false));
-       define('__NOTIFY_VALUE', TRANSLATE_COMMA($_CONFIG['bonus_notify_points'], false));
-       define('__TRANKS_VALUE', $_CONFIG['bonus_ranks']);
-       define('__TLINES_VALUE', $_CONFIG['bonus_lines']);
-
-       // Transfer options to template __MEMBER_SELECTION
-       ADD_MEMBER_SELECTION_BOX(false, true, true, $_CONFIG['bonus_uid']);
+       $content['login']  = translateComma(getConfig('login_bonus')        , false);
+       $content['turbo']  = translateComma(getConfig('turbo_bonus')        , false);
+       $content['order']  = translateComma(getConfig('bonus_order')        , false);
+       $content['ref']    = translateComma(getConfig('bonus_ref')          , false);
+       $content['stats']  = translateComma(getConfig('bonus_stats')        , false);
+       $content['notify'] = translateComma(getConfig('bonus_notify_points'), false);
+
+       // Transfer options to template
+       $content['member_selection'] = addMemberSelectionBox(getConfig('bonus_userid'), false, true, true, 'bonus_userid');
 
        // Initialize array for the points list
-       $RANKS = explode(";", $_CONFIG['bonus_rates']);
+       //die("*".getConfig('turbo_rates')."*");
+       $RANKS = explode(';', getConfig('turbo_rates'));
 
        // Automatically calculate bonus points for ranks 2 and 3 when not set
-       if (empty($_CONFIG['bonus_rates'])) $RANKS = array(round($_CONFIG['turbo_bonus'] / 2), round($_CONFIG['turbo_bonus'] / 4));
+       if (getConfig('turbo_rates') == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4));
 
        // Generate list
-       $OUT = "<OL start=\"2\">\n";
-       foreach ($RANKS as $k=>$rate)
-       {
-               if (!empty($rate))
-               {
+       $OUT = "<ol start=\"2\">\n";
+       $cnt = '0';
+       foreach ($RANKS as $k => $rate) {
+               if (!empty($rate))      {
                        // Print only when something is in
-                       $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";
-               }
-       }
-       for ($i = 3; $i < 8; $i++)
-       {
-               $OUT .= "  <LI><INPUT type=\"text\" name=\"rate[".($k + $i)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\">&nbsp;<FONT class=\"admin_notes\">(".POINTS.")</FONT?</LI>\n";
-       }
-       $OUT .= "</OL>\n";
-       define('__TRATES_LIST', $OUT);
-
-       define('__LOGIN_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS($_CONFIG['login_timeout']    , "login_timeout"    , "WDh"));
-       define('__BONUS_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS($_CONFIG['bonus_timeout']    , "bonus_timeout"    , "WDh"));
-       define('__WAIT_SELECTION'         , CREATE_TIME_SELECTIONS($_CONFIG['bonus_notify_wait'], "bonus_notify_wait", "ms" ));
-
-       // Activate / Deactivate bonus active rallye (Y/N)
-       switch ($_CONFIG['bonus_active'])
-       {
-       case 'Y':
-               define('__BONUS_ACTIVE_Y', ' checked');
-               define('__BONUS_ACTIVE_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_ACTIVE_Y', "");
-               define('__BONUS_ACTIVE_N', ' checked');
-               break;
-       }
-       // Other bonus to de-/activate
-       switch ($_CONFIG['bonus_login_yn'])
-       {
-       case 'Y':
-               define('__BONUS_LOGIN_Y', ' checked');
-               define('__BONUS_LOGIN_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_LOGIN_Y', "");
-               define('__BONUS_LOGIN_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_stats_yn'])
-       {
-       case 'Y':
-               define('__BONUS_STATS_Y', ' checked');
-               define('__BONUS_STATS_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_STATS_Y', "");
-               define('__BONUS_STATS_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_order_yn'])
-       {
-       case 'Y':
-               define('__BONUS_ORDER_Y', ' checked');
-               define('__BONUS_ORDER_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_ORDER_Y', "");
-               define('__BONUS_ORDER_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_ref_yn'])
-       {
-       case 'Y':
-               define('__BONUS_REF_Y', ' checked');
-               define('__BONUS_REF_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_REF_Y', "");
-               define('__BONUS_REF_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_click_yn'])
-       {
-       case 'Y':
-               define('__BONUS_CLICK_Y', ' checked');
-               define('__BONUS_CLICK_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_CLICK_Y', "");
-               define('__BONUS_CLICK_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_en_notify'])
-       {
-       case 'Y':
-               define('__BONUS_EN_NOTIFY_Y', ' checked');
-               define('__BONUS_EN_NOTIFY_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_EN_NOTIFY_Y', "");
-               define('__BONUS_EN_NOTIFY_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_di_notify'])
-       {
-       case 'Y':
-               define('__BONUS_DI_NOTIFY_Y', ' checked');
-               define('__BONUS_DI_NOTIFY_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_DI_NOTIFY_Y', "");
-               define('__BONUS_DI_NOTIFY_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_new_mem_notify'])
-       {
-       case 'Y':
-               define('__BONUS_NEW_MEMBER_NOTIFY_Y', ' checked');
-               define('__BONUS_NEW_MEMBER_NOTIFY_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_NEW_MEMBER_NOTIFY_Y', "");
-               define('__BONUS_NEW_MEMBER_NOTIFY_N', ' checked');
-               break;
-       }
-       switch ($_CONFIG['bonus_include_own'])
-       {
-       case 'Y':
-               define('__BONUS_INCLUDE_OWN_Y', ' checked');
-               define('__BONUS_INCLUDE_OWN_N', "");
-               break;
-
-       case 'N':
-               define('__BONUS_INCLUDE_OWN_Y', "");
-               define('__BONUS_INCLUDE_OWN_N', ' checked');
-               break;
-       }
+                       $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";
+               } // END - if
+               $cnt++;
+       } // END - foreach
+
+       // Maxmium entries
+       $max = 10;
+       if ($cnt >= 8) $max = $cnt+3;
+
+       // Add more empty fields
+       for ($i = $cnt; $i < $max; $i++) {
+               $OUT .= "  <li><input type=\"text\" name=\"rate[".($i+2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\" /> <div class=\"admin_notes\">({?POINTS?})</div></li>\n";
+       } // END - for
+       $OUT .= "</ol>\n";
+       $content['trates_list'] = $OUT;
+
+       // Selection boxes
+       $content['login_timeout_selection'] = createTimeSelections(getConfig('login_timeout')    , 'login_timeout'    , 'WDh');
+       $content['bonus_timeout_selection'] = createTimeSelections(getConfig('bonus_timeout')    , 'bonus_timeout'    , 'WDh');
+       $content['wait_selection']          = createTimeSelections(getConfig('bonus_notify_wait'), 'bonus_notify_wait', 'ms' );
+
+       // Init Y/N selections
+       foreach (array('active','login_yn','stats_yn','order_yn','ref_yn','click_yn','en_notify','di_notify','new_mem_notify','include_own') as $entry) {
+               $content[$entry . '_y'] = '';
+               $content[$entry . '_n'] = '';
+               $content[$entry . '_' . strtolower(getConfig('bonus_' . $entry))] = ' checked="checked"';
+       } // END - foreach
 
        // Load final template
-       LOAD_TEMPLATE("admin_config_bonus", false);
+       loadTemplate('admin_config_bonus', false, $content);
 }
-//
+
+// [EOF]
 ?>