]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
ADMIN_MEMBER_SELECTION_BOX() does now return a select-tag with the member list
[mailer.git] / inc / modules / admin / admin-inc.php
index 43f531ceeeeefbbe451515d5b16290a350364f45..0c32844379b89018a2b34a4dc563cbaeacb4a81e 100644 (file)
@@ -194,7 +194,7 @@ function admin_WriteData ($file, $comment, $prefix, $suffix, $DATA, $seek=0) {
        $found = false;
 
        // Is the file there and read-/write-able?
-       if ((file_exists($file)) && (is_readable($file)) && (is_writeable($file))) {
+       if ((FILE_READABLE($file)) && (is_writeable($file))) {
                $search = "CFG: ".$comment;
                $tmp = $file.".tmp";
 
@@ -259,7 +259,7 @@ function admin_WriteData ($file, $comment, $prefix, $suffix, $DATA, $seek=0) {
 //
 function ADMIN_DO_ACTION($wht)
 {
-       global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $link, $DATA, $DEPTH;
+       global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $DATA, $DEPTH;
        //* DEBUG: */ echo __LINE__."*".$wht."/".$GLOBALS['module']."/".$GLOBALS['action']."/".$GLOBALS['what']."*<br />\n";
        if (EXT_IS_ACTIVE("cache"))
        {
@@ -309,7 +309,7 @@ LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
 
                // Is valid but does the inlcude file exists?
                $INC = sprintf("%sinc/modules/admin/action-%s.php", PATH, $act);
-               if ((file_exists($INC)) && (is_readable($INC)) && (VALIDATE_MENU_ACTION("admin", $act, $wht)) && (__ACL_ALLOW == true))
+               if ((FILE_READABLE($INC)) && (VALIDATE_MENU_ACTION("admin", $act, $wht)) && (__ACL_ALLOW == true))
                {
                        // Ok, we finally load the admin action module
                        include($INC);
@@ -338,7 +338,7 @@ LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
 //
 function ADD_ADMIN_MENU($act, $wht,$return=false)
 {
-       global $menuDesription, $menuTitle, $link;
+       global $menuDesription, $menuTitle;
        $SUB = false;
 
        // Menu descriptions
@@ -416,7 +416,7 @@ function ADD_ADMIN_MENU($act, $wht,$return=false)
                                                        // ACL is "allow"... hmmm
                                                        $ACL = true;
                                                }
-                                               $readable = ((file_exists($INC)) && (is_readable($INC)));
+                                               $readable = FILE_READABLE($INC);
                                                if ($ACL)
                                                {
                                                        // Insert compiled title and description
@@ -489,7 +489,7 @@ function ADD_ADMIN_MENU($act, $wht,$return=false)
        }
 }
 //
-function ADD_MEMBER_SELECTION_BOX($add_all = false, $return = false, $none = false, $def = "0")
+function ADD_MEMBER_SELECTION_BOX ($def="0", $add_all=false, $return=false, $none=false)
 {
        // Output selection form with all confirmed user accounts listed
        $result = SQL_QUERY("SELECT userid, surname, family FROM "._MYSQL_PREFIX."_user_data ORDER BY userid", __FILE__, __LINE__);
@@ -517,6 +517,9 @@ function ADD_MEMBER_SELECTION_BOX($add_all = false, $return = false, $none = fal
 
                // Load template
                LOAD_TEMPLATE("admin_member_selection_box", false, $GLOBALS['what']);
+       } else {
+               // Return content
+               return "<select name=\"userid\" size=\"1\">\n".$OUT."</select>\n";
        }
 }
 //
@@ -548,43 +551,20 @@ function ADMIN_MENU_SELECTION($MODE, $default="", $defid="") {
        // 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;
-       $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
-                       $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))) {
@@ -595,7 +575,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);
-                               }
+                               } // END - if
 
                                // Shall we add numbers or strings?
                                $test = (float)$val;
@@ -837,7 +817,23 @@ function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $columns=array(), $filterFu
                // 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);