]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-refback.php
Fix for error and min/max refback displayed in edit form
[mailer.git] / inc / modules / member / what-refback.php
index 5a965b6723ae0025c0212b29ea359bbd377f7dae..90d3ad7f624c3dde64cd0f7312325f47d9cf7006 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
@@ -82,6 +88,8 @@ if ((isset($_POST['edit'])) && (isset($_POST['id']))) {
 
                // Translate comma
                $content['refback'] = TRANSLATE_COMMA($content['refback']);
+               $content['max']     = $_CONFIG['refback_max_percents'];
+               $content['min']     = $_CONFIG['refback_min_percents'];
 
                // Load form for editing
                LOAD_TEMPLATE("member_refback_edit", false, $content);
@@ -132,7 +140,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