]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-config_points.php
Even more double->single converted
[mailer.git] / inc / modules / admin / what-config_points.php
index 46aefa2608b442ee89fc10cbafa3b16a9f7d7215..b255c9cea8ad86d465feba0eeb517c7e4966d23b 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -55,91 +55,49 @@ if (isGetRequestElementSet('sub')) {
                                unsetPostRequestElement('ok');
                        } // END - if
                        break;
-
-               case 'ref':
-                       if (isGetRequestElementSet('do')) {
-                               if (((!isPostRequestElementSet('level')) || (!isPostRequestElementSet('percents'))) && (getRequestElement('do') == 'add')) {
-                                       unsetPostRequestElement('ok');
-                               }
-                       }
-                       break;
        } // END - switch
 } else {
        // Display overview
        setGetRequestElement('sub', 'overview');
 }
 
-if (isFormSent()) {
+// Is a form sent?
+if ((isFormSent('do_delete')) || (isFormSent('do_edit')) || (isFormSent('do_add')) || (isFormSent('save_config'))) {
+       // Init SQLs
        initSqls();
        switch (getRequestElement('sub')) {
                case 'points':
                        adminSaveSettingsFromPostData();
                        break;
 
-               case 'ref':
-                       switch (getRequestElement('do')) {
-                               case 'add':
-                                       addSql("INSERT INTO `{?_MYSQL_PREFIX?}_refdepths` (`level`,`percents`) VALUES ('".bigintval(postRequestElement('level'))."','".bigintval(postRequestElement('percents'))."')");
-                                       break;
-
-                               case 'edit': // Change entries
-                                       foreach (postRequestElement('level') as $id => $value) {
-                                               // Secure id
-                                               $id = bigintval($id);
-
-                                               // Revert german commata
-                                               setPostRequestElement('percents', array($id => convertCommaToDot(postRequestElement('percents', $id))));
-
-                                               // Update entry
-                                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refdepths` SET `level`=%s,`percents`=%s WHERE `id`=%s LIMIT 1",
-                                                       array(bigintval($value), convertCommaToDot(postRequestElement('percents', $id)), $id), __FILE__, __LINE__);
-                                       } // END - foreach
-                                       $message = '{--ADMIN_REFERRAL_DEPTHS_SAVED--}';
-                                       break;
-
-                               case 'delete':
-                                       foreach (postRequestElement('id') as $id => $value) {
-                                               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
-                                               array(bigintval($id)), __FILE__, __LINE__);
-                                       } // END - foreach
-                                       $message = '{--ADMIN_REFERRAL_DEPTHS_DELETED--}';
-                                       break;
-                       } // END - switch
-
-                       // Update cache file
-                       // @TODO Rewrite this to a filter
-                       if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
-                               if ($GLOBALS['cache_instance']->loadCacheFile('refdepths')) $GLOBALS['cache_instance']->removeCacheFile();
-                       } // END - if
-                       break;
-
                case 'settings':
                        $REF = bigintval(postRequestElement('ref_payout'));
                        updateConfiguration(
                                array('allow_direct_pay', 'ref_payout'),
                                array(postRequestElement('allow_direct_pay'), $REF)
                        );
-                       if ((getConfig('ref_payout') == '0') && (postRequestElement('ref_payout') > 0)) {
+                       if ((getRefPayout() == '0') && (postRequestElement('ref_payout') > 0)) {
                                // Update account's ref_payout for "must-confirm"
-                               addSql(sprintf("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=(%s - `mails_confirmed`)
+                               addSql(sprintf('UPDATE
+       `{?_MYSQL_PREFIX?}_user_data`
+SET
+       `ref_payout`=(%s - `mails_confirmed`)
 WHERE
-       `mails_confirmed` < %s", $REF, $REF));
-                       } elseif ((getConfig('ref_payout') > 0) && (postRequestElement('ref_payout') == '0')) {
+       `mails_confirmed` < %s', $REF, $REF));
+                       } elseif ((getRefPayout() > 0) && (postRequestElement('ref_payout') == '0')) {
                                // Update account's ref_payout for "not-must-confirm"
                                addSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=0 WHERE `ref_payout` > 0");
+                               // @TODO Rewrite these two lines for new user_points columns (e.g. locked_order_points) with a filter
                                addSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `points`=`points`+`locked_points` WHERE `locked_points` > 0");
                                addSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `locked_points`=0 WHERE `locked_points` > 0");
                        }
                        break;
        } // END - switch
 
-       if ((isSqlsValid()) && (isSqlsValid())) {
-               // Is INSERT there?
-               if (isInString('INSERT', $GLOBALS['sqls'][0])) {
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`=%s LIMIT 1",
-                               array(bigintval(postRequestElement('level'))), __FILE__, __LINE__);
-                       SQL_FREERESULT($result);
-               } // END - if
+       // Is there an array?
+       if ((getRequestElement('sub') != 'points') && (ifSqlsRegistered())) {
+               // Default is failed-message
+               $message = '<span class="bad">{--SETTINGS_NOT_SAVED--}</span>';
 
                if (countSqls() > 0) {
                        // Run all SQL commands
@@ -150,14 +108,11 @@ WHERE
 
                        // Destroy config cache file here...
                        rebuildCache('config', 'config');
-               } else {
-                       // Prepare failed-message
-                       $message = '<span class="notice">{--SETTINGS_NOT_SAVED--}</span>';
-               }
+               } // END - if
 
                // Remove SQL queries
                unsetSqls();
-       }
+       } // END - if
 
        // Shall we display a message?
        if (!empty($message)) {
@@ -174,62 +129,7 @@ WHERE
        } // END - foreach
 
        // Load template
-       loadTemplate('admin_config_point_settings', false, $content);
-} elseif (getRequestElement('sub') == 'ref') {
-       // 12          3     32    2                        3321
-       if ((isFormSent('delete')) && (ifPostContainsSelections())) {
-               // Delete entries
-               $OUT = '';
-               foreach (postRequestElement('sel') as $id => $value) {
-                       $result = SQL_QUERY_ESC("SELECT `id`,`level`,`percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
-                               array(bigintval($id)), __FILE__, __LINE__);
-                       $content = SQL_FETCHARRAY($result);
-                       SQL_FREERESULT($result);
-
-                       // Load row template and switch color
-                       $OUT .= loadTemplate('admin_delete_reflevel_row', true, $content);
-               } // END - foreach
-
-               // Load main template
-               loadTemplate('admin_delete_reflevel', false, $OUT);
-       } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
-               // Edit entries
-               $OUT = '';
-               foreach (postRequestElement('sel') as $id => $value) {
-                       $result = SQL_QUERY_ESC("SELECT `id`,`level`,`percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
-                               array(bigintval($id)), __FILE__, __LINE__);
-                       $content = SQL_FETCHARRAY($result);
-                       SQL_FREERESULT($result);
-
-                       // Load row template and switch color
-                       $OUT .= loadTemplate('admin_edit_reflevel_row', true, $content);
-               } // END - foreach
-
-               // Load main template
-               loadTemplate('admin_edit_reflevel', false, $OUT);
-       } else {
-               // Referral levels
-               $result = SQL_QUERY("SELECT `id`,`level`,`percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
-               if (!SQL_HASZERONUMS($result)) {
-                       // Make referral levels editable and deletable
-                       $OUT = '';
-
-                       // List already existing categories for editing
-                       while ($content = SQL_FETCHARRAY($result)) {
-                               // Load row template and switch color
-                               $OUT .= loadTemplate('admin_list_reflevel_row', true, $content);
-                       } // END - while
-
-                       // Free memory
-                       SQL_FREERESULT($result);
-
-                       // Load main template
-                       loadTemplate('admin_list_reflevel', false, $OUT);
-               }
-
-               // Form for adding new referral levels
-               loadTemplate('admin_add_reflevel');
-       }
+       loadTemplate('admin_config_point_settings', FALSE, $content);
 } elseif (getRequestElement('sub') == 'points') {
        // Load template
        loadTemplate('admin_config_sub_points');