From: Roland Häder Date: Sat, 25 Jun 2011 22:58:21 +0000 (+0000) Subject: Wrapper functions for converting commas in configuration added, ext-coupon continued X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=a44235215a481489b76a39269cf98b170901186b Wrapper functions for converting commas in configuration added, ext-coupon continued - First configuration template and script for ext-coupon added - Wrapper functions convertCommaToDotInPostData() and convertCommaToDotInPostDataArray() introduced which will wrap converting German comma into Computer's version - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index 75d40c21fe..527b1834db 100644 --- a/.gitattributes +++ b/.gitattributes @@ -260,6 +260,7 @@ inc/language/bonus_de.php svneol=native#text/plain inc/language/booking_de.php svneol=native#text/plain inc/language/cache_de.php svneol=native#text/plain inc/language/country_de.php svneol=native#text/plain +inc/language/coupon_de.php svneol=native#text/plain inc/language/de.php svneol=native#text/plain inc/language/debug_de.php svneol=native#text/plain inc/language/doubler_de.php svneol=native#text/plain @@ -315,6 +316,7 @@ inc/libs/bonus_functions.php svneol=native#text/plain inc/libs/booking_functions.php svneol=native#text/plain inc/libs/cache_functions.php svneol=native#text/plain inc/libs/country_functions.php svneol=native#text/plain +inc/libs/coupon_functions.php svneol=native#text/plain inc/libs/debug_functions.php svneol=native#text/plain inc/libs/doubler_functions.php svneol=native#text/plain inc/libs/events_functions.php svneol=native#text/plain @@ -391,6 +393,7 @@ inc/modules/admin/action- svneol=native#text/plain inc/modules/admin/action-admins.php svneol=native#text/plain inc/modules/admin/action-bank.php svneol=native#text/plain inc/modules/admin/action-country.php svneol=native#text/plain +inc/modules/admin/action-coupon.php svneol=native#text/plain inc/modules/admin/action-doubler.php svneol=native#text/plain inc/modules/admin/action-email.php svneol=native#text/plain inc/modules/admin/action-holiday.php svneol=native#text/plain @@ -441,6 +444,7 @@ inc/modules/admin/what-config_beg.php svneol=native#text/plain inc/modules/admin/what-config_birthday.php svneol=native#text/plain inc/modules/admin/what-config_bonus.php svneol=native#text/plain inc/modules/admin/what-config_cats.php svneol=native#text/plain +inc/modules/admin/what-config_coupon.php svneol=native#text/plain inc/modules/admin/what-config_doubler.php svneol=native#text/plain inc/modules/admin/what-config_email.php svneol=native#text/plain inc/modules/admin/what-config_extensions.php svneol=native#text/plain @@ -967,6 +971,7 @@ templates/de/html/admin/admin_admins_mails_edit_row.tpl svneol=native#text/plain templates/de/html/admin/admin_admins_mails_list.tpl svneol=native#text/plain templates/de/html/admin/admin_admins_mails_list_row.tpl svneol=native#text/plain templates/de/html/admin/admin_cache_stats.tpl svneol=native#text/plain +templates/de/html/admin/admin_config_ svneol=native#text/plain templates/de/html/admin/admin_config_active.tpl svneol=native#text/plain templates/de/html/admin/admin_config_admin.tpl svneol=native#text/plain templates/de/html/admin/admin_config_admins.tpl svneol=native#text/plain @@ -981,6 +986,7 @@ templates/de/html/admin/admin_config_birthday.tpl svneol=native#text/plain templates/de/html/admin/admin_config_bonus.tpl svneol=native#text/plain templates/de/html/admin/admin_config_cats.tpl svneol=native#text/plain templates/de/html/admin/admin_config_cats_row.tpl svneol=native#text/plain +templates/de/html/admin/admin_config_coupon.tpl svneol=native#text/plain templates/de/html/admin/admin_config_doubler.tpl svneol=native#text/plain templates/de/html/admin/admin_config_email.tpl svneol=native#text/plain templates/de/html/admin/admin_config_email_del.tpl svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 3fca4825ed..c1c290fe52 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -47,13 +47,13 @@ ./inc/extensions-functions.php:567: // @TODO Extension is loaded, what next? ./inc/filter/bonus_filter.php:55: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/filter/cache_filter.php:78: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. -./inc/functions.php:1213: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? -./inc/functions.php:1301: // @TODO Are these convertions still required? -./inc/functions.php:1319:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:1217: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? +./inc/functions.php:1305: // @TODO Are these convertions still required? +./inc/functions.php:1323:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:163:// @TODO Rewrite this to an extension 'smtp' -./inc/functions.php:1901: // @TODO Find a way to cache this -./inc/functions.php:2002: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2182: // @TODO Rename column data_type to e.g. mail_status +./inc/functions.php:1905: // @TODO Find a way to cache this +./inc/functions.php:2006: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2186: // @TODO Rename column data_type to e.g. mail_status ./inc/functions.php:92: // @TODO Extension 'msg' does not exist ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); diff --git a/inc/extensions/ext-coupon.php b/inc/extensions/ext-coupon.php index 03d3a9495d..c6b6a3e22a 100644 --- a/inc/extensions/ext-coupon.php +++ b/inc/extensions/ext-coupon.php @@ -82,7 +82,7 @@ UNIQUE KEY (`coupon_code`) // Configuration entries addConfigAddSql('coupon_default_time', 'BIGINT(20) NOT NULL DEFAULT ' . (getOneDay() * 7)); - addConfigAddSql('coupon_default_points', 'FLOAT(20,5) NOT NULL DEFAULT 1000.00000'); + addConfigAddSql('coupon_default_points', 'FLOAT(20,5) NOT NULL DEFAULT 100.00000'); // Menu systems: // - Admin entries diff --git a/inc/functions.php b/inc/functions.php index da112b43fa..bc397426cf 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -346,14 +346,18 @@ function translateComma ($dotted, $cut = true, $max = '0') { // First, cast all to double, due to PHP changes $dotted = (double) $dotted; - // Default is 3 you can change this in admin area "Misc -> Misc Options" - if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', 3); + // Default is 3 you can change this in admin area "Settings -> Misc Options" + if (!isConfigEntrySet('max_comma')) { + setConfigEntry('max_comma', 3); + } // END - if // Use from config is default $maxComma = getConfig('max_comma'); // Use from parameter? - if ($max > 0) $maxComma = $max; + if ($max > 0) { + $maxComma = $max; + } // END - if // Cut zeros off? if (($cut === true) && ($max == '0')) { diff --git a/inc/language/coupon_de.php b/inc/language/coupon_de.php new file mode 100644 index 0000000000..f183ad4bfb --- /dev/null +++ b/inc/language/coupon_de.php @@ -0,0 +1,51 @@ + "Allgemeine Einstellungen zu den Gutscheinen", + 'ADMIN_CONFIG_COUPON_DEFAULT_TIME' => "Zeit, bis Gutscheine ablaufen sollen. Sie können diesen Ausgangswert beim Erstellen von neuen Gutscheinen nachträglich anpassen.", + 'ADMIN_CONFIG_COUPON_DEFAULT_POINTS' => "Ausgangsvergütung in {?POINTS?}. Sie können diesen Ausgangswert beim Erstellen von neuen Gutscheinen nachträglich anpassen.", +)); + +// [EOF] +?> diff --git a/inc/libs/coupon_functions.php b/inc/libs/coupon_functions.php new file mode 100644 index 0000000000..e17e525532 --- /dev/null +++ b/inc/libs/coupon_functions.php @@ -0,0 +1,56 @@ + diff --git a/inc/modules/admin/action-coupon.php b/inc/modules/admin/action-coupon.php new file mode 100644 index 0000000000..d40bd88add --- /dev/null +++ b/inc/modules/admin/action-coupon.php @@ -0,0 +1,56 @@ + diff --git a/inc/modules/admin/what-config_beg.php b/inc/modules/admin/what-config_beg.php index 18f1c1aba5..84062756e2 100644 --- a/inc/modules/admin/what-config_beg.php +++ b/inc/modules/admin/what-config_beg.php @@ -44,10 +44,8 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { addYouAreHereLink('admin', __FILE__); if (isFormSent()) { - // Translate german decimal commas to computer decimal dots - setPostRequestParameter('beg_points' , convertCommaToDot(postRequestParameter('beg_points') )); - setPostRequestParameter('beg_points_max' , convertCommaToDot(postRequestParameter('beg_points_max') )); - setPostRequestParameter('beg_notify_bonus', convertCommaToDot(postRequestParameter('beg_notify_bonus'))); + // Replace german decimal comma with computer decimal dot + convertCommaToDotInPostDataArray(array('beg_points', 'beg_points_max', 'beg_notify_bonus')); // Save settings adminSaveSettingsFromPostData(); diff --git a/inc/modules/admin/what-config_bonus.php b/inc/modules/admin/what-config_bonus.php index bfa6a2feed..f8878843f5 100644 --- a/inc/modules/admin/what-config_bonus.php +++ b/inc/modules/admin/what-config_bonus.php @@ -44,12 +44,8 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { addYouAreHereLink('admin', __FILE__); if (isFormSent()) { - // Replace german decimal commas to computer decimal dots - 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'))); + // Replace german decimal comma with computer decimal dot + convertCommaToDotInPostDataArray(array('login_bonus', 'turbo_bonus', 'bonus_ref', 'bonus_order', 'bonus_notify_points')); // Generate string for saving ranks setPostRequestParameter('turbo_rates', ''); @@ -62,7 +58,9 @@ if (isFormSent()) { unsetPostRequestParameter('rate'); // Automatically calculate bonus points for ranks 2 and 3 when not set - if (!isPostRequestParameterSet('turbo_rates')) setPostRequestParameter('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).''); + if (!isPostRequestParameterSet('turbo_rates')) { + setPostRequestParameter('turbo_rates', ''.round(getConfig('turbo_bonus') / 2).';'.round(getConfig('turbo_bonus') / 4).''); + } // END - if // Save data adminSaveSettingsFromPostData(); diff --git a/inc/modules/admin/what-config_coupon.php b/inc/modules/admin/what-config_coupon.php new file mode 100644 index 0000000000..fb9a11a90e --- /dev/null +++ b/inc/modules/admin/what-config_coupon.php @@ -0,0 +1,61 @@ + diff --git a/inc/modules/admin/what-config_doubler.php b/inc/modules/admin/what-config_doubler.php index 6738249233..f26d37e212 100644 --- a/inc/modules/admin/what-config_doubler.php +++ b/inc/modules/admin/what-config_doubler.php @@ -44,18 +44,14 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { addYouAreHereLink('admin', __FILE__); if (isFormSent()) { - // Replace commata with decimal dot - setPostRequestParameter('doubler_charge', convertCommaToDot(postRequestParameter('doubler_charge'))); - setPostRequestParameter('doubler_ref' , convertCommaToDot(postRequestParameter('doubler_ref'))); - setPostRequestParameter('doubler_min' , convertCommaToDot(postRequestParameter('doubler_min'))); - setPostRequestParameter('doubler_max' , convertCommaToDot(postRequestParameter('doubler_max'))); - setPostRequestParameter('doubler_left' , convertCommaToDot(postRequestParameter('doubler_left'))); + // Replace german decimal comma with computer decimal dot + convertCommaToDotInPostDataArray(array('doubler_charge', 'doubler_ref', 'doubler_min', 'doubler_max', 'doubler_left')); // Save settings adminSaveSettingsFromPostData(); } else { // Init all Y/N selections - foreach (array('jackpot','own','sent_all') as $entry) { + foreach (array('jackpot', 'own', 'sent_all') as $entry) { $content[$entry . '_y'] = ''; $content[$entry . '_n'] = ''; $content[$entry . '_' . strtolower(getConfig('doubler_' . $entry))] = ' checked="checked"'; diff --git a/inc/modules/admin/what-config_payouts.php b/inc/modules/admin/what-config_payouts.php index d3b77e7d5c..8a5e102d6c 100644 --- a/inc/modules/admin/what-config_payouts.php +++ b/inc/modules/admin/what-config_payouts.php @@ -43,7 +43,10 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addYouAreHereLink('admin', __FILE__); -if (isPostRequestParameterSet('rate')) setPostRequestParameter('rate', convertCommaToDot(postRequestParameter('rate'))); +// Convert 'rate' if set +if (isPostRequestParameterSet('rate')) { + convertCommaToDotInPostData('rate'); +} // END - if if ((isFormSent('add')) && (isPostRequestParameterSet('title')) && (postRequestParameter('rate') > 0)) { // Add new payout type diff --git a/inc/modules/admin/what-config_refback.php b/inc/modules/admin/what-config_refback.php index bb5834696c..a8a381d166 100644 --- a/inc/modules/admin/what-config_refback.php +++ b/inc/modules/admin/what-config_refback.php @@ -45,8 +45,7 @@ addYouAreHereLink('admin', __FILE__); if (isFormSent()) { // Replace german decimal comma with computer decimal dot - if (isPostRequestParameterSet('refback_min_perc')) setPostRequestParameter('refback_min_perc', convertCommaToDot(postRequestParameter('refback_min_perc'))); - if (isPostRequestParameterSet('refback_max_perc')) setPostRequestParameter('refback_max_perc', convertCommaToDot(postRequestParameter('refback_max_perc'))); + convertCommaToDotInPostDataArray(array('refback_min_perc', 'refback_max_perc')); // Save configuration adminSaveSettingsFromPostData(); diff --git a/inc/modules/admin/what-config_surfbar.php b/inc/modules/admin/what-config_surfbar.php index f0213cd06c..a0b77e469c 100644 --- a/inc/modules/admin/what-config_surfbar.php +++ b/inc/modules/admin/what-config_surfbar.php @@ -46,9 +46,7 @@ addYouAreHereLink('admin', __FILE__); // Was the form submitted? if (isFormSent()) { // Replace german decimal comma with computer decimal dot - if (isPostRequestParameterSet('surfbar_static_reward')) setPostRequestParameter('surfbar_static_reward' , convertCommaToDot(postRequestParameter('surfbar_static_reward'))); - if (isPostRequestParameterSet('surfbar_static_costs')) setPostRequestParameter('surfbar_static_costs' , convertCommaToDot(postRequestParameter('surfbar_static_costs'))); - if (isPostRequestParameterSet('surfbar_dynamic_percent')) setPostRequestParameter('surfbar_dynamic_percent', convertCommaToDot(postRequestParameter('surfbar_dynamic_percent'))); + convertCommaToDotInPostDataArray(array('surfbar_static_reward', 'surfbar_static_costs', 'surfbar_dynamic_percent')); // Save settings adminSaveSettingsFromPostData(); diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 81fbc2f8b0..9b27b66fee 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2442,12 +2442,33 @@ function firstCharUpperCase ($str) { } // Shortens calls with configuration entry as first argument (the second will become obsolete in the future) -function createConfigurationTimeSelections ($configEntry, $stamps) { +function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') { // Get the configuration entry $configValue = getConfig($configEntry); // Call inner method - return createTimeSelections($configValue, $configEntry, $stamps); + return createTimeSelections($configValue, $configEntry, $stamps, $align); +} + +// Shortens converting of German comma to Computer's version in POST data +function convertCommaToDotInPostData ($postEntry) { + // Read and convert given entry + $postValue = convertCommaToDot(postRequestParameter($postEntry)); + + // ... and set it again + setPostRequestParameter($postEntry, $postValue); +} + +// Converts German commas to Computer's version in all entries +function convertCommaToDotInPostDataArray (array $postEntries) { + // Replace german decimal comma with computer decimal dot + foreach ($postEntries as $entry) { + // Is the entry there? + if (isPostRequestParameterSet($entry)) { + // Then convert it + convertCommaToDotInPostData($entry); + } // END - if + } // END - foreach } // [EOF] diff --git a/templates/de/html/admin/admin_config_ b/templates/de/html/admin/admin_config_ new file mode 100644 index 0000000000..2d9555694b --- /dev/null +++ b/templates/de/html/admin/admin_config_ @@ -0,0 +1,23 @@ +
+
+ + + + + + + + + + + +
+ {--ADMIN_CONFIG__SETTINGS_TITLE--}: +
{--ADMIN_CONFIG_--}: + +
+
+
diff --git a/templates/de/html/admin/admin_config_coupon.tpl b/templates/de/html/admin/admin_config_coupon.tpl new file mode 100644 index 0000000000..3a221b8542 --- /dev/null +++ b/templates/de/html/admin/admin_config_coupon.tpl @@ -0,0 +1,30 @@ +
+
+ + + + + + + + + + + + + + + +
+ {--ADMIN_CONFIG_COUPON_SETTINGS_TITLE--}: +
{--ADMIN_CONFIG_COUPON_DEFAULT_TIME--}: + $content[coupon_default_time_selection] +
{--ADMIN_CONFIG_COUPON_DEFAULT_POINTS--}: + + ({?POINTS?}) +
+
+