Min/max reback percents implemented
authorRoland Häder <roland@mxchange.org>
Sun, 12 Oct 2008 00:50:37 +0000 (00:50 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 12 Oct 2008 00:50:37 +0000 (00:50 +0000)
inc/databases.php
inc/language/refback_de.php
inc/modules/member/what-refback.php

index f54c7a9..b994f3e 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "494");
+define('CURR_SVN_REVISION', "495");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index fece0bb..c0a2936 100644 (file)
@@ -72,6 +72,7 @@ define('MEMBER_REFBACK_ERROR_INVALID_ID_NUMBER', "Ung&uuml;ltige ID-Nummer &uuml
 define('MEMBER_REFBACK_ERROR_INVALID_PERCENTAGE', "Prozentsatz ung&uuml;ltig. 0 bis 100 sind g&uuml;ltige Werte.");
 define('MEMBER_REFBACK_ERROR_ID_MISMATCH', "Die ausgew&auml;hlte Ref-Back ID geh&ouml;rt Ihnen nicht.");
 define('MEMBER_REFBACK_ERROR_NOT_UPDATED', "Ref-Back nicht aktualisiert.");
+define('MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS', "Sie k&ouml;nnen nur mindestens <u>%s&#37;</> und maximal <u>%s&#37;</u> einstellen!");
 define('MEMBER_REFBACK_DONE', "Ref-Back eingestellt. Dieser ist ab jetzt g&uuml;ltig.");
 
 // Subject lines
index 5a965b6..db6fdcd 100644 (file)
@@ -59,19 +59,25 @@ ADD_DESCR("member", __FILE__);
 if ((isset($_POST['edit'])) && (isset($_POST['id']))) {
        // Okay, has the user entered some values?
        if (isset($_POST['percents'])) {
-               // Change ref-back for this direct id
-               $status = REFBACK_CHANGE_MEMBER_PERCENTS($_POST['id'], $_POST['percents']);
-
-               // Check status
-               if (isset($status['ok'])) {
-                       // No message found
-                       LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_DONE);
-               } elseif (isset($status['message'])) {
-                       // Something went wrong with error message
-                       LOAD_TEMPLATE("admin_settings_saved", false, sprintf(MEMBER_REFBACK_ERROR_MESSAGE, $status['message']));
+               // Validate percents
+               if (($_POST['percents'] >= $_CONFIG['refback_min_percents']) || ($_POST['percents'] == 0)) && ($_POST['percents'] <= $_CONFIG['refback_max_percents'])) {
+                       // Change ref-back for this direct id
+                       $status = REFBACK_CHANGE_MEMBER_PERCENTS($_POST['id'], $_POST['percents']);
+
+                       // Check status
+                       if (isset($status['ok'])) {
+                               // No message found
+                               LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_DONE);
+                       } elseif (isset($status['message'])) {
+                               // Something went wrong with error message
+                               LOAD_TEMPLATE("admin_settings_saved", false, sprintf(MEMBER_REFBACK_ERROR_MESSAGE, $status['message']));
+                       } else {
+                               // No message found
+                               LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_ERROR_EMPTY_MESSAGE);
+                       }
                } else {
-                       // No message found
-                       LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_ERROR_EMPTY_MESSAGE);
+                       // Percents out-of-bounds ;-)
+                       LOAD_TEMPLATE("admin_settings_saved", false, sprintf(MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS, $_CONFIG['refback_min_percents'], $_CONFIG['refback_max_percents']));
                }
 
                // Insert line
@@ -132,7 +138,7 @@ if (SQL_NUMROWS($result) > 0) {
 
                // Remember the content
                $content['counter']  = TRANSLATE_COMMA($counter);
-               $content['percents'] = TRANSLATE_COMMA($content['percents']);
+               $content['percents'] = TRANSLATE_COMMA($content['percents'], true, 1);
                $content['rows']     = $rows;
 
                // Load level template