]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-refback.php
Frameset support entirely removed, TODO extended, minor template fix
[mailer.git] / inc / modules / member / what-refback.php
index 280aba6cf377ab65ef82ea9c96304803ab4977f1..eac8db386d6dea72b9ce2d9a4d200a5d82aad766 100644 (file)
@@ -39,31 +39,47 @@ if (!defined('__SECURITY')) {
        // User is not logged in
        LOAD_URL("modules.php?module=index");
 } elseif ((!EXT_IS_ACTIVE("refback")) && (!IS_ADMIN())) {
-       // Extension "refback" is not active
        ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "refback");
        return;
 }
 
+// Is the refback system enabled?
+if ($_CONFIG['refback_enabled'] == "N") {
+       // Output message
+       LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_DISABLED);
+       // Abort here
+       return false;
+} // END - if
+
 // Add description as navigation point
-ADD_DESCR("member", basename(__FILE__));
+ADD_DESCR("member", __FILE__);
 
 // Was the form submitted?
 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']));
+               // Revert german commta for testing
+               $percents = REVERT_COMMA($_POST['percents']);
+
+               // Validate percents
+               if ((($percents >= $_CONFIG['refback_min_perc']) || (round($percents) == 0)) && ($percents <= $_CONFIG['refback_max_perc'])) {
+                       // 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_perc'], $_CONFIG['refback_max_perc']));
                }
 
                // Insert line
@@ -74,6 +90,8 @@ if ((isset($_POST['edit'])) && (isset($_POST['id']))) {
 
                // Translate comma
                $content['refback'] = TRANSLATE_COMMA($content['refback']);
+               $content['min']     = TRANSLATE_COMMA($_CONFIG['refback_min_perc'].".0");
+               $content['max']     = TRANSLATE_COMMA($_CONFIG['refback_max_perc'].".0");
 
                // Load form for editing
                LOAD_TEMPLATE("member_refback_edit", false, $content);