rewritten to new functions, some parts rewritten to filters
[mailer.git] / inc / modules / admin / what-config_points.php
index 085393a3d5150737e4e3b28916cbf5d97eccfe0b..88e5d89919bcd4678f67494a575343d4958c56b0 100644 (file)
@@ -68,18 +68,18 @@ if (REQUEST_ISSET_GET(('sub'))) {
 }
 
 if (IS_FORM_SENT()) {
-       $SQLs = array();
+       INIT_SQLS();
        switch (REQUEST_GET('sub'))
        {
        case "points":
-               $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_config` SET points_register='".REQUEST_POST('points_register')."', points_ref='".REQUEST_POST('points_ref')."' WHERE config=0 LIMIT 1";
+               ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_config` SET points_register='".REQUEST_POST('points_register')."', points_ref='".REQUEST_POST('points_ref')."' WHERE config=0 LIMIT 1");
                break;
 
        case "ref":
                switch (REQUEST_GET('do'))
                {
                case "add":
-                       $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_refdepths` (level, percents) VALUES ('".REQUEST_POST('lvl')."','".REQUEST_POST('perc')."')";
+                       ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_refdepths` (level, percents) VALUES ('".REQUEST_POST('lvl')."','".REQUEST_POST('perc')."')");
                        break;
 
                case "edit": // Change entries
@@ -114,7 +114,7 @@ if (IS_FORM_SENT()) {
 
        case "settings":
                $REF = bigintval(REQUEST_POST('ref_payout'));
-               $SQLs[] = sprintf("UPDATE `{!_MYSQL_PREFIX!}_config` SET
+               ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_config` SET
 allow_direct_pay='%s',
 reg_points_mode='%s',
 ref_payout='%s'
@@ -122,30 +122,30 @@ WHERE config=0 LIMIT 1",
                        REQUEST_POST('allow_direct_pay'),
                        REQUEST_POST('reg_points_mode'),
                        $REF
-               );
+               ));
                if ((getConfig('ref_payout') == 0) && (REQUEST_POST('ref_payout') > 0)) {
                        // Update account's ref_payout for "must-confirm"
-                       $SQLs[] = sprintf("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=(%s - mails_confirmed)
-WHERE mails_confirmed < %s", $REF, $REF);
+                       ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=(%s - mails_confirmed)
+WHERE mails_confirmed < %s", $REF, $REF));
                } elseif ((getConfig('ref_payout') > 0) && (REQUEST_POST('ref_payout') == 0)) {
                        // Update account's ref_payout for "not-must-confirm"
-                       $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0";
-                       $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0";
-                       $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_user_points` SET locked_points=0 WHERE locked_points>0";
+                       ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0");
+                       ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0");
+                       ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET locked_points=0 WHERE locked_points>0");
                }
                break;
        }
 
-       if ((isset($SQLs)) && (is_array($SQLs)) && (!empty($SQLs[0]))) {
-               if (strpos($SQLs[0], "INSERT") > -1) {
+       if ((IS_SQLS_VALID()) && (IS_SQLS_VALID())) {
+               if (strpos($GLOBALS['sqls'][0], "INSERT") > -1) {
                        $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level='%s' LIMIT 1",
                                array(bigintval(REQUEST_POST('lvl'))), __FILE__, __LINE__);
                        SQL_FREERESULT($result);
                } // END - if
 
-               if (count($SQLs) > 0) {
+               if (COUNT_SQLS() > 0) {
                        // Run all SQL commands
-                       RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs));
+                       RUN_FILTER('run_sqls', array('dry_run' => false));
 
                        // Entry saved...
                        $message = SETTINGS_SAVED;
@@ -158,7 +158,7 @@ WHERE mails_confirmed < %s", $REF, $REF);
                }
 
                // Remove SQL queries
-               unset($SQLs);
+               UNSET_SQLS();
        }
 
        // Shall we display a message?