Deleting of entries added
authorRoland Häder <roland@mxchange.org>
Thu, 11 Sep 2008 18:43:21 +0000 (18:43 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 11 Sep 2008 18:43:21 +0000 (18:43 +0000)
inc/databases.php
inc/functions.php
inc/language/de.php
inc/modules/admin/admin-inc.php

index 60045547c15e253e7e57ff09cab3a7a8ec877546..70bf8d8334b457df129a59d5acad37e96290b4ce 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "298");
+define('CURR_SVN_REVISION', "299");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index bfe60aa6e7b6439b30ec62198d4ea384d710b102..db1e00d4ecfabe142d9e1487c1c7879a06a259c9 100644 (file)
@@ -2031,15 +2031,14 @@ function scrambleString($str) {
 
                // Add it to final output string
                $scrambled .= $char;
 
                // Add it to final output string
                $scrambled .= $char;
-       }
+       } // END - for
 
        // Return scrambled string
        //* DEBUG: */ echo "***Scrambled=".$scrambled."***<br />";
        return $scrambled;
 }
 //
 
        // Return scrambled string
        //* DEBUG: */ echo "***Scrambled=".$scrambled."***<br />";
        return $scrambled;
 }
 //
-function descrambleString($str)
-{
+function descrambleString($str) {
        global $_CONFIG;
        // Scramble only 40 chars long strings
        if (strlen($str) != 40) return $str;
        global $_CONFIG;
        // Scramble only 40 chars long strings
        if (strlen($str) != 40) return $str;
@@ -2053,11 +2052,10 @@ function descrambleString($str)
        // Begin descrambling
        $orig = str_repeat(" ", 40);
        //* DEBUG: */ echo "+++Scrambled=".$str."+++<br />";
        // Begin descrambling
        $orig = str_repeat(" ", 40);
        //* DEBUG: */ echo "+++Scrambled=".$str."+++<br />";
-       for ($idx = 0; $idx < 40; $idx++)
-       {
+       for ($idx = 0; $idx < 40; $idx++) {
                $char = substr($str, $idx, 1);
                $orig = substr_replace($orig, $char, $scrambleNums[$idx], 1);
                $char = substr($str, $idx, 1);
                $orig = substr_replace($orig, $char, $scrambleNums[$idx], 1);
-       }
+       } // END - for
 
        // Return scrambled string
        //* DEBUG: */ echo "+++Original=".$orig."+++<br />";
 
        // Return scrambled string
        //* DEBUG: */ echo "+++Original=".$orig."+++<br />";
@@ -2077,11 +2075,11 @@ function genScrambleString($len) {
                // Check for it by creating more numbers
                while (array_key_exists($rand, $scrambleNumbers)) {
                        $rand = mt_rand(0, ($len -1));
                // Check for it by creating more numbers
                while (array_key_exists($rand, $scrambleNumbers)) {
                        $rand = mt_rand(0, ($len -1));
-               }
+               } // END - while
 
                // Add number
                $scrambleNumbers[$rand] = $rand;
 
                // Add number
                $scrambleNumbers[$rand] = $rand;
-       }
+       } // END - for
 
        // So let's create the string for storing it in database
        $scrambleString = implode(":", $scrambleNumbers);
 
        // So let's create the string for storing it in database
        $scrambleString = implode(":", $scrambleNumbers);
@@ -2089,8 +2087,7 @@ function genScrambleString($len) {
 }
 // Append data like session ID referral ID to the given URL which would
 // normally be stored in cookies
 }
 // Append data like session ID referral ID to the given URL which would
 // normally be stored in cookies
-function ADD_URL_DATA($URL)
-{
+function ADD_URL_DATA($URL) {
        global $_CONFIG;
        $ADD = "";
 
        global $_CONFIG;
        $ADD = "";
 
@@ -2119,7 +2116,7 @@ function ADD_URL_DATA($URL)
                        // Add current session
                        $ADD .= $BIND."PHPSESSID=".session_id();
                }
                        // Add current session
                        $ADD .= $BIND."PHPSESSID=".session_id();
                }
-       }
+       } // END - if
 
        // Add all together and return it
        return $URL.$ADD;
 
        // Add all together and return it
        return $URL.$ADD;
@@ -2175,8 +2172,8 @@ function FIX_DELETED_COOKIES ($cookies) {
                        if (get_session($cookieName) == "deleted") {
                                set_session($cookieName, "");
                        }
                        if (get_session($cookieName) == "deleted") {
                                set_session($cookieName, "");
                        }
-               }
-       }
+               } // END - foreach
+       } // END - if
 }
 
 // Output error messages in a fasioned way and die...
 }
 
 // Output error messages in a fasioned way and die...
@@ -2431,6 +2428,36 @@ function FILE_READABLE($fqfn) {
        // Check all...
        return ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn)));
 }
        // Check all...
        return ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn)));
 }
+// Converts timestamp selections into a timestamp
+function CONVERT_SELECTIONS_TO_TIMESTAMP(&$POST, &$DATA, &$id, &$skip) {
+       // Init test variable
+       $TEST2 = "";
+
+       // Get last three chars
+       $TEST = substr($id, -3);
+
+       // Improved way of checking! :-)
+       if (in_array($TEST, array("_ye", "_mo", "_we", "_da", "_ho", "_mi", "_se"))) {
+               // Found a multi-selection for timings?
+               $TEST = substr($id, 0, -3);
+               if ((isset($POST[$TEST."_ye"])) && (isset($POST[$TEST."_mo"])) && (isset($POST[$TEST."_we"])) && (isset($POST[$TEST."_da"])) && (isset($POST[$TEST."_ho"])) && (isset($POST[$TEST."_mi"])) && (isset($POST[$TEST."_se"])) && ($TEST != $TEST2)) {
+                       // Generate timestamp
+                       $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
+                       $DATA[] = "$TEST='".$POST[$TEST]."'";
+
+                       // Remove data from array
+                       foreach (array("ye", "mo", "we", "da", "ho", "mi", "se") as $rem) {
+                               unset($POST[$TEST."_".$rem]);
+                       } // END - foreach
+
+                       // Skip adding
+                       unset($id); $skip = true; $TEST2 = $TEST;
+               } // END - if
+       } else {
+               // Process this entry
+               $skip = false; $TEST2 = "";
+       }
+}
 //
 //////////////////////////////////////////////////
 //                                              //
 //
 //////////////////////////////////////////////////
 //                                              //
@@ -2445,7 +2472,7 @@ if (!function_exists('html_entity_decode')) {
                $trans_tbl = array_flip($trans_tbl);
                return strtr($string, $trans_tbl);
        }
                $trans_tbl = array_flip($trans_tbl);
                return strtr($string, $trans_tbl);
        }
-}
+} // END - if
 
 //
 ?>
 
 //
 ?>
index d9c90f426f201d2d8b75ebf70d05973a9fa0f42b..1b3737116e07fafd335ee332102d2ea8aae9bc3a 100644 (file)
@@ -1149,6 +1149,8 @@ define('ADMIN_CONTINUE_LOGIN', "Weiter zum Administratorlogin");
 define('ADMIN_RESET_PASS_LINK', "Jetzt Ihr Administratorkennwort zur&uuml;cksetzen (n&ouml;tiger Schritt!)");
 define('ADMIN_SUPPORT_FORUM_LINK', "Direktlink zum Support-Forum (neues Fenster)");
 define('ADMIN_REFERAL_LEVEL_ZERO_NOTICE', "Die Referal-Ebene 0 ist das Mitglied selber und sollte daher auf 100% stehen. Sie sollte auch nicht ge&auml;ndert oder gel&ouml;scht werden! Dann erhalten Ihre Mitglieder keine {!POINTS!} gutgeschrieben.");
 define('ADMIN_RESET_PASS_LINK', "Jetzt Ihr Administratorkennwort zur&uuml;cksetzen (n&ouml;tiger Schritt!)");
 define('ADMIN_SUPPORT_FORUM_LINK', "Direktlink zum Support-Forum (neues Fenster)");
 define('ADMIN_REFERAL_LEVEL_ZERO_NOTICE', "Die Referal-Ebene 0 ist das Mitglied selber und sollte daher auf 100% stehen. Sie sollte auch nicht ge&auml;ndert oder gel&ouml;scht werden! Dann erhalten Ihre Mitglieder keine {!POINTS!} gutgeschrieben.");
+define('ADMIN_ALL_ENTRIES_REMOVED', "Alle ausgew&auml;hlten Eintr&auml;ge sind gel&ouml;scht.");
+define('ADMIN_SOME_ENTRIES_NOT_DELETED', "Es wurden <u>%s</u> von <u>%s</u> ausgew&auml;hlten Eintr&auml;ge gel&ouml;scht.");
 
 //
 ?>
 
 //
 ?>
index 377cdfab91be1ca2d7b26bded6c8ebf96a0d0ddd..1a8c01ad9970852bf207cae40bceab83fe3b45f5 100644 (file)
@@ -548,43 +548,20 @@ function ADMIN_MENU_SELECTION($MODE, $default="", $defid="") {
        // Return output
        return $OUT;
 }
        // Return output
        return $OUT;
 }
-//
-function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="config=0", $translateComma = array(), $alwaysAdd=false) {
+// Save settings to the database
+function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="config=0", $translateComma=array(), $alwaysAdd=false) {
        global $_CONFIG, $cacheArray, $cacheInstance;
 
        // Prepare all arrays, variables
        $DATA = array();
        $skip = false;
        global $_CONFIG, $cacheArray, $cacheInstance;
 
        // Prepare all arrays, variables
        $DATA = array();
        $skip = false;
-       $TEST2 = "";
 
        // Now, walk through all entries and prepare them for saving
        foreach ($POST as $id => $val) {
                // Process only formular field but not submit buttons ;)
                if ($id != "ok") {
                        // Do not save the ok value
 
        // Now, walk through all entries and prepare them for saving
        foreach ($POST as $id => $val) {
                // Process only formular field but not submit buttons ;)
                if ($id != "ok") {
                        // Do not save the ok value
-                       $TEST = substr($id, -3);
-
-                       // Improved way of checking! :-)
-                       if (in_array($TEST, array("_ye", "_mo", "_we", "_da", "_ho", "_mi", "_se"))) {
-                               // Found a multi-selection for timings?
-                               $TEST = substr($id, 0, -3);
-                               if ((isset($POST[$TEST."_ye"])) && (isset($POST[$TEST."_mo"])) && (isset($POST[$TEST."_we"])) && (isset($POST[$TEST."_da"])) && (isset($POST[$TEST."_ho"])) && (isset($POST[$TEST."_mi"])) && (isset($POST[$TEST."_se"])) && ($TEST != $TEST2)) {
-                                       // Generate timestamp
-                                       $POST[$TEST] = CREATE_TIMESTAMP_FROM_SELECTIONS($TEST, $POST);
-                                       $DATA[] = "$TEST='".$POST[$TEST]."'";
-
-                                       // Remove data from array
-                                       foreach (array("ye", "mo", "we", "da", "ho", "mi", "se") as $rem) {
-                                               unset($POST[$TEST."_".$rem]);
-                                       } // END - foreach
-
-                                       // Skip adding
-                                       unset($id); $skip = true; $TEST2 = $TEST;
-                               }
-                       } else {
-                               // Process this entry
-                               $skip = false; $TEST2 = "";
-                       }
+                       CONVERT_SELECTIONS_TO_TIMESTAMP($POST, $DATA, $id, $skip);
 
                        // Shall we process this ID? It muss not be empty, of course
                        if ((!$skip) && (!empty($id))) {
 
                        // Shall we process this ID? It muss not be empty, of course
                        if ((!$skip) && (!empty($id))) {
@@ -595,7 +572,7 @@ function ADMIN_SAVE_SETTINGS (&$POST, $tableName="_config", $whereStatement="con
                                if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
                                        // Then do it here... :)
                                        $val = str_replace(",", ".", $val);
                                if ((is_array($translateComma)) && (in_array($id, $translateComma))) {
                                        // Then do it here... :)
                                        $val = str_replace(",", ".", $val);
-                               }
+                               } // END - if
 
                                // Shall we add numbers or strings?
                                $test = (float)$val;
 
                                // Shall we add numbers or strings?
                                $test = (float)$val;
@@ -837,7 +814,23 @@ function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $columns=array(), $filterFu
                // Shall we delete here or list for deletion?
                if ($deleteNow) {
                        // Delete them
                // Shall we delete here or list for deletion?
                if ($deleteNow) {
                        // Delete them
-                       die("DELETE!");
+                       $SQL = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_%s WHERE %s IN (%s)";
+                       $idList = "";
+                       foreach ($IDs as $id => $sel) {
+                               $idList .= $id.",";
+                       } // END - if
+
+                       // Run the query
+                       SQL_QUERY($SQL, array($table, $idColumn, substr($idList, 0, -1)), __FILE__, __LINE__);
+
+                       // Was this fine?
+                       if (SQL_AFFECTEDROWS() == count($IDs)) {
+                               // All deleted
+                               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ALL_ENTRIES_REMOVED);
+                       } else {
+                               // Some are still there :(
+                               LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_SOME_ENTRIES_NOT_DELETED, SQL_AFFECTEDROWS(), count($IDs)));
+                       }
                } else {
                        // List for deletion confirmation
                        ADMIN_BUILD_LIST("del", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
                } else {
                        // List for deletion confirmation
                        ADMIN_BUILD_LIST("del", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);